Compare commits

...

70 Commits

Author SHA1 Message Date
862908fe0c Sync with develop branch 2024-08-20 14:12:31 -04:00
035fc1b57c Add initial pre-checks 2024-08-19 17:53:08 -04:00
9f9a798d91 more task rename; block remove 2024-08-07 10:57:30 -04:00
677ba57401 more task rename 2024-08-07 10:54:20 -04:00
2a8ce9fa89 task rename 2024-08-07 10:51:40 -04:00
684c1bef51 cleanup and add code block 2024-08-07 10:17:05 -04:00
e7e90aaaf5 cleanup 2024-08-06 11:47:21 -04:00
aba39cbad4 new service state handling 2024-08-06 11:30:30 -04:00
6fb410cffd fix file references 2024-08-02 21:12:19 -04:00
6f6050cf77 named-chroot initial fix 2024-08-02 21:08:12 -04:00
51402c1189 Docker fix re-implement 2024-08-02 12:49:17 -04:00
7f5d29dfbf Test Docker fix 2024-08-02 12:37:55 -04:00
7fefca9bef Notes and log path update 2024-08-02 10:44:46 -04:00
27d5965e82 Add service fact gathering 2024-08-01 10:55:04 -04:00
782aa94210 Add reboot code to match scneario 2024-08-01 10:41:45 -04:00
339dcdd6ad Task reorder/move; log path update 2024-08-01 10:13:25 -04:00
8245abf806 Fix conditional; cant check string against integer 2024-07-31 23:29:03 -04:00
490170e752 Task shift 2024-07-31 12:28:58 -04:00
a8fdf951c4 Task file re-name 2024-07-31 12:12:56 -04:00
e53e97cf9a Fix Docker service management; relocate Grub fsck 2024-07-31 11:53:25 -04:00
0b11597038 Logic prune 2024-07-31 10:03:36 -04:00
4ca8d421e2 More shufflin ¯\_(ツ)_/¯ 2024-07-30 18:05:08 -04:00
fad845dd1d Doing the task shuffle. ¯\_(ツ)_/¯ 2024-07-30 17:48:03 -04:00
b440005e55 Var fix. 2024-07-30 17:31:12 -04:00
94c4366903 Indent fix. Yes, again. 2024-07-30 17:27:39 -04:00
b7b6f9555d Indent fix. 2024-07-30 17:25:52 -04:00
64f1220935 That task wasnt supposed to be there! 2024-07-30 17:23:20 -04:00
664291b15d Support for logging of disabled services 2024-07-30 17:16:57 -04:00
f655d19716 fixes 2024-07-29 16:08:33 -04:00
205101856b add filters 2024-07-26 15:55:40 -04:00
42709c4fe6 variable naming fix 2024-07-26 15:51:34 -04:00
050939b52a add default 2024-07-26 15:42:23 -04:00
22d4c220ab fix hosts 2024-07-26 14:16:28 -04:00
d7c73f1a97 refactor 2024-07-26 14:12:10 -04:00
fd108e2b69 import->include 2024-07-26 11:40:03 -04:00
51ba92ecd7 fix playbook 2024-07-26 11:36:17 -04:00
2b31c70a8c add task to check workaround for set_stats 2024-07-26 11:31:54 -04:00
6a0b9ff2ba fix docker service management 2024-07-23 23:21:29 -04:00
427e817ba6 fix aggregate 2024-07-23 16:32:05 -04:00
ef87a6f20e aggregate 2024-07-23 16:29:01 -04:00
eccb4d523a fix per_host 2024-07-23 15:57:51 -04:00
7c31c184d4 per_host 2024-07-23 15:56:14 -04:00
4a1f42bea0 remove aggregate/per_host 2024-07-23 15:45:09 -04:00
c5ccbf28cb remove problematic debugging code 2024-07-23 15:35:27 -04:00
4ee78bead1 fixes for multiple hosts 2024-07-23 15:20:10 -04:00
164307eab7 nevermind; reverted 2024-07-21 00:59:53 -04:00
9284232e47 include role instead of import playbook 2024-07-21 00:58:44 -04:00
3cc0f210e6 task rename 2024-07-21 00:56:04 -04:00
8d289a9d09 fixdebugging 2024-07-21 00:45:11 -04:00
b081b69ba9 debugging 2024-07-21 00:39:27 -04:00
04dd540fe8 fixes 2024-07-20 00:24:40 -04:00
788553a9b6 fixes 2024-07-20 00:20:50 -04:00
da08d182c4 fixes 2024-07-20 00:19:42 -04:00
9d5e0cf89d fixes 2024-07-20 00:13:46 -04:00
37f7723d8c fixes 2024-07-20 00:10:59 -04:00
d958c3501f more logic fixes 2024-07-20 00:08:44 -04:00
47b9224223 logic fixes 2024-07-19 23:53:58 -04:00
e1c5d48796 fixes 2024-07-19 22:01:47 -04:00
eb2e9eb4ae fixes 2024-07-19 21:46:18 -04:00
58ffce84ed fix verified 2024-07-19 09:37:41 -04:00
0f84be55b2 fix verify 2024-07-18 16:44:33 -04:00
337d6df638 fix for fix for disable docker if found; re-enable post-bigboot 2024-07-18 14:19:55 -04:00
5c9f42248b fix for disable docker if found; re-enable post-bigboot 2024-07-18 14:19:25 -04:00
549eae7551 disable docker if found; re-enable post-bigboot 2024-07-18 14:15:54 -04:00
209edd45a4 re-enable service handling; add debug summary of disabled services 2024-07-18 11:45:04 -04:00
438c50a955 truncate bigboot-noop.yml for now 2024-07-18 00:23:12 -04:00
842ec2bac9 Fix to allow per-host Bigboot executions; revised again - indent fix 2024-07-17 18:45:31 -04:00
9567293eb8 Fix to allow per-host Bigboot executions; revised again 2024-07-17 18:40:35 -04:00
d26ca163a6 Fix to allow per-host Bigboot executions; revised 2024-07-17 18:23:49 -04:00
c34ecde485 Fix to allow per-host Bigboot executions 2024-07-17 18:22:49 -04:00
16 changed files with 266 additions and 167 deletions

View File

@ -5,3 +5,4 @@ skip_list:
- no-changed-when
- run-once[play]
- name[template]
- jinja[spacing]

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ filter_plugins/*.bak
python/
collections/ansible_collections
roles/autofsck
*.bak

View File

@ -18,79 +18,17 @@
- name: Capture logical volume information
ansible.builtin.import_tasks: tasks/capture_lv_device_details.yml
- name: Perform a ReaR backup if any disk modifications are to be made
ansible.builtin.import_playbook: rhc.rear.rear_backup
when:
- bigboot_execute_bigboot | default('false') | bool
- not bigboot_skip_rear_backup | default('true') | bool
- name: Perform logical volume and boot parition resizing as needed
hosts: all
become: true
gather_facts: true
strategy: free
vars_files:
- bigboot_vars.yml
tasks:
- name: Perform service and filesystem checks prior to Bigboot execution
when:
- (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool)
block:
# - name: Check for and disable services exceeding the timeout threshold
# ansible.builtin.import_tasks: tasks/check_systemd_services.yml
- 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: Extend the timeout values for physical hosts
ansible.builtin.set_fact:
initramfs_post_reboot_delay: 300
initramfs_reboot_timeout: 14400
when:
- "'host' in ansible_virtualization_role"
- name: Shrink the logical volume to support /boot expansion
ansible.builtin.debug:
msg:
- "device: {{ bigboot_adjacent_lvm_device }}"
- "size : {{ bigboot_lv_shrink_size | int }}"
when:
- bigboot_execute_shrink_lv | bool
- name: Expand the /boot partition as requested
ansible.builtin.debug:
msg: "{{ bigboot_size }}"
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 }}"
# when:
# - bigboot_systemd_disabled_services is defined
# - bigboot_systemd_disabled_services | length > 0
- name: Set environment for subsequent workflow nodes
ansible.builtin.set_stats:
data:
bigboot_data: "{{ bigboot_data | default({}) |
combine({inventory_hostname:
{
'bigboot_execute_bigboot': bigboot_execute_bigboot,
'bigboot_execute_shrink_lv': bigboot_execute_shrink_lv,
'bigboot_adjacent_lvm_device': bigboot_adjacent_lvm_device,
'bigboot_lv_shrink_size': bigboot_lv_shrink_size | int,
'bigboot_size': bigboot_size,
'bigboot_skip_rear_backup': bigboot_skip_rear | default('false')
}
})}}"

View File

@ -9,33 +9,10 @@
- bigboot_vars.yml
tasks:
- name: Perform service and filesystem checks prior to Bigboot execution
- name: Perform filesystem check prior to Bigboot execution
ansible.builtin.import_tasks: tasks/grub_filesystem_check.yml
when:
- (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool)
block:
# - name: Check for and disable services exceeding the timeout threshold
# ansible.builtin.import_tasks: tasks/check_systemd_services.yml
- 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
- bigboot_data[inventory_hostname]['bigboot_execute_bigboot'] | default(false) | bool
- name: Extend the timeout values for physical hosts
ansible.builtin.set_fact:
@ -49,23 +26,18 @@
name: infra.lvm_snapshots.shrink_lv
vars:
shrink_lv_devices:
- device: "{{ bigboot_adjacent_lvm_device }}"
size: "{{ bigboot_lv_shrink_size | int }}"
- device: "{{ bigboot_data[inventory_hostname]['bigboot_adjacent_lvm_device'] }}"
size: "{{ bigboot_data[inventory_hostname]['bigboot_lv_shrink_size'] | int }}"
when:
- bigboot_execute_shrink_lv | bool
- bigboot_data[inventory_hostname]['bigboot_execute_shrink_lv'] | bool
- name: Expand the /boot partition as requested
ansible.builtin.import_role:
name: infra.lvm_snapshots.bigboot
vars:
bigboot_size: "{{ bigboot_data[inventory_hostname]['bigboot_size'] }}"
when:
- bigboot_execute_bigboot | bool
- bigboot_data[inventory_hostname]['bigboot_execute_bigboot'] | bool
# - name: Re-enabling services previously disabled
# ansible.builtin.service:
# name: "{{ item }}"
# state: started
# enabled: true
# loop: "{{ bigboot_systemd_disabled_services }}"
# when:
# - bigboot_systemd_disabled_services is defined
# - bigboot_systemd_disabled_services | length > 0
- name: Restore service state for disabled services
ansible.builtin.import_tasks: tasks/restore_services.yml

View File

@ -1,6 +1,6 @@
---
- name: Perform a ReaR backup if any disk modifications are to be made
- name: Perform a ReaR backup before the /boot expansion
ansible.builtin.import_playbook: rhc.rear.rear_backup
when:
- bigboot_execute_bigboot | default('false') | bool
- not bigboot_skip_rear_backup | default('true') | bool
- bigboot_data[inventory_hostname]['bigboot_execute_bigboot'] | default(false) | bool
- not rear_backup_skip | default(false) | bool

View File

@ -0,0 +1,19 @@
---
- name: Perform logical volume and boot parition resizing as needed
hosts: rear_server
become: true
gather_facts: false
vars_files:
- bigboot_vars.yml
tasks:
- name: Create IP list and add to NFS exports
ansible.builtin.include_tasks: tasks/rear_nfs_exports.yml
loop: "{{ bigboot_data | dict2items }}"
loop_control:
label: "{{ item['key'] }}"
when:
- item['value']['bigboot_execute_bigboot'] | default(false) | bool
- not rear_backup_skip | default(false) | bool

View File

@ -12,22 +12,35 @@
- name: Cleanup from any previous executions
ansible.builtin.import_tasks: tasks/cleanup.yml
- name: Capture boot device details
- name: Check for services that require being disabled
ansible.builtin.import_tasks: tasks/check_services.yml
- name: Set boot device details
ansible.builtin.import_tasks: tasks/capture_boot_device_details.yml
- name: Capture logical volume information
- name: Set logical volume information
ansible.builtin.import_tasks: tasks/capture_lv_device_details.yml
- name: Run pre-checks to verify environment
ansible.builtin.import_tasks: tasks/pre-checks.yml
when:
- bigboot_execute_bigboot | bool
- name: Set environment for subsequent workflow nodes
ansible.builtin.set_stats:
aggregate: true
data:
bigboot_execute_bigboot: "{{ bigboot_execute_bigboot }}"
bigboot_execute_shrink_lv: "{{ bigboot_execute_shrink_lv }}"
bigboot_adjacent_lvm_device: "{{ bigboot_adjacent_lvm_device }}"
bigboot_lv_shrink_size: "{{ bigboot_lv_shrink_size | int }}"
bigboot_partition_size: "{{ bigboot_partition_size }}"
bigboot_skip_rear_backup: "{{ bigboot_skip_rear | default('false') }}"
per_host: false
aggregate: false
bigboot_data: "{{ bigboot_data | default({}) |
combine({inventory_hostname:
{
'bigboot_execute_bigboot': bigboot_execute_bigboot,
'bigboot_execute_shrink_lv': bigboot_execute_shrink_lv,
'bigboot_adjacent_lvm_device': bigboot_adjacent_lvm_device,
'bigboot_lv_shrink_size': bigboot_lv_shrink_size | int,
'bigboot_size': bigboot_size,
'ip_addresses': ansible_all_ipv4_addresses,
'server_hostname': ansible_hostname
}
}) }}"
...

56
tasks/check_services.yml Normal file
View File

@ -0,0 +1,56 @@
---
- 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:
"{{ bigboot_systemd_running_services | default([]) + [item['key']] }}"
loop: "{{ ansible_facts['services'] | dict2items }}"
loop_control:
label: "{{ item['key'] }}"
when:
- "'running' in item['value']['state']"
- name: Get the stop timeout value for running services
ansible.builtin.shell:
cmd: |
set -o pipefail
systemctl show {{ item }} | grep TimeoutStopUSec
changed_when: false
register: bigboot_systemd_service_timeout
loop: "{{ bigboot_systemd_running_services }}"
- name: Adding services exceeding the timeout threshold to the list of services to disable
ansible.builtin.set_fact:
bigboot_services_disabled: "{{ bigboot_services_disabled | default([]) + [item['item']] }}"
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 | int
- name: Adding incompatible services to the list of services to disable
ansible.builtin.set_fact:
bigboot_services_disabled: "{{ bigboot_services_disabled | default([]) + [item] }}"
loop: "{{ bigboot_incompatible_services }}"
when:
- ansible_facts['services'][item] is defined
- ansible_facts['services'][item]['state'] == "running"
- name: Log and disable services
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(', ') }}

View File

@ -1,31 +0,0 @@
---
- name: Get the list of services on the host
ansible.builtin.service_facts:
- name: Capture a list of running services
ansible.builtin.set_fact:
bigboot_systemd_running_services:
"{{ bigboot_systemd_running_services | default([]) + [item['key']] }}"
loop: "{{ ansible_facts['services'] | dict2items }}"
loop_control:
label: "{{ item['key'] }}"
when:
- "'running' in item['value']['state']"
- name: Get the stop timeout value for running services
ansible.builtin.shell:
cmd: |
set -o pipefail
systemctl show {{ item }} | grep TimeoutStopUSec
changed_when: false
register: bigboot_systemd_service_timeout
loop: "{{ bigboot_systemd_running_services }}"
- 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

View File

@ -29,4 +29,14 @@
path: "/boot/initramfs-{{ initramfs_kernel_version }}.img.{{ initramfs_backup_extension }}"
state: absent
- name: Check for Bigboot state log and restore services to pre-Bigboot state
ansible.builtin.import_tasks: tasks/restore_services.yml
- name: Cleanup previous Bigboot state log if present
ansible.builtin.file:
path: "{{ bigboot_disabled_services_log }}"
state: absent
when:
- bigboot_disabled_services_log_stat['stat']['exists'] | bool
...

View File

@ -1,11 +1,23 @@
---
- name: Disabling service for exceeding the timeout threshold
- name: "Save service state: {{ item }}"
ansible.builtin.set_fact:
bigboot_service_to_disable:
service: "{{ ansible_facts['services'][item]['name'] }}"
state: "{{ (ansible_facts['services'][item]['state'] == 'running') | ternary('started', 'stopped') }}"
status: "{{ (ansible_facts['services'][item]['status'] == 'enabled') | ternary('true', 'false') }}"
- name: "Disable and stop service: {{ item }}"
ansible.builtin.service:
name: "{{ item['item'] }}"
name: "{{ item }}"
state: stopped
enabled: false
- name: Append service to list of disabled services
ansible.builtin.set_fact:
bigboot_systemd_disabled_services:
"{{ bigboot_systemd_disabled_services | default([]) + [item['item']] }}"
- name: "Log disabled service state: {{ item }}"
ansible.builtin.lineinfile:
path: "{{ bigboot_disabled_services_log }}"
line: "{{ item }},{{ bigboot_service_to_disable['state'] }},{{ bigboot_service_to_disable['status'] }}"
create: true
state: present
owner: root
group: root
mode: "0600"

View File

@ -0,0 +1,30 @@
---
- name: Enable Grub filesystem check
ansible.builtin.import_role:
name: autofsck
tasks_from: main.yml
- name: Flush handlers to add Grub parameters for fsck
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: Reboot to run filesystem checks
ansible.builtin.command: /sbin/shutdown -r +1
- name: Wait for the reboot to complete
ansible.builtin.wait_for_connection:
connect_timeout: 20
sleep: 10
delay: "{{ bigboot_post_reboot_delay | default('70') }}"
timeout: "{{ bigboot_reboot_timeout | default('1800') }}"
- name: Disable Grub filesystem check
ansible.builtin.import_role:
name: autofsck
tasks_from: cleanup.yml
- name: Flush handlers to remove Grub parameters for fsck
ansible.builtin.meta: flush_handlers

29
tasks/pre-checks.yml Normal file
View File

@ -0,0 +1,29 @@
---
- name: Get /boot mount information
ansible.builtin.set_fact:
bigboot_boot_mount: "{{ ansible_facts.mounts \
| selectattr('mount', 'equalto', '/boot') | first }}"
- name: Set next partition after /boot
ansible.builtin.set_fact:
bigboot_next_device: "{{ bigboot_boot_mount['device'][:-1] }}{{ bigboot_boot_mount['device'][-1:] | int + 1 }}"
- name: Capture partition information from fdisk
ansible.builtin.shell:
cmd: |
set -o pipefail
fdisk -l {{ bigboot_boot_mount['device'][:-1] }} | grep '{{ bigboot_next_device }}'
executable: /bin/bash
changed_when: false
failed_when: bigboot_fdisk_partition['rc'] not in [0, 141]
register: bigboot_fdisk_partition
- name: Debug bigboot_fdisk_partition
ansible.builtin.debug:
var: bigboot_fdisk_partition
- name: Assert that the partition following /boot is of type LVM
ansible.builtin.assert:
that: "'Linux LVM' in bigboot_fdisk_partition['stdout']"
success_msg: The partition following /boot is an LVM partition
fail_msg: The partition following /boot is NOT an LVM partition. Execution halted.

View File

@ -0,0 +1,9 @@
---
- name: Create list of IP addresses and hostnames
ansible.builtin.set_fact:
client_ips: "{{ item['value']['ip_addresses'] | list | flatten }}"
namehost: "{{ item['value']['server_hostname'] }}"
- name: Include NFS export role
ansible.builtin.include_role:
name: rhc.rear.say_hi

View File

@ -0,0 +1,25 @@
---
- name: Check for Bigboot service state log presence
ansible.builtin.stat:
path: "{{ bigboot_disabled_services_log }}"
register: bigboot_disabled_services_log_stat
- name: Read state log and restore service state
when:
- bigboot_disabled_services_log_stat['stat']['exists'] | bool
block:
- name: Read service state from log
community.general.read_csv:
path: "{{ bigboot_disabled_services_log }}"
fieldnames: service,state,enabled
delimiter: ','
register: bigboot_service_state_contents
- name: Restore service state
ansible.builtin.service:
name: "{{ item['service'] }}"
state: "{{ item['state'] }}"
enabled: "{{ item['enabled'] | bool }}"
loop: "{{ bigboot_service_state_contents['list'] }}"
loop_control:
label: "{{ item['service'] }}"

View File

@ -8,11 +8,22 @@ bigboot_reboot_timeout: 1800
bigboot_skip_rear_backup: false
# Max value in minutes for the timeout threshold:
bigboot_service_max_timeout: 2
# Max value in minutes for services timeout threshold:
bigboot_service_max_timeout: 5
# List of services incompatible with calculations
# to obtain required disk information:
#
# (These services will ALWAYS be disabled)
bigboot_incompatible_services:
- docker.service
- named-chroot.service
# List of services which will be excluded from being
# disabled during Bigboot execution:
#
# (Services listed in `bigboot_incompatible_services`
# will ALWAYS be disabled regardless if they are protected or not)
bigboot_protected_services:
- sshd.service
- user@0.service
@ -20,3 +31,7 @@ bigboot_protected_services:
- rhnsd.service
- rhnsd
- boksm.service
- SplunkForwarder.service
# Filename of disabled services log:
bigboot_disabled_services_log: /var/ipe/ipu/el7to8/bigboot_disabled_services.log