add service disable on threshold timeout; cleanup bigboot-noop.yml

This commit is contained in:
2024-07-10 20:46:24 -04:00
parent 25c7c4a19e
commit e176c76638
3 changed files with 46 additions and 42 deletions

View File

@ -1,5 +1,5 @@
---
- name: Verify Middleware Apache package presence
- name: Get the list of services on the host
ansible.builtin.service_facts:
- name: Capture a list of running services
@ -12,7 +12,7 @@
when:
- "'running' in item['value']['state']"
- name: Get stop timeout value for running services
- name: Get the stop timeout value for running services
ansible.builtin.shell:
cmd: |
set -o pipefail
@ -21,20 +21,11 @@
register: bigboot_systemd_service_timeout
loop: "{{ bigboot_systemd_running_services }}"
- name: Disable services exceeding the timeout threshold
- name: Disabling services exceeding the timeout threshold
ansible.builtin.include_tasks: tasks/disable_systemd_services.yml
loop: "{{ bigboot_systemd_service_timeout['results'] }}"
loop_control:
label: "{{ item['item'] }}"
when:
- item['item'] not in bigboot_protected_services
- item['stdout'] | regex_replace('^.*=(.*$)', '\\1') | community.general.to_minutes > bigboot_service_max_timeout
block:
- name: Disabling services exceeding the timeout threshold
ansible.builtin.include_tasks: tasks/disable_systemd_services.yml
loop: "{{ bigboot_systemd_service_timeout['results'] }}"
loop_control:
label: "{{ item['item'] }}"
- name: Re-enabling services previously disabled
ansible.builtin.service:
name: "{{ item }}"
state: started
enabled: true
loop: "{{ bigboot_systemd_disabled_services }}"