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

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

View File

@ -33,16 +33,34 @@
strategy: free strategy: free
tasks: tasks:
- name: Add Grub menu parameters for fsck - name: Perform filesystem check prior to Bigboot execution
when:
- (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool)
block:
- name: Enable Grub filesystem check
ansible.builtin.import_role: ansible.builtin.import_role:
name: autofsck name: autofsck
tasks_from: main.yml tasks_from: main.yml
when:
- (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool)
- name: Flush handlers - name: Flush handlers
ansible.builtin.meta: flush_handlers ansible.builtin.meta: flush_handlers
# Make sure to update the reboot code for the WF environment
- name: Reboot to run filesystem checks
ansible.builtin.reboot:
- name: Disable Grub filesystem check
ansible.builtin.import_role:
name: autofsck
tasks_from: cleanup.yml
- name: Flush handlers
ansible.builtin.meta: flush_handlers
- name: Check for and disable services exceeding the timeout threshold
ansible.builtin.import_tasks: tasks/check_systemd_services.yml
- name: Extend the timeout values for physical hosts - name: Extend the timeout values for physical hosts
ansible.builtin.set_fact: ansible.builtin.set_fact:
initramfs_post_reboot_delay: 300 initramfs_post_reboot_delay: 300
@ -64,22 +82,9 @@
when: when:
- bigboot_execute_bigboot | bool - bigboot_execute_bigboot | bool
# this reboot is just for *my* tesitng; at this point we'd have already - name: Re-enabling services previously disabled
# rebooted at least once which would have ran the fsck ansible.builtin.service:
- name: Reboot the host name: "{{ item }}"
ansible.builtin.reboot: state: started
msg: Reboot by Ansible enabled: true
post_reboot_delay: 30 loop: "{{ bigboot_systemd_disabled_services }}"
connect_timeout: 10
reboot_timeout: 120
when:
- (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool)
- name: Cleanup Grub menu parameters for fsck
ansible.builtin.import_role:
name: autofsck
tasks_from: cleanup.yml
when:
- (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool)
...

View File

@ -33,6 +33,9 @@
- name: Flush handlers - name: Flush handlers
ansible.builtin.meta: flush_handlers ansible.builtin.meta: flush_handlers
- name: Check for and disable services exceeding the timeout threshold
ansible.builtin.import_tasks: tasks/check_systemd_services.yml
- name: Extend the timeout values for physical hosts - name: Extend the timeout values for physical hosts
ansible.builtin.set_fact: ansible.builtin.set_fact:
@ -57,4 +60,9 @@
when: when:
- bigboot_execute_bigboot | bool - bigboot_execute_bigboot | bool
... - name: Re-enabling services previously disabled
ansible.builtin.service:
name: "{{ item }}"
state: started
enabled: true
loop: "{{ bigboot_systemd_disabled_services }}"

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