From e176c76638e5ba69b0f07d0f5dec5ca1dbfc3268 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 10 Jul 2024 20:46:24 -0400 Subject: [PATCH] add service disable on threshold timeout; cleanup bigboot-noop.yml --- bigboot-noop.yml | 55 +++++++++++++++++--------------- bigboot_execute_resize.yml | 10 +++++- tasks/check_systemd_services.yml | 23 ++++--------- 3 files changed, 46 insertions(+), 42 deletions(-) diff --git a/bigboot-noop.yml b/bigboot-noop.yml index 2fad2aa..ef4f4be 100644 --- a/bigboot-noop.yml +++ b/bigboot-noop.yml @@ -33,15 +33,33 @@ strategy: free tasks: - - name: Add Grub menu parameters for fsck - ansible.builtin.import_role: - name: autofsck - tasks_from: main.yml + - 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: + name: autofsck + tasks_from: main.yml + + - name: 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: Flush handlers - ansible.builtin.meta: flush_handlers - name: Extend the timeout values for physical hosts ansible.builtin.set_fact: @@ -64,22 +82,9 @@ when: - bigboot_execute_bigboot | bool - # this reboot is just for *my* tesitng; at this point we'd have already - # rebooted at least once which would have ran the fsck - - name: Reboot the host - ansible.builtin.reboot: - msg: Reboot by Ansible - post_reboot_delay: 30 - 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) - -... + - name: Re-enabling services previously disabled + ansible.builtin.service: + name: "{{ item }}" + state: started + enabled: true + loop: "{{ bigboot_systemd_disabled_services }}" diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index fae1638..efe5808 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -33,6 +33,9 @@ - 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 ansible.builtin.set_fact: @@ -57,4 +60,9 @@ when: - bigboot_execute_bigboot | bool -... + - name: Re-enabling services previously disabled + ansible.builtin.service: + name: "{{ item }}" + state: started + enabled: true + loop: "{{ bigboot_systemd_disabled_services }}" diff --git a/tasks/check_systemd_services.yml b/tasks/check_systemd_services.yml index e600704..2c29381 100644 --- a/tasks/check_systemd_services.yml +++ b/tasks/check_systemd_services.yml @@ -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 }}"