cleanup and add code block

This commit is contained in:
2024-08-07 10:17:05 -04:00
parent e7e90aaaf5
commit 684c1bef51
3 changed files with 18 additions and 23 deletions

View File

@ -1,4 +1,7 @@
---
- name: Ensure service facts are available
ansible.builtin.service_facts:
- name: Capture a list of running services
ansible.builtin.set_fact:
bigboot_systemd_running_services:
@ -33,21 +36,21 @@
bigboot_services_disabled: "{{ bigboot_services_disabled | default([]) + [item] }}"
loop: "{{ bigboot_incompatible_services }}"
when:
- item not in bigboot_protected_services
- ansible_facts['services'][item] is defined
- ansible_facts['services'][item]['state'] == "running"
- name: Log and disable services
ansible.builtin.include_tasks: tasks/disable_systemd_services.yml
loop: "{{ bigboot_services_disabled }}"
when:
- bigboot_services_disabled is defined
- name: Services disabled notice
ansible.builtin.debug:
msg: >-
The following services were disabled, and will be re-enabled post
Bigboot execution: {{ bigboot_services_disabled | join(', ') }}
when:
- bigboot_services_disabled is defined
- bigboot_services_disabled | length > 0
block:
- name: Disable services and log their state
ansible.builtin.include_tasks: tasks/disable_systemd_services.yml
loop: "{{ bigboot_services_disabled }}"
- name: Services disabled notice
ansible.builtin.debug:
msg: >-
The following services were disabled, and will be re-enabled post
Bigboot execution: {{ bigboot_services_disabled | join(', ') }}