From f6d129a5936a44aa108b1c773c2c7fca6a268702 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Tue, 26 Mar 2024 15:50:22 -0400 Subject: [PATCH 01/53] cleanup --- .unused_requirements.yml | 17 ------- bigboot-op.yml | 46 ----------------- bigboot-standalone.yml | 16 ------ bigboot.yml | 34 +++++++++++-- preflight.yml | 86 -------------------------------- shrink_lv.yml | 18 ------- tasks/bigboot_manage_lv-noop.yml | 76 ---------------------------- tasks/bigboot_manage_lv-op.yml | 76 ---------------------------- tasks/bigboot_manage_lv.yml | 79 ----------------------------- 9 files changed, 30 insertions(+), 418 deletions(-) delete mode 100644 .unused_requirements.yml delete mode 100644 bigboot-op.yml delete mode 100644 bigboot-standalone.yml delete mode 100644 preflight.yml delete mode 100644 shrink_lv.yml delete mode 100644 tasks/bigboot_manage_lv-noop.yml delete mode 100644 tasks/bigboot_manage_lv-op.yml delete mode 100644 tasks/bigboot_manage_lv.yml diff --git a/.unused_requirements.yml b/.unused_requirements.yml deleted file mode 100644 index d7e423b..0000000 --- a/.unused_requirements.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -roles: [] - -collections: - # RedHat COP - infra.lvm_snapshots - - name: infra.lvm_snapshots - source: https://github.com/redhat-cop/infra.lvm_snapshots.git - type: git - version: main - - - # Galaxy Collections - - name: community.general - - name: ansible.posix - - -... diff --git a/bigboot-op.yml b/bigboot-op.yml deleted file mode 100644 index 5b6f12d..0000000 --- a/bigboot-op.yml +++ /dev/null @@ -1,46 +0,0 @@ ---- -- name: Capture boot and logical volume information - hosts: all - become: true - gather_facts: true - strategy: free - - vars: - bigboot_size_target: 1G - - - tasks: - - name: Capture boot device details - ansible.builtin.import_tasks: tasks/capture_boot_device_details.yml - - - 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 | bool - - -- name: Perform logical volume and boot parition resizing as needed - hosts: all - become: true - gather_facts: true - strategy: free - - tasks: - - name: Expand the logical volume to support /boot expansion - ansible.builtin.import_role: - name: infra.lvm_snapshots.shrink_lv - vars: - shrink_lv_devices: - - device: "{{ bigboot_adjacent_lvm_device | trim }}" - size: "{{ bigboot_lv_shrink_size | int }}" - when: - - bigboot_execute_shrink_lv | bool - - - name: Expand the /boot partition as requested - ansible.builtin.import_role: - name: infra.lvm_snapshots.bigboot - when: bigboot_execute_bigboot | bool diff --git a/bigboot-standalone.yml b/bigboot-standalone.yml deleted file mode 100644 index 5a82639..0000000 --- a/bigboot-standalone.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -- name: Resize the /boot parition to the desired size - hosts: all - become: true - gather_facts: true - - - vars: - bigboot_size: "{{ bigboot_new_size | default('') }}" - - - roles: - - infra.lvm_snapshots.bigboot - - -... diff --git a/bigboot.yml b/bigboot.yml index 3932045..5b6f12d 100644 --- a/bigboot.yml +++ b/bigboot.yml @@ -1,5 +1,5 @@ --- -- name: Resize the /boot parition to the desired size +- name: Capture boot and logical volume information hosts: all become: true gather_facts: true @@ -8,13 +8,39 @@ vars: bigboot_size_target: 1G + tasks: - name: Capture boot device details ansible.builtin.import_tasks: tasks/capture_boot_device_details.yml - - name: Shrink a logical volume for /boot expansion if needed - ansible.builtin.import_tasks: tasks/bigboot_manage_lv.yml + - 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 | bool + + +- name: Perform logical volume and boot parition resizing as needed + hosts: all + become: true + gather_facts: true + strategy: free + + tasks: + - name: Expand the logical volume to support /boot expansion + ansible.builtin.import_role: + name: infra.lvm_snapshots.shrink_lv + vars: + shrink_lv_devices: + - device: "{{ bigboot_adjacent_lvm_device | trim }}" + size: "{{ bigboot_lv_shrink_size | int }}" + when: + - bigboot_execute_shrink_lv | bool - name: Expand the /boot partition as requested - ansible.builtin.include_role: + ansible.builtin.import_role: name: infra.lvm_snapshots.bigboot + when: bigboot_execute_bigboot | bool diff --git a/preflight.yml b/preflight.yml deleted file mode 100644 index fdab49a..0000000 --- a/preflight.yml +++ /dev/null @@ -1,86 +0,0 @@ ---- -- name: Create VG and LVOL for shrink_lv testing - hosts: all - become: true - gather_facts: true - - - vars: - __part_size: 80GB - __partition_devices: - # - /dev/sdb - # - /dev/sdc - - /dev/sdd - - /dev/sde - - __vg_name : test-vg02 - __lv_name : test-lv02 - __lv_size : 120g - __lv_mount : "/lvol/{{ __lv_name }}" - __lv_fstype : ext4 - - - tasks: - - name: Debug __partition_devices - ansible.builtin.debug: - msg: - - "{{ __partition_devices }}" - - "{{ __partition_devices | join(',') }}" - - "{{ __partition_devices | \ - map('regex_replace', '(?Psd.*)', '\\g' + '1', multiline=True) }}" - verbosity: 1 - - - - name: Install LVM2 - ansible.builtin.package: - name : lvm2 - state : present - - - - name: Create partitions on all drives - community.general.parted: - device : "{{ item }}" - number : 1 - flags : ['lvm'] - state : present - part_end : "{{ __part_size }}" - loop: "{{ __partition_devices }}" - - - - name: Create VG - community.general.lvg: - vg : "{{ __vg_name }}" - pvs : "{{ __partition_devices | \ - map('regex_replace', '(?Psd.*)', '\\g' + '1', multiline=True) }}" - - - - name: Create LV - community.general.lvol: - vg : "{{ __vg_name }}" - lv : "{{ __lv_name }}" - size : "{{ __lv_size }}" - force : true - - - - name: Create lvol mount point - ansible.builtin.file: - path : "{{ __lv_mount }}" - state : directory - mode : "0755" - - - - name: Create filesystem on {{ __lv_name }} - community.general.filesystem: - dev : "/dev/{{ __vg_name }}/{{ __lv_name }}" - fstype : "{{ __lv_fstype }}" - - - - name: Mount {{ __lv_mount }} - ansible.posix.mount: - path : "{{ __lv_mount }}" - src : "/dev/{{ __vg_name }}/{{ __lv_name }}" - fstype : "{{ __lv_fstype }}" - state : mounted - - -... diff --git a/shrink_lv.yml b/shrink_lv.yml deleted file mode 100644 index 1ea00a8..0000000 --- a/shrink_lv.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -- name: Shrink specific logical volume to given size - hosts: all - become: true - gather_facts: true - - - vars: - shrink_lv_devices: - - device: "{{ shrink_lv_logical_volume | default('') }}" - size: "{{ shrink_lv_volume_size | default('') }}" - - - roles: - - infra.lvm_snapshots.shrink_lv - - -... diff --git a/tasks/bigboot_manage_lv-noop.yml b/tasks/bigboot_manage_lv-noop.yml deleted file mode 100644 index 62ff11d..0000000 --- a/tasks/bigboot_manage_lv-noop.yml +++ /dev/null @@ -1,76 +0,0 @@ ---- -- name: Capture logical volume adjacent to /boot - ansible.builtin.shell: - cmd: | - set -o pipefail - lsblk -p -o name,type|grep lvm|head -1 - executable: /bin/bash - changed_when: false - register: bigboot_adjacent_lvm - -- name: Set adjacent LVM device name - ansible.builtin.set_fact: - bigboot_adjacent_lvm_device: "{{ bigboot_adjacent_lvm.stdout | regex_replace('.*(/dev.*)\\s+.*$', '\\1') }}" - -- name: Get logical volume mount information - ansible.builtin.set_fact: - bigboot_lv_info: "{{ ansible_facts.mounts \ - | selectattr('device', 'equalto', bigboot_adjacent_lvm_device | trim) | first }}" - -- name: Assert that there is space on the logical volume for shrinkage - ansible.builtin.assert: - that: bigboot_lv_info.size_available > bigboot_expansion_diff | int - fail_msg: There is not enough space available for LV shrinking. - -- name: Capture shrink size for logical volume - ansible.builtin.set_fact: - bigboot_lv_shrink_size: "{{ bigboot_lv_info.size_total - bigboot_expansion_diff | int }}" - -- name: Capture logical volume name - ansible.builtin.shell: - cmd: | - set -o pipefail - lvdisplay {{ bigboot_adjacent_lvm_device }} | grep -i 'vg name' - executable: /bin/bash - changed_when: false - register: bigboot_lv_vg_name - -- name: Format logical volume name - ansible.builtin.set_fact: - bigboot_lv_vg_name: "{{ bigboot_lv_vg_name.stdout | regex_replace('VG\\s+Name\\s+(.*)$', '\\1') }}" - -- name: Capture volume group free PE - ansible.builtin.shell: - cmd: | - set -o pipefail - vgdisplay {{ bigboot_lv_vg_name | trim }} | grep -i 'free' - executable: /bin/bash - changed_when: false - register: bigboot_lv_vg_free_pe - -- name: Format logical volume free PE - ansible.builtin.set_fact: - # Ex: - # Free PE / Size 320 / 1.25 GiB" - # Free PE / Size 189 / 756.00 MiB" - # Free PE / Size 414 / <1.62 GiB - # Free PE / Size 0 / 0 - bigboot_lv_vg_free_pe: "{{ bigboot_lv_vg_free_pe.stdout | regex_replace('^.*/.*/\\s+[<]?(.*)', '\\1') }}" - -- name: Get size in MB for PE and - ansible.builtin.set_fact: - bigboot_lv_pe_size_in_mb: - "{{ bigboot_lv_vg_free_pe | regex_replace('i|\\s+|<', '') | human_to_bytes | human_readable(unit='M') }}" - -- name: Verify if there's available PE or not and execute Shrink_LV - block: - - name: Assert if we need to execute the shrink_lv role to gain free PE - ansible.builtin.assert: - that: (bigboot_lv_pe_size_in_mb[:-3] | int | round) | int > bigboot_size[:-1] | int - fail_msg: Not enough PE to expand /boot. - - rescue: - - name: Set flag to execute shrink_lv - ansible.builtin.set_fact: - bigboot_execute_shrink_lv: true - diff --git a/tasks/bigboot_manage_lv-op.yml b/tasks/bigboot_manage_lv-op.yml deleted file mode 100644 index 62ff11d..0000000 --- a/tasks/bigboot_manage_lv-op.yml +++ /dev/null @@ -1,76 +0,0 @@ ---- -- name: Capture logical volume adjacent to /boot - ansible.builtin.shell: - cmd: | - set -o pipefail - lsblk -p -o name,type|grep lvm|head -1 - executable: /bin/bash - changed_when: false - register: bigboot_adjacent_lvm - -- name: Set adjacent LVM device name - ansible.builtin.set_fact: - bigboot_adjacent_lvm_device: "{{ bigboot_adjacent_lvm.stdout | regex_replace('.*(/dev.*)\\s+.*$', '\\1') }}" - -- name: Get logical volume mount information - ansible.builtin.set_fact: - bigboot_lv_info: "{{ ansible_facts.mounts \ - | selectattr('device', 'equalto', bigboot_adjacent_lvm_device | trim) | first }}" - -- name: Assert that there is space on the logical volume for shrinkage - ansible.builtin.assert: - that: bigboot_lv_info.size_available > bigboot_expansion_diff | int - fail_msg: There is not enough space available for LV shrinking. - -- name: Capture shrink size for logical volume - ansible.builtin.set_fact: - bigboot_lv_shrink_size: "{{ bigboot_lv_info.size_total - bigboot_expansion_diff | int }}" - -- name: Capture logical volume name - ansible.builtin.shell: - cmd: | - set -o pipefail - lvdisplay {{ bigboot_adjacent_lvm_device }} | grep -i 'vg name' - executable: /bin/bash - changed_when: false - register: bigboot_lv_vg_name - -- name: Format logical volume name - ansible.builtin.set_fact: - bigboot_lv_vg_name: "{{ bigboot_lv_vg_name.stdout | regex_replace('VG\\s+Name\\s+(.*)$', '\\1') }}" - -- name: Capture volume group free PE - ansible.builtin.shell: - cmd: | - set -o pipefail - vgdisplay {{ bigboot_lv_vg_name | trim }} | grep -i 'free' - executable: /bin/bash - changed_when: false - register: bigboot_lv_vg_free_pe - -- name: Format logical volume free PE - ansible.builtin.set_fact: - # Ex: - # Free PE / Size 320 / 1.25 GiB" - # Free PE / Size 189 / 756.00 MiB" - # Free PE / Size 414 / <1.62 GiB - # Free PE / Size 0 / 0 - bigboot_lv_vg_free_pe: "{{ bigboot_lv_vg_free_pe.stdout | regex_replace('^.*/.*/\\s+[<]?(.*)', '\\1') }}" - -- name: Get size in MB for PE and - ansible.builtin.set_fact: - bigboot_lv_pe_size_in_mb: - "{{ bigboot_lv_vg_free_pe | regex_replace('i|\\s+|<', '') | human_to_bytes | human_readable(unit='M') }}" - -- name: Verify if there's available PE or not and execute Shrink_LV - block: - - name: Assert if we need to execute the shrink_lv role to gain free PE - ansible.builtin.assert: - that: (bigboot_lv_pe_size_in_mb[:-3] | int | round) | int > bigboot_size[:-1] | int - fail_msg: Not enough PE to expand /boot. - - rescue: - - name: Set flag to execute shrink_lv - ansible.builtin.set_fact: - bigboot_execute_shrink_lv: true - diff --git a/tasks/bigboot_manage_lv.yml b/tasks/bigboot_manage_lv.yml deleted file mode 100644 index 726b53a..0000000 --- a/tasks/bigboot_manage_lv.yml +++ /dev/null @@ -1,79 +0,0 @@ ---- -- name: Capture logical volume adjacent to /boot - ansible.builtin.shell: - cmd: | - set -o pipefail - lsblk -p -o name,type|grep lvm|head -1 - executable: /bin/bash - changed_when: false - register: bigboot_adjacent_lvm - -- name: Set adjacent LVM device name - ansible.builtin.set_fact: - bigboot_adjacent_lvm_device: "{{ bigboot_adjacent_lvm.stdout | regex_replace('.*(/dev.*)\\s+.*$', '\\1') }}" - -- name: Get logical volume mount information - ansible.builtin.set_fact: - bigboot_lv_info: "{{ ansible_facts.mounts \ - | selectattr('device', 'equalto', bigboot_adjacent_lvm_device | trim) | first }}" - -- name: Assert that there is space on the logical volume for shrinkage - ansible.builtin.assert: - that: bigboot_lv_info.size_available > bigboot_expansion_diff | int - fail_msg: There is not enough space available for LV shrinking. - -- name: Capture shrink size for logical volume - ansible.builtin.set_fact: - bigboot_lv_shrink_size: "{{ bigboot_lv_info.size_total - bigboot_expansion_diff | int }}" - -- name: Capture logical volume name - ansible.builtin.shell: - cmd: | - set -o pipefail - lvdisplay {{ bigboot_adjacent_lvm_device }} | grep -i 'vg name' - executable: /bin/bash - changed_when: false - register: bigboot_lv_vg_name - -- name: Format logical volume name - ansible.builtin.set_fact: - bigboot_lv_vg_name: "{{ bigboot_lv_vg_name.stdout | regex_replace('VG\\s+Name\\s+(.*)$', '\\1') }}" - -- name: Capture volume group free PE - ansible.builtin.shell: - cmd: | - set -o pipefail - vgdisplay {{ bigboot_lv_vg_name | trim }} | grep -i 'free' - executable: /bin/bash - changed_when: false - register: bigboot_lv_vg_free_pe - -- name: Format logical volume free PE - ansible.builtin.set_fact: - # Ex: - # Free PE / Size 320 / 1.25 GiB" - # Free PE / Size 189 / 756.00 MiB" - # Free PE / Size 414 / <1.62 GiB - # Free PE / Size 0 / 0 - bigboot_lv_vg_free_pe: "{{ bigboot_lv_vg_free_pe.stdout | regex_replace('^.*/.*/\\s+[<]?(.*)', '\\1') }}" - -- name: Get size in MB for PE and - ansible.builtin.set_fact: - bigboot_lv_pe_size_in_mb: - "{{ bigboot_lv_vg_free_pe | regex_replace('i|\\s+|<', '') | human_to_bytes | human_readable(unit='M') }}" - -- name: Verify if there's available PE or not and execute Shrink_LV - block: - - name: Assert if we need to execute the shrink_lv role to gain free PE - ansible.builtin.assert: - that: (bigboot_lv_pe_size_in_mb[:-3] | int | round) | int > bigboot_size[:-1] | int - fail_msg: Not enough PE to expand /boot. - - rescue: - - name: Execute Shrink_LV role to resize target logical volume - ansible.builtin.import_role: - name: infra.lvm_snapshots.shrink_lv - vars: - shrink_lv_devices: - - device: "{{ bigboot_adjacent_lvm_device | trim }}" - size: "{{ bigboot_lv_shrink_size | int }}" -- 2.47.1 From c18e018f09c01e09e06dffbba90441c30b38e7f1 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Tue, 26 Mar 2024 16:00:51 -0400 Subject: [PATCH 02/53] fix task name --- bigboot-noop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigboot-noop.yml b/bigboot-noop.yml index 8025113..ed9157b 100644 --- a/bigboot-noop.yml +++ b/bigboot-noop.yml @@ -17,7 +17,7 @@ ansible.builtin.import_tasks: tasks/capture_lv_device_details.yml -- name: Perform a ReaR backup if resizing /boot +- 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 | bool -- 2.47.1 From 251eab291830e18dd726b976fdb6b171af8fd0b7 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Tue, 26 Mar 2024 16:45:35 -0400 Subject: [PATCH 03/53] fix: dont select swap when capturing the adjacent lv --- tasks/capture_lv_device_details.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/capture_lv_device_details.yml b/tasks/capture_lv_device_details.yml index 273e299..11340cf 100644 --- a/tasks/capture_lv_device_details.yml +++ b/tasks/capture_lv_device_details.yml @@ -3,7 +3,7 @@ ansible.builtin.shell: cmd: | set -o pipefail - lsblk -p -o name,type|grep lvm|head -1 + lsblk -p -o name,type | grep -vi swap | grep lvm | head -1 executable: /bin/bash changed_when: false register: bigboot_adjacent_lvm -- 2.47.1 From 6d19ec0fa6a97f8d0973af18df8ce5ea42d3aa5a Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 27 Mar 2024 10:28:04 -0400 Subject: [PATCH 04/53] more fix: dont select swap when capturing the adjacent lv --- bigboot-noop.yml | 2 +- bigboot.yml | 2 +- tasks/capture_lv_device_details.yml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bigboot-noop.yml b/bigboot-noop.yml index ed9157b..2d9c80d 100644 --- a/bigboot-noop.yml +++ b/bigboot-noop.yml @@ -33,7 +33,7 @@ - name: Expand the logical volume to support /boot expansion ansible.builtin.debug: msg: - - "device: {{ bigboot_adjacent_lvm_device | trim }}" + - "device: {{ bigboot_adjacent_lvm_device }}" - "size : {{ bigboot_lv_shrink_size | int }}" when: - bigboot_execute_shrink_lv | bool diff --git a/bigboot.yml b/bigboot.yml index 5b6f12d..79e3085 100644 --- a/bigboot.yml +++ b/bigboot.yml @@ -35,7 +35,7 @@ name: infra.lvm_snapshots.shrink_lv vars: shrink_lv_devices: - - device: "{{ bigboot_adjacent_lvm_device | trim }}" + - device: "{{ bigboot_adjacent_lvm_device }}" size: "{{ bigboot_lv_shrink_size | int }}" when: - bigboot_execute_shrink_lv | bool diff --git a/tasks/capture_lv_device_details.yml b/tasks/capture_lv_device_details.yml index 11340cf..86a01ad 100644 --- a/tasks/capture_lv_device_details.yml +++ b/tasks/capture_lv_device_details.yml @@ -3,19 +3,19 @@ ansible.builtin.shell: cmd: | set -o pipefail - lsblk -p -o name,type | grep -vi swap | grep lvm | head -1 + lsblk -pl -o name,type,mountpoint | grep -vi swap | grep lvm | head -1 | awk '{ print $1}' executable: /bin/bash changed_when: false register: bigboot_adjacent_lvm - name: Set adjacent LVM device name ansible.builtin.set_fact: - bigboot_adjacent_lvm_device: "{{ bigboot_adjacent_lvm.stdout | regex_replace('.*(/dev.*)\\s+.*$', '\\1') }}" + bigboot_adjacent_lvm_device: "{{ bigboot_adjacent_lvm.stdout }}" - name: Get logical volume mount information ansible.builtin.set_fact: bigboot_lv_info: "{{ ansible_facts.mounts \ - | selectattr('device', 'equalto', bigboot_adjacent_lvm_device | trim) | first }}" + | selectattr('device', 'equalto', bigboot_adjacent_lvm_device) | first }}" - name: Assert that there is space on the logical volume for shrinkage ansible.builtin.assert: -- 2.47.1 From 11db88db4c9fa9ce701b54b08fdf3014a56ae6c4 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 26 Apr 2024 14:47:38 -0400 Subject: [PATCH 05/53] breakout into separate playbooks for workflow testing --- bigboot.yml => bigboot_execute_resize.yml | 26 ++---------------- bigboot_rear_backup.yml | 15 +++++++++++ bigboot_setup_environment.yml | 32 +++++++++++++++++++++++ 3 files changed, 49 insertions(+), 24 deletions(-) rename bigboot.yml => bigboot_execute_resize.yml (53%) create mode 100644 bigboot_rear_backup.yml create mode 100644 bigboot_setup_environment.yml diff --git a/bigboot.yml b/bigboot_execute_resize.yml similarity index 53% rename from bigboot.yml rename to bigboot_execute_resize.yml index 79e3085..29ccd95 100644 --- a/bigboot.yml +++ b/bigboot_execute_resize.yml @@ -1,28 +1,4 @@ --- -- name: Capture boot and logical volume information - hosts: all - become: true - gather_facts: true - strategy: free - - vars: - bigboot_size_target: 1G - - - tasks: - - name: Capture boot device details - ansible.builtin.import_tasks: tasks/capture_boot_device_details.yml - - - 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 | bool - - - name: Perform logical volume and boot parition resizing as needed hosts: all become: true @@ -44,3 +20,5 @@ ansible.builtin.import_role: name: infra.lvm_snapshots.bigboot when: bigboot_execute_bigboot | bool + +... diff --git a/bigboot_rear_backup.yml b/bigboot_rear_backup.yml new file mode 100644 index 0000000..f7d5d2c --- /dev/null +++ b/bigboot_rear_backup.yml @@ -0,0 +1,15 @@ +--- +- name: Perform ReaR backup before the /boot expansion + hosts: all + become: true + gather_facts: true + strategy: free + + tasks: + - 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 | bool + - not bigboot_skip_rear_backup | bool + +... diff --git a/bigboot_setup_environment.yml b/bigboot_setup_environment.yml new file mode 100644 index 0000000..4521ce6 --- /dev/null +++ b/bigboot_setup_environment.yml @@ -0,0 +1,32 @@ +--- +- name: Capture boot and logical volume information + hosts: all + become: true + gather_facts: true + strategy: free + + vars: + bigboot_size_target: 1G + ansible_ssh_retries: 10 + + + tasks: + - name: Capture boot device details + ansible.builtin.import_tasks: tasks/capture_boot_device_details.yml + + - name: Capture logical volume information + ansible.builtin.import_tasks: tasks/capture_lv_device_details.yml + + - name: Set environment for subsequent workflow nodes + ansible.builtin.set_stats: + data: + bigboot_execute_bigboot: "{{ bigboot_execute_bigboot }}" + bigboot_execute_shrink_lv: "{{ bigboot_execute_shrink_lv }}" + bigboot_adjacent_lvm_device: "{{ bigboot_adjacent_lvm_device | trim }}" + bigboot_lv_shrink_size: "{{ bigboot_lv_shrink_size | int }}" + bigboot_size: "{{ bigboot_size }}" + bigboot_skip_rear_backup: "{{ bigboot_skip_rear | default('false') }}" + per_host: false + aggregate: false + +... -- 2.47.1 From baa89926c6e535a298a85f84c675526e33d25e38 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 26 Apr 2024 14:59:30 -0400 Subject: [PATCH 06/53] fixes --- bigboot_rear_backup.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/bigboot_rear_backup.yml b/bigboot_rear_backup.yml index f7d5d2c..91413de 100644 --- a/bigboot_rear_backup.yml +++ b/bigboot_rear_backup.yml @@ -1,15 +1,8 @@ --- -- name: Perform ReaR backup before the /boot expansion - hosts: all - become: true - gather_facts: true - strategy: free - - tasks: - - 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 | bool - - not bigboot_skip_rear_backup | bool +- 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 | bool + - not bigboot_skip_rear_backup | bool ... -- 2.47.1 From 9a6ff8ee868e7ea9378a905f92c1060a458f7550 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 26 Apr 2024 15:23:02 -0400 Subject: [PATCH 07/53] add cleanup in the event of execution interruption --- bigboot_setup_environment.yml | 34 +++++++++++++++++++--------------- tasks/cleanup.yml | 31 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 tasks/cleanup.yml diff --git a/bigboot_setup_environment.yml b/bigboot_setup_environment.yml index 4521ce6..1059ca5 100644 --- a/bigboot_setup_environment.yml +++ b/bigboot_setup_environment.yml @@ -7,26 +7,30 @@ vars: bigboot_size_target: 1G + initramfs_backup_extension: old ansible_ssh_retries: 10 tasks: - - name: Capture boot device details - ansible.builtin.import_tasks: tasks/capture_boot_device_details.yml + - name: Cleanup from any previous executions + ansible.builtin.import_tasks: tasks/cleanup.yml - - name: Capture logical volume information - ansible.builtin.import_tasks: tasks/capture_lv_device_details.yml + # - name: Capture boot device details + # ansible.builtin.import_tasks: tasks/capture_boot_device_details.yml - - name: Set environment for subsequent workflow nodes - ansible.builtin.set_stats: - data: - bigboot_execute_bigboot: "{{ bigboot_execute_bigboot }}" - bigboot_execute_shrink_lv: "{{ bigboot_execute_shrink_lv }}" - bigboot_adjacent_lvm_device: "{{ bigboot_adjacent_lvm_device | trim }}" - bigboot_lv_shrink_size: "{{ bigboot_lv_shrink_size | int }}" - bigboot_size: "{{ bigboot_size }}" - bigboot_skip_rear_backup: "{{ bigboot_skip_rear | default('false') }}" - per_host: false - aggregate: false + # - name: Capture logical volume information + # ansible.builtin.import_tasks: tasks/capture_lv_device_details.yml + + # - name: Set environment for subsequent workflow nodes + # ansible.builtin.set_stats: + # data: + # bigboot_execute_bigboot: "{{ bigboot_execute_bigboot }}" + # bigboot_execute_shrink_lv: "{{ bigboot_execute_shrink_lv }}" + # bigboot_adjacent_lvm_device: "{{ bigboot_adjacent_lvm_device | trim }}" + # bigboot_lv_shrink_size: "{{ bigboot_lv_shrink_size | int }}" + # bigboot_size: "{{ bigboot_size }}" + # bigboot_skip_rear_backup: "{{ bigboot_skip_rear | default('false') }}" + # per_host: false + # aggregate: false ... diff --git a/tasks/cleanup.yml b/tasks/cleanup.yml new file mode 100644 index 0000000..fc68848 --- /dev/null +++ b/tasks/cleanup.yml @@ -0,0 +1,31 @@ +--- +- name: Get kernel version + ansible.builtin.set_fact: + initramfs_kernel_version: "{{ ansible_facts.kernel }}" + +- name: Remove dracut extend boot module + ansible.builtin.file: + path: /usr/lib/dracut/modules.d/99extend_boot + state: absent + +- name: Check for initramfs backup file + ansible.builtin.stat: + path: "/boot/initramfs-{{ initramfs_kernel_version }}.img.{{ initramfs_backup_extension }}" + register: bigboot_initramfs_backup_stat + +- name: Restore and remove initramfs backup file + when: bigboot_initramfs_backup_stat['stat']['exists'] | bool + block: + - name: Restore previous initramfs + ansible.builtin.copy: + remote_src: true + src: /boot/initramfs-{{ initramfs_kernel_version }}.img.{{ initramfs_backup_extension }} + dest: /boot/initramfs-{{ initramfs_kernel_version }}.img + mode: "0600" + + - name: Remove initramfs backup file + ansible.builtin.file: + path: /boot/initramfs-{{ initramfs_kernel_version }}.img.{{ initramfs_backup_extension }} + state: absent + +... -- 2.47.1 From 1268170cb1b7a39a614b468aecf30a6baf224710 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 26 Apr 2024 15:24:16 -0400 Subject: [PATCH 08/53] fix code comments --- bigboot_setup_environment.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/bigboot_setup_environment.yml b/bigboot_setup_environment.yml index 1059ca5..919b20a 100644 --- a/bigboot_setup_environment.yml +++ b/bigboot_setup_environment.yml @@ -15,22 +15,22 @@ - name: Cleanup from any previous executions ansible.builtin.import_tasks: tasks/cleanup.yml - # - name: Capture boot device details - # ansible.builtin.import_tasks: tasks/capture_boot_device_details.yml + - name: Capture boot device details + ansible.builtin.import_tasks: tasks/capture_boot_device_details.yml - # - name: Capture logical volume information - # ansible.builtin.import_tasks: tasks/capture_lv_device_details.yml + - name: Capture logical volume information + ansible.builtin.import_tasks: tasks/capture_lv_device_details.yml - # - name: Set environment for subsequent workflow nodes - # ansible.builtin.set_stats: - # data: - # bigboot_execute_bigboot: "{{ bigboot_execute_bigboot }}" - # bigboot_execute_shrink_lv: "{{ bigboot_execute_shrink_lv }}" - # bigboot_adjacent_lvm_device: "{{ bigboot_adjacent_lvm_device | trim }}" - # bigboot_lv_shrink_size: "{{ bigboot_lv_shrink_size | int }}" - # bigboot_size: "{{ bigboot_size }}" - # bigboot_skip_rear_backup: "{{ bigboot_skip_rear | default('false') }}" - # per_host: false - # aggregate: false + - name: Set environment for subsequent workflow nodes + ansible.builtin.set_stats: + data: + bigboot_execute_bigboot: "{{ bigboot_execute_bigboot }}" + bigboot_execute_shrink_lv: "{{ bigboot_execute_shrink_lv }}" + bigboot_adjacent_lvm_device: "{{ bigboot_adjacent_lvm_device | trim }}" + bigboot_lv_shrink_size: "{{ bigboot_lv_shrink_size | int }}" + bigboot_size: "{{ bigboot_size }}" + bigboot_skip_rear_backup: "{{ bigboot_skip_rear | default('false') }}" + per_host: false + aggregate: false ... -- 2.47.1 From 93134954066ac49f43d515d0d6a3883e7c7ac5ee Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 26 Apr 2024 16:40:33 -0400 Subject: [PATCH 09/53] remove extra line break --- bigboot_setup_environment.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/bigboot_setup_environment.yml b/bigboot_setup_environment.yml index 919b20a..eade593 100644 --- a/bigboot_setup_environment.yml +++ b/bigboot_setup_environment.yml @@ -10,7 +10,6 @@ initramfs_backup_extension: old ansible_ssh_retries: 10 - tasks: - name: Cleanup from any previous executions ansible.builtin.import_tasks: tasks/cleanup.yml -- 2.47.1 From 1be095a24b5815ad348cdb0125ca8616a5a814ea Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Tue, 30 Apr 2024 14:57:12 -0400 Subject: [PATCH 10/53] change to bracket notation for kernel version set_fact --- tasks/cleanup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/cleanup.yml b/tasks/cleanup.yml index fc68848..8dce21f 100644 --- a/tasks/cleanup.yml +++ b/tasks/cleanup.yml @@ -1,7 +1,7 @@ --- - name: Get kernel version ansible.builtin.set_fact: - initramfs_kernel_version: "{{ ansible_facts.kernel }}" + initramfs_kernel_version: "{{ ansible_facts['kernel'] }}" - name: Remove dracut extend boot module ansible.builtin.file: -- 2.47.1 From e1e843962393b556073a3040803be99bf871e783 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Tue, 30 Apr 2024 15:21:19 -0400 Subject: [PATCH 11/53] move var and add quotes --- bigboot_setup_environment.yml | 1 - tasks/cleanup.yml | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bigboot_setup_environment.yml b/bigboot_setup_environment.yml index eade593..1c572ab 100644 --- a/bigboot_setup_environment.yml +++ b/bigboot_setup_environment.yml @@ -7,7 +7,6 @@ vars: bigboot_size_target: 1G - initramfs_backup_extension: old ansible_ssh_retries: 10 tasks: diff --git a/tasks/cleanup.yml b/tasks/cleanup.yml index 8dce21f..222f0e0 100644 --- a/tasks/cleanup.yml +++ b/tasks/cleanup.yml @@ -1,7 +1,8 @@ --- -- name: Get kernel version +- name: Set kernel version and backup extension ansible.builtin.set_fact: initramfs_kernel_version: "{{ ansible_facts['kernel'] }}" + initramfs_backup_extension: old - name: Remove dracut extend boot module ansible.builtin.file: @@ -19,13 +20,13 @@ - name: Restore previous initramfs ansible.builtin.copy: remote_src: true - src: /boot/initramfs-{{ initramfs_kernel_version }}.img.{{ initramfs_backup_extension }} - dest: /boot/initramfs-{{ initramfs_kernel_version }}.img + src: "/boot/initramfs-{{ initramfs_kernel_version }}.img.{{ initramfs_backup_extension }}" + dest: "/boot/initramfs-{{ initramfs_kernel_version }}.img" mode: "0600" - name: Remove initramfs backup file ansible.builtin.file: - path: /boot/initramfs-{{ initramfs_kernel_version }}.img.{{ initramfs_backup_extension }} + path: "/boot/initramfs-{{ initramfs_kernel_version }}.img.{{ initramfs_backup_extension }}" state: absent ... -- 2.47.1 From 54a3a107fe8dc95c73e28d02506589620dae7fbc Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 1 May 2024 11:36:39 -0400 Subject: [PATCH 12/53] add timeout change for physical hosts --- bigboot_execute_resize.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index 29ccd95..3d469e2 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -6,6 +6,13 @@ strategy: free tasks: + - name: Re-define timeout values for physical hosts + ansible.builtin.set_fact: + initramfs_post_reboot_delay: 300 + initramfs_reboot_timeout: 14400 + when: + - ansible_virtualization_role is 'host' + - name: Expand the logical volume to support /boot expansion ansible.builtin.import_role: name: infra.lvm_snapshots.shrink_lv -- 2.47.1 From fcba1975e2c0634d1431501044b61ef9c0514c9c Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 1 May 2024 11:46:29 -0400 Subject: [PATCH 13/53] add no_log for debugging --- bigboot_execute_resize.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index 3d469e2..0b64a97 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -10,6 +10,7 @@ ansible.builtin.set_fact: initramfs_post_reboot_delay: 300 initramfs_reboot_timeout: 14400 + no_log: false when: - ansible_virtualization_role is 'host' -- 2.47.1 From b8689a41ecef3aef10e7b6ea609dd84ec43c3ba1 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 1 May 2024 12:00:22 -0400 Subject: [PATCH 14/53] update conditional --- bigboot_execute_resize.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index 0b64a97..dfb4bee 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -12,7 +12,7 @@ initramfs_reboot_timeout: 14400 no_log: false when: - - ansible_virtualization_role is 'host' + - "'host' in ansible_virtualization_role" - name: Expand the logical volume to support /boot expansion ansible.builtin.import_role: -- 2.47.1 From d27d06704cefbdb964e03efcde9c887c47c10b83 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 1 May 2024 12:06:34 -0400 Subject: [PATCH 15/53] update conditional --- bigboot_execute_resize.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index dfb4bee..00637c6 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -12,7 +12,7 @@ initramfs_reboot_timeout: 14400 no_log: false when: - - "'host' in ansible_virtualization_role" + - "'host' not in ansible_virtualization_role" - name: Expand the logical volume to support /boot expansion ansible.builtin.import_role: -- 2.47.1 From 926c0b5c1cc35002e9c5ee7a9d3b1cb4e8e18514 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 1 May 2024 13:46:00 -0400 Subject: [PATCH 16/53] revert conditional --- bigboot_execute_resize.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index 00637c6..dfb4bee 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -12,7 +12,7 @@ initramfs_reboot_timeout: 14400 no_log: false when: - - "'host' not in ansible_virtualization_role" + - "'host' in ansible_virtualization_role" - name: Expand the logical volume to support /boot expansion ansible.builtin.import_role: -- 2.47.1 From ef88bb4ed4ce3ddadf02e67b6c72d89cdcd47242 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 1 May 2024 15:16:28 -0400 Subject: [PATCH 17/53] remove no_log --- bigboot_execute_resize.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index dfb4bee..ebe461a 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -10,7 +10,6 @@ ansible.builtin.set_fact: initramfs_post_reboot_delay: 300 initramfs_reboot_timeout: 14400 - no_log: false when: - "'host' in ansible_virtualization_role" -- 2.47.1 From 28aeaa509567fc47878950f0c2b3cf241d3c8dc1 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 1 May 2024 17:41:58 -0400 Subject: [PATCH 18/53] update task name --- bigboot_execute_resize.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index ebe461a..8e0a996 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -6,7 +6,7 @@ strategy: free tasks: - - name: Re-define timeout values for physical hosts + - name: Extend the timeout values for physical hosts ansible.builtin.set_fact: initramfs_post_reboot_delay: 300 initramfs_reboot_timeout: 14400 -- 2.47.1 From 4fc7500fbf541b42c135a67a33918ce648a711a0 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Tue, 4 Jun 2024 15:15:43 -0400 Subject: [PATCH 19/53] comment out executable param --- tasks/capture_lv_device_details.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/capture_lv_device_details.yml b/tasks/capture_lv_device_details.yml index 86a01ad..3484740 100644 --- a/tasks/capture_lv_device_details.yml +++ b/tasks/capture_lv_device_details.yml @@ -4,7 +4,7 @@ cmd: | set -o pipefail lsblk -pl -o name,type,mountpoint | grep -vi swap | grep lvm | head -1 | awk '{ print $1}' - executable: /bin/bash + # executable: /bin/bash changed_when: false register: bigboot_adjacent_lvm -- 2.47.1 From 813d6dbae572490087b2e8e00fbeebc1ff436452 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Tue, 4 Jun 2024 15:19:37 -0400 Subject: [PATCH 20/53] restore executable param --- tasks/capture_lv_device_details.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/capture_lv_device_details.yml b/tasks/capture_lv_device_details.yml index 3484740..86a01ad 100644 --- a/tasks/capture_lv_device_details.yml +++ b/tasks/capture_lv_device_details.yml @@ -4,7 +4,7 @@ cmd: | set -o pipefail lsblk -pl -o name,type,mountpoint | grep -vi swap | grep lvm | head -1 | awk '{ print $1}' - # executable: /bin/bash + executable: /bin/bash changed_when: false register: bigboot_adjacent_lvm -- 2.47.1 From 235049b91e78277b186fe8a90b097bcf4d5f43b5 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 5 Jun 2024 13:54:01 -0400 Subject: [PATCH 21/53] add boot drive to lsblk command to better select adjacent lvm device --- .ansible-lint | 1 + preflight.yml | 123 ++++++++++++++++++++++++++++ tasks/capture_lv_device_details.yml | 3 +- 3 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 preflight.yml diff --git a/.ansible-lint b/.ansible-lint index c907879..d8dc293 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -4,3 +4,4 @@ skip_list: - yaml[line-length] - no-changed-when - run-once[play] + - name[template] diff --git a/preflight.yml b/preflight.yml new file mode 100644 index 0000000..58382d3 --- /dev/null +++ b/preflight.yml @@ -0,0 +1,123 @@ +--- +- name: Create VG and LVOL for shrink_lv testing + hosts: all + become: true + gather_facts: true + + + vars: + __part_size: 20GB + __partition_devices: + - /dev/vdb + - /dev/vdc + - /dev/vdd + - /dev/vde + - /dev/vdf + - /dev/vdg + - /dev/vdh + - /dev/vdi + - /dev/vdj + - /dev/vdk + - /dev/vdl + - /dev/vdm + - /dev/vdn + - /dev/vdo + - /dev/vdp + - /dev/sdb + - /dev/sdc + - /dev/sdd + - /dev/sde + - /dev/sdf + - /dev/sdg + - /dev/sdh + - /dev/sdi + - /dev/sdj + - /dev/sdk + - /dev/sdl + - /dev/sdm + - /dev/sdn + - /dev/sdo + - /dev/sdp + + __vg_name : test-vg + __lv_name : test-lv + __lv_size : 18g + __lv_mount : "/data/{{ __lv_name }}" + __lv_fstype : ext4 + + + tasks: + - name: Debug __partition_devices + ansible.builtin.debug: + msg: + - "{{ __partition_devices }}" + - "{{ __partition_devices | join(',') }}" + - "{{ __partition_devices | \ + map('regex_replace', '(?Psd.*)', '\\g' + '1', multiline=True) }}" + verbosity: 1 + + + - name: Install LVM2 + ansible.builtin.package: + name : lvm2 + state : present + + + - name: Debug __partition_devices + ansible.builtin.debug: + msg: "{{ item }}1 :: {{ item | split('/') | last }}" + verbosity: 1 + loop: "{{ __partition_devices }}" + + + - name: Create partitions on all drives + community.general.parted: + device : "{{ item }}" + number : 1 + flags : ['lvm'] + state : present + part_end : "{{ __part_size }}" + loop: "{{ __partition_devices }}" + + + - name: Create VGs on LVM devices + community.general.lvg: + vg : "{{ __vg_name }}-{{ item | split('/') | last }}" + pvs : "{{ item }}1" + loop: "{{ __partition_devices }}" + + + - name: Create LV + community.general.lvol: + vg : "{{ __vg_name }}-{{ item | split('/') | last }}" + lv : "{{ __lv_name }}-{{ item | split('/') | last }}" + size : "{{ __lv_size }}" + force : true + loop: "{{ __partition_devices }}" + + + - name: Create lvol mount point + ansible.builtin.file: + path : "{{ __lv_mount }}-{{ item | split('/') | last }}" + state : directory + mode : "0755" + loop: "{{ __partition_devices }}" + + + - name: Create filesystems + community.general.filesystem: + dev : "/dev/{{ __vg_name }}-{{ item | split('/') | last }}/{{ __lv_name }}-{{ item | split('/') | last }}" + fstype : "{{ __lv_fstype }}" + loop: "{{ __partition_devices }}" + + + - name: Mount data + ansible.posix.mount: + path : "{{ __lv_mount }}-{{ item | split('/') | last }}" + src : "/dev/{{ __vg_name }}-{{ item | split('/') | last }}/{{ __lv_name }}-{{ item | split('/') | last }}" + fstype : "{{ __lv_fstype }}" + state : mounted + loop: "{{ __partition_devices }}" + + +... diff --git a/tasks/capture_lv_device_details.yml b/tasks/capture_lv_device_details.yml index 86a01ad..09128bb 100644 --- a/tasks/capture_lv_device_details.yml +++ b/tasks/capture_lv_device_details.yml @@ -3,7 +3,8 @@ ansible.builtin.shell: cmd: | set -o pipefail - lsblk -pl -o name,type,mountpoint | grep -vi swap | grep lvm | head -1 | awk '{ print $1}' + lsblk -pl -o name,type,mountpoint {{ bigboot_boot_mount['device'][:-1] }} \ + | grep -vi swap | grep lvm | head -1 | awk '{ print $1}' executable: /bin/bash changed_when: false register: bigboot_adjacent_lvm -- 2.47.1 From 72c47a2483a104b45779ff0ddcc8c61b46d722ac Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Thu, 6 Jun 2024 00:33:46 -0400 Subject: [PATCH 22/53] update preflight.yml to be better --- preflight.yml | 74 +++++--------------------------------- tasks/create_lvm_setup.yml | 47 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 66 deletions(-) create mode 100644 tasks/create_lvm_setup.yml diff --git a/preflight.yml b/preflight.yml index 58382d3..a317012 100644 --- a/preflight.yml +++ b/preflight.yml @@ -4,9 +4,13 @@ become: true gather_facts: true - vars: - __part_size: 20GB + __vg_name : test-vg + __lv_name : test-lv + __lv_size : 18g + __lv_mount : "/data/{{ __lv_name }}" + __lv_fstype : ext4 + __part_size : 20GB __partition_devices: - /dev/vdb - /dev/vdc @@ -39,13 +43,6 @@ - /dev/sdo - /dev/sdp - __vg_name : test-vg - __lv_name : test-lv - __lv_size : 18g - __lv_mount : "/data/{{ __lv_name }}" - __lv_fstype : ext4 - - tasks: - name: Debug __partition_devices ansible.builtin.debug: @@ -56,68 +53,13 @@ map('regex_replace', '(?Psd.*)', '\\g' + '1', multiline=True) }}" verbosity: 1 - - name: Install LVM2 ansible.builtin.package: name : lvm2 state : present - - - name: Debug __partition_devices - ansible.builtin.debug: - msg: "{{ item }}1 :: {{ item | split('/') | last }}" - verbosity: 1 + - name: Include LVM setup creation tasks + ansible.builtin.include_tasks: tasks/create_lvm_setup.yml loop: "{{ __partition_devices }}" - - - name: Create partitions on all drives - community.general.parted: - device : "{{ item }}" - number : 1 - flags : ['lvm'] - state : present - part_end : "{{ __part_size }}" - loop: "{{ __partition_devices }}" - - - - name: Create VGs on LVM devices - community.general.lvg: - vg : "{{ __vg_name }}-{{ item | split('/') | last }}" - pvs : "{{ item }}1" - loop: "{{ __partition_devices }}" - - - - name: Create LV - community.general.lvol: - vg : "{{ __vg_name }}-{{ item | split('/') | last }}" - lv : "{{ __lv_name }}-{{ item | split('/') | last }}" - size : "{{ __lv_size }}" - force : true - loop: "{{ __partition_devices }}" - - - - name: Create lvol mount point - ansible.builtin.file: - path : "{{ __lv_mount }}-{{ item | split('/') | last }}" - state : directory - mode : "0755" - loop: "{{ __partition_devices }}" - - - - name: Create filesystems - community.general.filesystem: - dev : "/dev/{{ __vg_name }}-{{ item | split('/') | last }}/{{ __lv_name }}-{{ item | split('/') | last }}" - fstype : "{{ __lv_fstype }}" - loop: "{{ __partition_devices }}" - - - - name: Mount data - ansible.posix.mount: - path : "{{ __lv_mount }}-{{ item | split('/') | last }}" - src : "/dev/{{ __vg_name }}-{{ item | split('/') | last }}/{{ __lv_name }}-{{ item | split('/') | last }}" - fstype : "{{ __lv_fstype }}" - state : mounted - loop: "{{ __partition_devices }}" - - ... diff --git a/tasks/create_lvm_setup.yml b/tasks/create_lvm_setup.yml new file mode 100644 index 0000000..71cea8c --- /dev/null +++ b/tasks/create_lvm_setup.yml @@ -0,0 +1,47 @@ +--- +- name: Debug __partition_devices + ansible.builtin.debug: + msg: "{{ item }}1 :: {{ item | split('/') | last }}" + verbosity: 1 + +- name: Creating layout for {{ item }} + ansible.builtin.debug: + msg: "Setting up LVM PV/VG/LVol for {{ item }}..." + +- name: Create partitions on all drives + community.general.parted: + device : "{{ item }}" + number : 1 + flags : ['lvm'] + state : present + part_end : "{{ __part_size }}" + +- name: Create VGs on LVM devices + community.general.lvg: + vg : "{{ __vg_name }}-{{ item | split('/') | last }}" + pvs : "{{ item }}1" + +- name: Create LV + community.general.lvol: + vg : "{{ __vg_name }}-{{ item | split('/') | last }}" + lv : "{{ __lv_name }}-{{ item | split('/') | last }}" + size : "{{ __lv_size }}" + force : true + +- name: Create lvol mount point + ansible.builtin.file: + path : "{{ __lv_mount }}-{{ item | split('/') | last }}" + state : directory + mode : "0755" + +- name: Create filesystems + community.general.filesystem: + dev : "/dev/{{ __vg_name }}-{{ item | split('/') | last }}/{{ __lv_name }}-{{ item | split('/') | last }}" + fstype : "{{ __lv_fstype }}" + +- name: Mount data + ansible.posix.mount: + path : "{{ __lv_mount }}-{{ item | split('/') | last }}" + src : "/dev/{{ __vg_name }}-{{ item | split('/') | last }}/{{ __lv_name }}-{{ item | split('/') | last }}" + fstype : "{{ __lv_fstype }}" + state : mounted -- 2.47.1 From fa1676652c919660f826eee070e7e30759d142dc Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Thu, 6 Jun 2024 14:37:46 -0400 Subject: [PATCH 23/53] remove trim --- bigboot_setup_environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigboot_setup_environment.yml b/bigboot_setup_environment.yml index 1c572ab..af7e5dd 100644 --- a/bigboot_setup_environment.yml +++ b/bigboot_setup_environment.yml @@ -24,7 +24,7 @@ data: bigboot_execute_bigboot: "{{ bigboot_execute_bigboot }}" bigboot_execute_shrink_lv: "{{ bigboot_execute_shrink_lv }}" - bigboot_adjacent_lvm_device: "{{ bigboot_adjacent_lvm_device | trim }}" + 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') }}" -- 2.47.1 From 74f123adc7707e178efa1f11b6a0c67a6a774d25 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Thu, 6 Jun 2024 14:40:45 -0400 Subject: [PATCH 24/53] the bob fix --- tasks/capture_lv_device_details.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/capture_lv_device_details.yml b/tasks/capture_lv_device_details.yml index 09128bb..dc89d5a 100644 --- a/tasks/capture_lv_device_details.yml +++ b/tasks/capture_lv_device_details.yml @@ -8,6 +8,7 @@ executable: /bin/bash changed_when: false register: bigboot_adjacent_lvm + failed_when: bigboot_adjacent_lvm.rc not in [0,141] - name: Set adjacent LVM device name ansible.builtin.set_fact: -- 2.47.1 From ccc0584c951b3740a8c444eee65a1c5e97ebf36c Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Thu, 6 Jun 2024 14:44:12 -0400 Subject: [PATCH 25/53] the bob fix pt2 --- tasks/capture_lv_device_details.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/capture_lv_device_details.yml b/tasks/capture_lv_device_details.yml index dc89d5a..2207983 100644 --- a/tasks/capture_lv_device_details.yml +++ b/tasks/capture_lv_device_details.yml @@ -8,7 +8,7 @@ executable: /bin/bash changed_when: false register: bigboot_adjacent_lvm - failed_when: bigboot_adjacent_lvm.rc not in [0,141] + failed_when: bigboot_adjacent_lvm['rc'] not in [0,141] - name: Set adjacent LVM device name ansible.builtin.set_fact: -- 2.47.1 From 23ced84443364304bb1f00b610fa036dfdc9fc61 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Thu, 13 Jun 2024 13:40:29 -0400 Subject: [PATCH 26/53] updates to preflight.yml for new test vm --- preflight.yml | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/preflight.yml b/preflight.yml index a317012..326c41b 100644 --- a/preflight.yml +++ b/preflight.yml @@ -12,21 +12,6 @@ __lv_fstype : ext4 __part_size : 20GB __partition_devices: - - /dev/vdb - - /dev/vdc - - /dev/vdd - - /dev/vde - - /dev/vdf - - /dev/vdg - - /dev/vdh - - /dev/vdi - - /dev/vdj - - /dev/vdk - - /dev/vdl - - /dev/vdm - - /dev/vdn - - /dev/vdo - - /dev/vdp - /dev/sdb - /dev/sdc - /dev/sdd @@ -42,6 +27,36 @@ - /dev/sdn - /dev/sdo - /dev/sdp + - /dev/sdq + - /dev/sdr + - /dev/sds + - /dev/sdt + - /dev/sdu + - /dev/sdv + - /dev/sdw + - /dev/sdx + - /dev/sdy + - /dev/sdz + - /dev/vda + - /dev/vdb + - /dev/vdc + - /dev/vdd + - /dev/vde + - /dev/vdf + - /dev/vdg + - /dev/vdh + - /dev/vdi + - /dev/vdj + - /dev/vdk + - /dev/vdl + - /dev/vdm + - /dev/vdn + - /dev/vdo + - /dev/sdaa + - /dev/sdab + - /dev/sdac + - /dev/sdad + - /dev/sdae tasks: - name: Debug __partition_devices -- 2.47.1 From fe354b45bcc4c612d2e15b8d5581060fe3c4697c Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Fri, 14 Jun 2024 17:52:49 -0400 Subject: [PATCH 27/53] add fix for logical volume selection and a couple of typo fixes --- bigboot-noop.yml | 2 +- bigboot_execute_resize.yml | 2 +- tasks/capture_lv_device_details.yml | 24 +++++++++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/bigboot-noop.yml b/bigboot-noop.yml index 2d9c80d..846f472 100644 --- a/bigboot-noop.yml +++ b/bigboot-noop.yml @@ -30,7 +30,7 @@ strategy: free tasks: - - name: Expand the logical volume to support /boot expansion + - name: Shrink the logical volume to support /boot expansion ansible.builtin.debug: msg: - "device: {{ bigboot_adjacent_lvm_device }}" diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index 8e0a996..1178ca0 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -13,7 +13,7 @@ when: - "'host' in ansible_virtualization_role" - - name: Expand the logical volume to support /boot expansion + - name: Shrink the logical volume to support /boot expansion ansible.builtin.import_role: name: infra.lvm_snapshots.shrink_lv vars: diff --git a/tasks/capture_lv_device_details.yml b/tasks/capture_lv_device_details.yml index 2207983..d8854dd 100644 --- a/tasks/capture_lv_device_details.yml +++ b/tasks/capture_lv_device_details.yml @@ -1,18 +1,32 @@ --- -- name: Capture logical volume adjacent to /boot +- name: Capture all logical volume paritions on /boot device ansible.builtin.shell: cmd: | set -o pipefail - lsblk -pl -o name,type,mountpoint {{ bigboot_boot_mount['device'][:-1] }} \ - | grep -vi swap | grep lvm | head -1 | awk '{ print $1}' + lsblk -pl -o name,type {{ bigboot_boot_mount['device'][:-1] }} | grep -i lvm executable: /bin/bash changed_when: false + failed_when: bigboot_adjacent_lvm['rc'] not in [0, 141] register: bigboot_adjacent_lvm - failed_when: bigboot_adjacent_lvm['rc'] not in [0,141] + +- name: Map the device to its mount point if applicable + ansible.builtin.set_fact: + bigboot_adjacent_lvm_devices: "{{ bigboot_adjacent_lvm_devices | default([]) | combine({item | split(' ') | first: ansible_facts['mounts'] | selectattr('device', 'equalto', item | split(' ') | first) | map(attribute='mount')}) }}" + loop: "{{ bigboot_adjacent_lvm['stdout_lines'] }}" + +- name: Capture the device name of the mounted logical volumes + ansible.builtin.set_fact: + bigboot_lvm_mounts: "{{ bigboot_lvm_mounts | default([]) + [item['key']] }}" + loop: "{{ bigboot_adjacent_lvm_devices | dict2items }}" + when: item['value'] | regex_search("[a-zA-Z]") - name: Set adjacent LVM device name ansible.builtin.set_fact: - bigboot_adjacent_lvm_device: "{{ bigboot_adjacent_lvm.stdout }}" + bigboot_adjacent_lvm_device: "{{ bigboot_lvm_mounts | first }}" + +- name: Debug bigboot_adjacent_lvm_device + ansible.builtin.debug: + var: bigboot_adjacent_lvm_device - name: Get logical volume mount information ansible.builtin.set_fact: -- 2.47.1 From 806293ac1abfd7e203ae2acb22dde76f9cd3a480 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Mon, 17 Jun 2024 13:42:25 -0400 Subject: [PATCH 28/53] split line up --- tasks/capture_lv_device_details.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tasks/capture_lv_device_details.yml b/tasks/capture_lv_device_details.yml index d8854dd..1f26c1b 100644 --- a/tasks/capture_lv_device_details.yml +++ b/tasks/capture_lv_device_details.yml @@ -10,8 +10,11 @@ register: bigboot_adjacent_lvm - name: Map the device to its mount point if applicable - ansible.builtin.set_fact: - bigboot_adjacent_lvm_devices: "{{ bigboot_adjacent_lvm_devices | default([]) | combine({item | split(' ') | first: ansible_facts['mounts'] | selectattr('device', 'equalto', item | split(' ') | first) | map(attribute='mount')}) }}" + ansible.builtin.set_fact: > + bigboot_adjacent_lvm_devices: "{{ bigboot_adjacent_lvm_devices | default([]) + | combine({item | split(' ') | first: ansible_facts['mounts'] + | selectattr('device', 'equalto', item | split(' ') | first) + | map(attribute='mount')}) }}" loop: "{{ bigboot_adjacent_lvm['stdout_lines'] }}" - name: Capture the device name of the mounted logical volumes -- 2.47.1 From 8363d9ae1580d839bcde4562e9878989c7df18b8 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Mon, 17 Jun 2024 14:00:07 -0400 Subject: [PATCH 29/53] fixes --- tasks/capture_lv_device_details.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tasks/capture_lv_device_details.yml b/tasks/capture_lv_device_details.yml index 1f26c1b..2c0b752 100644 --- a/tasks/capture_lv_device_details.yml +++ b/tasks/capture_lv_device_details.yml @@ -10,11 +10,11 @@ register: bigboot_adjacent_lvm - name: Map the device to its mount point if applicable - ansible.builtin.set_fact: > - bigboot_adjacent_lvm_devices: "{{ bigboot_adjacent_lvm_devices | default([]) - | combine({item | split(' ') | first: ansible_facts['mounts'] - | selectattr('device', 'equalto', item | split(' ') | first) - | map(attribute='mount')}) }}" + ansible.builtin.set_fact: + bigboot_adjacent_lvm_devices: "{{ bigboot_adjacent_lvm_devices | default([]) \ + | combine({item | split(' ') | first: ansible_facts['mounts'] \ + | selectattr('device', 'equalto', item | split(' ') | first) \ + | map(attribute='mount')}) }}" loop: "{{ bigboot_adjacent_lvm['stdout_lines'] }}" - name: Capture the device name of the mounted logical volumes -- 2.47.1 From db967f6aefec99b0f9ac5fe83ed2857089d37dbc Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Tue, 18 Jun 2024 09:52:35 -0400 Subject: [PATCH 30/53] regex fix to include root partition --- tasks/capture_lv_device_details.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tasks/capture_lv_device_details.yml b/tasks/capture_lv_device_details.yml index 2c0b752..05d8429 100644 --- a/tasks/capture_lv_device_details.yml +++ b/tasks/capture_lv_device_details.yml @@ -21,7 +21,12 @@ ansible.builtin.set_fact: bigboot_lvm_mounts: "{{ bigboot_lvm_mounts | default([]) + [item['key']] }}" loop: "{{ bigboot_adjacent_lvm_devices | dict2items }}" - when: item['value'] | regex_search("[a-zA-Z]") + when: item['value'] | regex_search('^/[a-zA-Z]') + +- name: Debug bigboot_lvm_mounts + ansible.builtin.debug: + var: bigboot_lvm_mounts + verbosity: 1 - name: Set adjacent LVM device name ansible.builtin.set_fact: @@ -30,6 +35,7 @@ - name: Debug bigboot_adjacent_lvm_device ansible.builtin.debug: var: bigboot_adjacent_lvm_device + verbosity: 1 - name: Get logical volume mount information ansible.builtin.set_fact: -- 2.47.1 From 9fd528068372be8428489efb099899bf68e0b814 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Tue, 18 Jun 2024 15:52:31 -0400 Subject: [PATCH 31/53] regex fix --- tasks/capture_lv_device_details.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/capture_lv_device_details.yml b/tasks/capture_lv_device_details.yml index 05d8429..cca14c0 100644 --- a/tasks/capture_lv_device_details.yml +++ b/tasks/capture_lv_device_details.yml @@ -21,7 +21,7 @@ ansible.builtin.set_fact: bigboot_lvm_mounts: "{{ bigboot_lvm_mounts | default([]) + [item['key']] }}" loop: "{{ bigboot_adjacent_lvm_devices | dict2items }}" - when: item['value'] | regex_search('^/[a-zA-Z]') + when: item['value'] | regex_search('[/a-zA-Z]') - name: Debug bigboot_lvm_mounts ansible.builtin.debug: -- 2.47.1 From c321faf4c511690e853aad2bf2c6636c0e0286c0 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Mon, 1 Jul 2024 15:04:15 -0400 Subject: [PATCH 32/53] add autofsck role --- bigboot_execute_resize.yml | 17 ++++++++++++++++- requirements.yml | 6 ++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index 1178ca0..e162d44 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -6,6 +6,13 @@ strategy: free tasks: + - name: Run a filesystem check prior to performing disk activities + ansible.builtin.import_role: + name: autofsck + tasks_from: main.yml + when: + - (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool) + - name: Extend the timeout values for physical hosts ansible.builtin.set_fact: initramfs_post_reboot_delay: 300 @@ -26,6 +33,14 @@ - name: Expand the /boot partition as requested ansible.builtin.import_role: name: infra.lvm_snapshots.bigboot - when: bigboot_execute_bigboot | bool + when: + - 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) ... diff --git a/requirements.yml b/requirements.yml index 1f04f19..3ae931e 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,4 +1,10 @@ --- +roles: + - name: autofsck + src: gitea@gitea.thezengarden.net:ansible_roles/autofsck.git + scm: git + version: main + collections: # - name: infra.lvm_snapshots.shrink_lv # source: https://github.com/redhat-cop/infra.lvm_snapshots.git -- 2.47.1 From c10f29eefda741e2bbebce8bf2ad9f7bc94249b0 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Mon, 1 Jul 2024 16:50:28 -0400 Subject: [PATCH 33/53] update bigboot-noop.yml to bring it up to speed --- bigboot-noop.yml | 38 ++++++++++++++++- roles/autofsck/handlers/main.yml | 6 +++ roles/autofsck/meta/.galaxy_install_info | 2 + roles/autofsck/meta/main.yml | 52 ++++++++++++++++++++++++ roles/autofsck/tasks/cleanup.yml | 7 ++++ roles/autofsck/tasks/main.yml | 10 +++++ 6 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 roles/autofsck/handlers/main.yml create mode 100644 roles/autofsck/meta/.galaxy_install_info create mode 100644 roles/autofsck/meta/main.yml create mode 100644 roles/autofsck/tasks/cleanup.yml create mode 100644 roles/autofsck/tasks/main.yml diff --git a/bigboot-noop.yml b/bigboot-noop.yml index 846f472..a03d90e 100644 --- a/bigboot-noop.yml +++ b/bigboot-noop.yml @@ -10,6 +10,9 @@ tasks: + - name: Cleanup from any previous executions + ansible.builtin.import_tasks: tasks/cleanup.yml + - name: Capture boot device details ansible.builtin.import_tasks: tasks/capture_boot_device_details.yml @@ -30,6 +33,20 @@ strategy: free tasks: + - name: Run a filesystem check prior to performing disk activities + ansible.builtin.import_role: + name: autofsck + tasks_from: main.yml + when: + - (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool) + + - 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: @@ -41,4 +58,23 @@ - name: Expand the /boot partition as requested ansible.builtin.debug: msg: "{{ bigboot_size }}" - when: bigboot_execute_bigboot | bool + when: + - bigboot_execute_bigboot | bool + + - 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) + +... diff --git a/roles/autofsck/handlers/main.yml b/roles/autofsck/handlers/main.yml new file mode 100644 index 0000000..4771b80 --- /dev/null +++ b/roles/autofsck/handlers/main.yml @@ -0,0 +1,6 @@ +--- +- name: Update_Grub + ansible.builtin.command: + cmd: /usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg + register: autofsck_grub_mkconfig + changed_when: '"done" in autofsck_grub_mkconfig.stdout' diff --git a/roles/autofsck/meta/.galaxy_install_info b/roles/autofsck/meta/.galaxy_install_info new file mode 100644 index 0000000..d16f37f --- /dev/null +++ b/roles/autofsck/meta/.galaxy_install_info @@ -0,0 +1,2 @@ +install_date: 'Mon 01 Jul 2024 07:11:13 PM ' +version: main diff --git a/roles/autofsck/meta/main.yml b/roles/autofsck/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/autofsck/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/roles/autofsck/tasks/cleanup.yml b/roles/autofsck/tasks/cleanup.yml new file mode 100644 index 0000000..45527ec --- /dev/null +++ b/roles/autofsck/tasks/cleanup.yml @@ -0,0 +1,7 @@ +--- +- name: Cleanup /etc/default/grub to remove fsck + ansible.builtin.replace: + path: /etc/default/grub + regexp: '(GRUB_CMDLINE_LINUX=".*)\s+(fsck\.mode=force)\s+(fsck.repair=yes)(.*")' + replace: '\1\4' + notify: Update_Grub diff --git a/roles/autofsck/tasks/main.yml b/roles/autofsck/tasks/main.yml new file mode 100644 index 0000000..5aafc17 --- /dev/null +++ b/roles/autofsck/tasks/main.yml @@ -0,0 +1,10 @@ +--- +- name: Configure /etc/default/grub for fsck + ansible.builtin.lineinfile: + state: present + dest: /etc/default/grub + backrefs: true + regexp: '^(GRUB_CMDLINE_LINUX=(?!.* fsck)\"[^\"]+)(\".*)' + line: '\1 fsck.mode=force fsck.repair=yes\2' + backup: true + notify: Update_Grub -- 2.47.1 From 2e54dd73576971179271a1c7502d5ffd7173853a Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Mon, 1 Jul 2024 17:02:14 -0400 Subject: [PATCH 34/53] remove roles --- roles/autofsck/handlers/main.yml | 6 --- roles/autofsck/meta/.galaxy_install_info | 2 - roles/autofsck/meta/main.yml | 52 ------------------------ roles/autofsck/tasks/cleanup.yml | 7 ---- roles/autofsck/tasks/main.yml | 10 ----- 5 files changed, 77 deletions(-) delete mode 100644 roles/autofsck/handlers/main.yml delete mode 100644 roles/autofsck/meta/.galaxy_install_info delete mode 100644 roles/autofsck/meta/main.yml delete mode 100644 roles/autofsck/tasks/cleanup.yml delete mode 100644 roles/autofsck/tasks/main.yml diff --git a/roles/autofsck/handlers/main.yml b/roles/autofsck/handlers/main.yml deleted file mode 100644 index 4771b80..0000000 --- a/roles/autofsck/handlers/main.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- name: Update_Grub - ansible.builtin.command: - cmd: /usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg - register: autofsck_grub_mkconfig - changed_when: '"done" in autofsck_grub_mkconfig.stdout' diff --git a/roles/autofsck/meta/.galaxy_install_info b/roles/autofsck/meta/.galaxy_install_info deleted file mode 100644 index d16f37f..0000000 --- a/roles/autofsck/meta/.galaxy_install_info +++ /dev/null @@ -1,2 +0,0 @@ -install_date: 'Mon 01 Jul 2024 07:11:13 PM ' -version: main diff --git a/roles/autofsck/meta/main.yml b/roles/autofsck/meta/main.yml deleted file mode 100644 index c572acc..0000000 --- a/roles/autofsck/meta/main.yml +++ /dev/null @@ -1,52 +0,0 @@ -galaxy_info: - author: your name - description: your role description - company: your company (optional) - - # If the issue tracker for your role is not on github, uncomment the - # next line and provide a value - # issue_tracker_url: http://example.com/issue/tracker - - # Choose a valid license ID from https://spdx.org - some suggested licenses: - # - BSD-3-Clause (default) - # - MIT - # - GPL-2.0-or-later - # - GPL-3.0-only - # - Apache-2.0 - # - CC-BY-4.0 - license: license (GPL-2.0-or-later, MIT, etc) - - min_ansible_version: 2.1 - - # If this a Container Enabled role, provide the minimum Ansible Container version. - # min_ansible_container_version: - - # - # Provide a list of supported platforms, and for each platform a list of versions. - # If you don't wish to enumerate all versions for a particular platform, use 'all'. - # To view available platforms and versions (or releases), visit: - # https://galaxy.ansible.com/api/v1/platforms/ - # - # platforms: - # - name: Fedora - # versions: - # - all - # - 25 - # - name: SomePlatform - # versions: - # - all - # - 1.0 - # - 7 - # - 99.99 - - galaxy_tags: [] - # List tags for your role here, one per line. A tag is a keyword that describes - # and categorizes the role. Users find roles by searching for tags. Be sure to - # remove the '[]' above, if you add tags to this list. - # - # NOTE: A tag is limited to a single word comprised of alphanumeric characters. - # Maximum 20 tags per role. - -dependencies: [] - # List your role dependencies here, one per line. Be sure to remove the '[]' above, - # if you add dependencies to this list. diff --git a/roles/autofsck/tasks/cleanup.yml b/roles/autofsck/tasks/cleanup.yml deleted file mode 100644 index 45527ec..0000000 --- a/roles/autofsck/tasks/cleanup.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Cleanup /etc/default/grub to remove fsck - ansible.builtin.replace: - path: /etc/default/grub - regexp: '(GRUB_CMDLINE_LINUX=".*)\s+(fsck\.mode=force)\s+(fsck.repair=yes)(.*")' - replace: '\1\4' - notify: Update_Grub diff --git a/roles/autofsck/tasks/main.yml b/roles/autofsck/tasks/main.yml deleted file mode 100644 index 5aafc17..0000000 --- a/roles/autofsck/tasks/main.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: Configure /etc/default/grub for fsck - ansible.builtin.lineinfile: - state: present - dest: /etc/default/grub - backrefs: true - regexp: '^(GRUB_CMDLINE_LINUX=(?!.* fsck)\"[^\"]+)(\".*)' - line: '\1 fsck.mode=force fsck.repair=yes\2' - backup: true - notify: Update_Grub -- 2.47.1 From b48ef5e2ec0ff210db682346368ecae155acd872 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Mon, 1 Jul 2024 17:02:42 -0400 Subject: [PATCH 35/53] update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index bc92616..8cd27c8 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ filter_plugins/__pycache__ filter_plugins/*.bak python/ collections/ansible_collections +roles/ -- 2.47.1 From e04e64f5d66c407e499541c9ef8f7c838df7a5e1 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Mon, 1 Jul 2024 17:08:19 -0400 Subject: [PATCH 36/53] update requirements.yml --- requirements.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.yml b/requirements.yml index 3ae931e..9a4c623 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,7 +1,7 @@ --- roles: - name: autofsck - src: gitea@gitea.thezengarden.net:ansible_roles/autofsck.git + src: https://gitea.thezengarden.net/ansible_roles/autofsck.git scm: git version: main -- 2.47.1 From 260532fb3c6fbd4183f0be28a71eb98c6f1456cf Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Mon, 1 Jul 2024 17:16:44 -0400 Subject: [PATCH 37/53] update stuff --- .gitignore | 2 +- bigboot-noop.yml | 2 ++ roles/requirements.yml | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 roles/requirements.yml diff --git a/.gitignore b/.gitignore index 8cd27c8..6be675f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ filter_plugins/__pycache__ filter_plugins/*.bak python/ collections/ansible_collections -roles/ +roles/autofsck diff --git a/bigboot-noop.yml b/bigboot-noop.yml index a03d90e..f3c9fda 100644 --- a/bigboot-noop.yml +++ b/bigboot-noop.yml @@ -61,6 +61,8 @@ 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 diff --git a/roles/requirements.yml b/roles/requirements.yml new file mode 100644 index 0000000..d9358be --- /dev/null +++ b/roles/requirements.yml @@ -0,0 +1,5 @@ +--- +- name: autofsck + src: https://gitea.thezengarden.net/ansible_roles/autofsck.git + scm: git + version: main -- 2.47.1 From cced58c1b7b71aebddfca973f7caecd5a74c5eea Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Mon, 1 Jul 2024 17:26:58 -0400 Subject: [PATCH 38/53] add flush_handlers --- bigboot-noop.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bigboot-noop.yml b/bigboot-noop.yml index f3c9fda..aabe53c 100644 --- a/bigboot-noop.yml +++ b/bigboot-noop.yml @@ -33,13 +33,16 @@ strategy: free tasks: - - name: Run a filesystem check prior to performing disk activities + - name: Add Grub menu parameters for fsck ansible.builtin.import_role: name: autofsck tasks_from: main.yml when: - (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool) + - 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 -- 2.47.1 From 83c97fe5b4d44018d9c1e1c716bf28efc369b8d3 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Mon, 1 Jul 2024 19:41:29 -0400 Subject: [PATCH 39/53] task re-naming and flush_handlers --- bigboot_execute_resize.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index e162d44..aaaa05d 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -6,13 +6,16 @@ strategy: free tasks: - - name: Run a filesystem check prior to performing disk activities + - name: Enable filesystem check prior to performing disk activities ansible.builtin.import_role: name: autofsck tasks_from: main.yml when: - (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool) + - 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 @@ -36,7 +39,7 @@ when: - bigboot_execute_bigboot | bool - - name: Cleanup Grub menu parameters for fsck + - name: Remove filesystem check from Grub ansible.builtin.import_role: name: autofsck tasks_from: cleanup.yml -- 2.47.1 From 9a2e80150f0024b9a86c631acd7274d8b1a7a0af Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Tue, 2 Jul 2024 23:00:31 -0400 Subject: [PATCH 40/53] comment out fsck to verify if working or not --- bigboot_execute_resize.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index aaaa05d..19c9663 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -6,15 +6,15 @@ strategy: free tasks: - - name: Enable filesystem check prior to performing disk activities - ansible.builtin.import_role: - name: autofsck - tasks_from: main.yml - when: - - (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool) + # - name: Enable filesystem check prior to performing disk activities + # ansible.builtin.import_role: + # name: autofsck + # tasks_from: main.yml + # when: + # - (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool) - - name: Flush handlers - ansible.builtin.meta: flush_handlers + # - name: Flush handlers + # ansible.builtin.meta: flush_handlers - name: Extend the timeout values for physical hosts ansible.builtin.set_fact: @@ -39,11 +39,11 @@ when: - bigboot_execute_bigboot | bool - - name: Remove filesystem check from Grub - ansible.builtin.import_role: - name: autofsck - tasks_from: cleanup.yml - when: - - (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool) + # - name: Remove filesystem check from Grub + # ansible.builtin.import_role: + # name: autofsck + # tasks_from: cleanup.yml + # when: + # - (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool) ... -- 2.47.1 From db7f706fcd75a3e32ac67fdf168ca67fb4660528 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Tue, 2 Jul 2024 23:26:57 -0400 Subject: [PATCH 41/53] restore fsck to verify if working or not --- bigboot_execute_resize.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index 19c9663..aaaa05d 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -6,15 +6,15 @@ strategy: free tasks: - # - name: Enable filesystem check prior to performing disk activities - # ansible.builtin.import_role: - # name: autofsck - # tasks_from: main.yml - # when: - # - (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool) + - name: Enable filesystem check prior to performing disk activities + ansible.builtin.import_role: + name: autofsck + tasks_from: main.yml + when: + - (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool) - # - name: Flush handlers - # ansible.builtin.meta: flush_handlers + - name: Flush handlers + ansible.builtin.meta: flush_handlers - name: Extend the timeout values for physical hosts ansible.builtin.set_fact: @@ -39,11 +39,11 @@ when: - bigboot_execute_bigboot | bool - # - name: Remove filesystem check from Grub - # ansible.builtin.import_role: - # name: autofsck - # tasks_from: cleanup.yml - # when: - # - (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool) + - name: Remove filesystem check from Grub + ansible.builtin.import_role: + name: autofsck + tasks_from: cleanup.yml + when: + - (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool) ... -- 2.47.1 From ca371f94c3dcab94948cc1a34c7fd63f88f2fee8 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Tue, 2 Jul 2024 23:40:28 -0400 Subject: [PATCH 42/53] add reboot --- bigboot_execute_resize.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index aaaa05d..e33087e 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -16,6 +16,9 @@ - name: Flush handlers ansible.builtin.meta: flush_handlers + - name: Reboot to run filesystem check + ansible.builtin.reboot: + - name: Extend the timeout values for physical hosts ansible.builtin.set_fact: initramfs_post_reboot_delay: 300 -- 2.47.1 From 942afbf20515cacec3f7f7e9ef4314ba2519022c Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 3 Jul 2024 10:10:47 -0400 Subject: [PATCH 43/53] task re-order and re-name --- bigboot_execute_resize.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index e33087e..7b51480 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -6,7 +6,7 @@ strategy: free tasks: - - name: Enable filesystem check prior to performing disk activities + - name: Enable filesystem check prior to Bigboot execution ansible.builtin.import_role: name: autofsck tasks_from: main.yml @@ -16,9 +16,17 @@ - name: Flush handlers ansible.builtin.meta: flush_handlers + # Make sure to update the reboot code for the WF environment - name: Reboot to run filesystem check ansible.builtin.reboot: + - name: Disable filesystem check prior to Bigboot execution + ansible.builtin.import_role: + name: autofsck + tasks_from: cleanup.yml + when: + - (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool) + - name: Extend the timeout values for physical hosts ansible.builtin.set_fact: initramfs_post_reboot_delay: 300 @@ -42,11 +50,4 @@ when: - bigboot_execute_bigboot | bool - - name: Remove filesystem check from Grub - ansible.builtin.import_role: - name: autofsck - tasks_from: cleanup.yml - when: - - (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool) - ... -- 2.47.1 From 08168aafa1951f35b716be723de2cca0db649fd2 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 3 Jul 2024 10:53:37 -0400 Subject: [PATCH 44/53] move fsck code to a block --- bigboot_execute_resize.yml | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index 7b51480..3514f9e 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -6,26 +6,27 @@ strategy: free tasks: - - name: Enable filesystem check prior to Bigboot execution - 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 filesystem check prior to Bigboot execution + ansible.builtin.import_role: + name: autofsck + tasks_from: main.yml - - name: Flush handlers - ansible.builtin.meta: flush_handlers + - name: Flush handlers + ansible.builtin.meta: flush_handlers - # Make sure to update the reboot code for the WF environment - - name: Reboot to run filesystem check - ansible.builtin.reboot: + # Make sure to update the reboot code for the WF environment + - name: Reboot to run filesystem check + ansible.builtin.reboot: + + - name: Disable filesystem check prior to Bigboot execution + ansible.builtin.import_role: + name: autofsck + tasks_from: cleanup.yml - - name: Disable filesystem check prior to Bigboot execution - ansible.builtin.import_role: - name: autofsck - tasks_from: cleanup.yml - when: - - (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool) - name: Extend the timeout values for physical hosts ansible.builtin.set_fact: -- 2.47.1 From 1cbe355b1965145c75bdd00083450d37c0e53086 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 3 Jul 2024 15:49:23 -0400 Subject: [PATCH 45/53] task name updates --- bigboot_execute_resize.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index 3514f9e..41a9d9e 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -10,7 +10,7 @@ when: - (bigboot_execute_shrink_lv | bool or bigboot_execute_bigboot | bool) block: - - name: Enable filesystem check prior to Bigboot execution + - name: Enable Grub filesystem check ansible.builtin.import_role: name: autofsck tasks_from: main.yml @@ -19,10 +19,10 @@ ansible.builtin.meta: flush_handlers # Make sure to update the reboot code for the WF environment - - name: Reboot to run filesystem check + - name: Reboot to run filesystem checks ansible.builtin.reboot: - - name: Disable filesystem check prior to Bigboot execution + - name: Disable Grub filesystem check ansible.builtin.import_role: name: autofsck tasks_from: cleanup.yml -- 2.47.1 From 4b15e3396b50438cc2283b27578fcf6808991d33 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Mon, 8 Jul 2024 18:36:03 -0400 Subject: [PATCH 46/53] add flush handlers for cleanup --- bigboot_execute_resize.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index 41a9d9e..20665f4 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -27,6 +27,9 @@ 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: -- 2.47.1 From 25c7c4a19edf7d4547a72985546441d1e359a9c2 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 10 Jul 2024 19:45:25 -0400 Subject: [PATCH 47/53] initial changes and cleanup prior to service management code --- bigboot-check-device-debug.yml | 37 +++++++++++++++++++++++++++ bigboot-noop.yml | 8 +++--- bigboot_execute_resize.yml | 3 +++ bigboot_rear_backup.yml | 20 +++++++++++---- bigboot_setup_environment.yml | 5 ++-- tasks/check_systemd_services.yml | 40 ++++++++++++++++++++++++++++++ tasks/disable_systemd_services.yml | 11 ++++++++ vars/bigboot_vars.yml | 15 +++++++++++ 8 files changed, 127 insertions(+), 12 deletions(-) create mode 100644 bigboot-check-device-debug.yml create mode 100644 tasks/check_systemd_services.yml create mode 100644 tasks/disable_systemd_services.yml create mode 100644 vars/bigboot_vars.yml diff --git a/bigboot-check-device-debug.yml b/bigboot-check-device-debug.yml new file mode 100644 index 0000000..ac4b562 --- /dev/null +++ b/bigboot-check-device-debug.yml @@ -0,0 +1,37 @@ +--- +- name: Capture boot and logical volume information + hosts: all + become: true + gather_facts: true + strategy: free + + vars: + shrink_lv_device: "/dev/mapper/system-root" + + tasks: + - name: Get the mount point info + ansible.builtin.set_fact: + shrink_lv_mount_info: "{{ ansible_facts.mounts | selectattr('device', 'equalto', shrink_lv_device) }}" + + - name: Assert that the mount point exists + ansible.builtin.assert: + that: (shrink_lv_mount_info | length) == 1 + fail_msg: "Mount point {{ shrink_lv_device }} does not exist" + + - name: Get logical volume mount information + ansible.builtin.set_fact: + bigboot_lv_info: "{{ ansible_facts.mounts \ + | selectattr('device', 'equalto', shrink_lv_device) }}" + + - name: Assert that the mount point exists + ansible.builtin.assert: + that: (bigboot_lv_info | length) == 1 + fail_msg: "Mount point {{ shrink_lv_device }} does not exist" + + - name: Debug shrink_lv_mount_info + ansible.builtin.debug: + var: shrink_lv_mount_info + + - name: Debug bigboot_lv_info + ansible.builtin.debug: + var: bigboot_lv_info diff --git a/bigboot-noop.yml b/bigboot-noop.yml index aabe53c..2fad2aa 100644 --- a/bigboot-noop.yml +++ b/bigboot-noop.yml @@ -1,13 +1,12 @@ --- -- name: Capture boot and logical volume information +- name: Perform logical volume and boot parition resizing as needed hosts: all become: true gather_facts: true strategy: free - vars: - bigboot_size_target: 1G - + vars_files: + - bigboot_vars.yml tasks: - name: Cleanup from any previous executions @@ -24,6 +23,7 @@ ansible.builtin.import_playbook: rhc.rear.rear_backup when: - bigboot_execute_bigboot | bool + - not bigboot_skip_rear_backup | bool - name: Perform logical volume and boot parition resizing as needed diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index 20665f4..fae1638 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -5,6 +5,9 @@ gather_facts: true strategy: free + vars_files: + - bigboot_vars.yml + tasks: - name: Perform filesystem check prior to Bigboot execution when: diff --git a/bigboot_rear_backup.yml b/bigboot_rear_backup.yml index 91413de..9013549 100644 --- a/bigboot_rear_backup.yml +++ b/bigboot_rear_backup.yml @@ -1,8 +1,18 @@ --- -- 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 | bool - - not bigboot_skip_rear_backup | bool +- name: Perform a ReaR backup + hosts: all + become: true + gather_facts: true + strategy: free + + vars_files: + - bigboot_vars.yml + + tasks: + - 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 | bool + - not bigboot_skip_rear_backup | bool ... diff --git a/bigboot_setup_environment.yml b/bigboot_setup_environment.yml index af7e5dd..bd7dd06 100644 --- a/bigboot_setup_environment.yml +++ b/bigboot_setup_environment.yml @@ -5,9 +5,8 @@ gather_facts: true strategy: free - vars: - bigboot_size_target: 1G - ansible_ssh_retries: 10 + vars_files: + - bigboot_vars.yml tasks: - name: Cleanup from any previous executions diff --git a/tasks/check_systemd_services.yml b/tasks/check_systemd_services.yml new file mode 100644 index 0000000..e600704 --- /dev/null +++ b/tasks/check_systemd_services.yml @@ -0,0 +1,40 @@ +--- +- name: Verify Middleware Apache package presence + 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 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: 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 + 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 }}" diff --git a/tasks/disable_systemd_services.yml b/tasks/disable_systemd_services.yml new file mode 100644 index 0000000..d90a9f4 --- /dev/null +++ b/tasks/disable_systemd_services.yml @@ -0,0 +1,11 @@ +--- +- name: Disabling service for exceeding the timeout threshold + ansible.builtin.service: + name: "{{ item['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']] }}" diff --git a/vars/bigboot_vars.yml b/vars/bigboot_vars.yml new file mode 100644 index 0000000..082e19e --- /dev/null +++ b/vars/bigboot_vars.yml @@ -0,0 +1,15 @@ +--- +bigboot_size_target: 1G +ansible_ssh_retries: 10 + +# Max value in minutes for the timeout threshold: +bigboot_service_max_timeout: 2 + +# List of services which will be excluded from being disabled: +bigboot_protected_services: + - sshd.service + - user@0.service + - network + - rhnsd.service + # - rhnsd + - boksm.service -- 2.47.1 From e176c76638e5ba69b0f07d0f5dec5ca1dbfc3268 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 10 Jul 2024 20:46:24 -0400 Subject: [PATCH 48/53] 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 }}" -- 2.47.1 From 4bc64db2db05a6d61d0051197c309001c9f80887 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 10 Jul 2024 22:10:50 -0400 Subject: [PATCH 49/53] final touches --- bigboot-noop.yml | 8 +++++++- requirements.yml => collections/requirements.yml | 6 ------ vars/bigboot_vars.yml | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) rename requirements.yml => collections/requirements.yml (78%) diff --git a/bigboot-noop.yml b/bigboot-noop.yml index ef4f4be..8b6fb37 100644 --- a/bigboot-noop.yml +++ b/bigboot-noop.yml @@ -23,7 +23,7 @@ ansible.builtin.import_playbook: rhc.rear.rear_backup when: - bigboot_execute_bigboot | bool - - not bigboot_skip_rear_backup | bool + # - not bigboot_skip_rear_backup | bool - name: Perform logical volume and boot parition resizing as needed @@ -32,6 +32,9 @@ gather_facts: true strategy: free + vars_files: + - bigboot_vars.yml + tasks: - name: Perform filesystem check prior to Bigboot execution when: @@ -88,3 +91,6 @@ state: started enabled: true loop: "{{ bigboot_systemd_disabled_services }}" + when: + - bigboot_systemd_disabled_services is defined + - bigboot_systemd_disabled_services | length > 0 diff --git a/requirements.yml b/collections/requirements.yml similarity index 78% rename from requirements.yml rename to collections/requirements.yml index 9a4c623..1f04f19 100644 --- a/requirements.yml +++ b/collections/requirements.yml @@ -1,10 +1,4 @@ --- -roles: - - name: autofsck - src: https://gitea.thezengarden.net/ansible_roles/autofsck.git - scm: git - version: main - collections: # - name: infra.lvm_snapshots.shrink_lv # source: https://github.com/redhat-cop/infra.lvm_snapshots.git diff --git a/vars/bigboot_vars.yml b/vars/bigboot_vars.yml index 082e19e..8bf1cf0 100644 --- a/vars/bigboot_vars.yml +++ b/vars/bigboot_vars.yml @@ -2,6 +2,8 @@ bigboot_size_target: 1G ansible_ssh_retries: 10 +bigboot_skip_rear_backup: false + # Max value in minutes for the timeout threshold: bigboot_service_max_timeout: 2 @@ -11,5 +13,5 @@ bigboot_protected_services: - user@0.service - network - rhnsd.service - # - rhnsd + - rhnsd - boksm.service -- 2.47.1 From b76ba8933e5146a6c455dadeaeb61f335fd9e404 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 10 Jul 2024 22:12:44 -0400 Subject: [PATCH 50/53] final final touches; add conditional to service re-enable --- bigboot_execute_resize.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bigboot_execute_resize.yml b/bigboot_execute_resize.yml index efe5808..2055593 100644 --- a/bigboot_execute_resize.yml +++ b/bigboot_execute_resize.yml @@ -66,3 +66,6 @@ state: started enabled: true loop: "{{ bigboot_systemd_disabled_services }}" + when: + - bigboot_systemd_disabled_services is defined + - bigboot_systemd_disabled_services | length > 0 -- 2.47.1 From f8b500a0dc90fdcfa83f5abe552de0c6c66daa5f Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Thu, 11 Jul 2024 10:26:09 -0400 Subject: [PATCH 51/53] fixes --- bigboot-noop.yml | 4 ++-- bigboot_rear_backup.yml | 22 +++++----------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/bigboot-noop.yml b/bigboot-noop.yml index 8b6fb37..6507a2e 100644 --- a/bigboot-noop.yml +++ b/bigboot-noop.yml @@ -22,8 +22,8 @@ - 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 | bool - # - not bigboot_skip_rear_backup | bool + - bigboot_execute_bigboot | default('false') | bool + - not bigboot_skip_rear_backup | default('true') | bool - name: Perform logical volume and boot parition resizing as needed diff --git a/bigboot_rear_backup.yml b/bigboot_rear_backup.yml index 9013549..ffde0d6 100644 --- a/bigboot_rear_backup.yml +++ b/bigboot_rear_backup.yml @@ -1,18 +1,6 @@ --- -- name: Perform a ReaR backup - hosts: all - become: true - gather_facts: true - strategy: free - - vars_files: - - bigboot_vars.yml - - tasks: - - 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 | bool - - not bigboot_skip_rear_backup | bool - -... +- 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 -- 2.47.1 From 4e9e4438e098381a7345738786fd62c193f9781e Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Thu, 11 Jul 2024 11:31:50 -0400 Subject: [PATCH 52/53] updates --- vars/bigboot_vars.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vars/bigboot_vars.yml b/vars/bigboot_vars.yml index 8bf1cf0..b9d0c1d 100644 --- a/vars/bigboot_vars.yml +++ b/vars/bigboot_vars.yml @@ -7,7 +7,8 @@ bigboot_skip_rear_backup: false # Max value in minutes for the timeout threshold: bigboot_service_max_timeout: 2 -# List of services which will be excluded from being disabled: +# List of services which will be excluded from being +# disabled during Bigboot execution: bigboot_protected_services: - sshd.service - user@0.service -- 2.47.1 From 39f557220eb5a492d61e4a820e54d5251403b51f Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Thu, 11 Jul 2024 11:32:18 -0400 Subject: [PATCH 53/53] oops... more updates --- vars/bigboot_vars.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vars/bigboot_vars.yml b/vars/bigboot_vars.yml index b9d0c1d..d680b89 100644 --- a/vars/bigboot_vars.yml +++ b/vars/bigboot_vars.yml @@ -1,7 +1,11 @@ --- -bigboot_size_target: 1G ansible_ssh_retries: 10 +bigboot_size_target: 1G + +bigboot_post_reboot_delay: 70 +bigboot_reboot_timeout: 1800 + bigboot_skip_rear_backup: false # Max value in minutes for the timeout threshold: -- 2.47.1