Merge pull request 'Move develop into main' (#2) from develop into main

Reviewed-on: #2
This commit is contained in:
Chris Hammer 2024-07-11 21:41:44 -04:00
commit d6de38bfbc
24 changed files with 438 additions and 418 deletions

View File

@ -4,3 +4,4 @@ skip_list:
- yaml[line-length]
- no-changed-when
- run-once[play]
- name[template]

1
.gitignore vendored
View File

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

View File

@ -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
...

View File

@ -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

View File

@ -1,15 +1,17 @@
---
- 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
ansible.builtin.import_tasks: tasks/cleanup.yml
- name: Capture boot device details
ansible.builtin.import_tasks: tasks/capture_boot_device_details.yml
@ -17,10 +19,11 @@
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
- bigboot_execute_bigboot | default('false') | bool
- not bigboot_skip_rear_backup | default('true') | bool
- name: Perform logical volume and boot parition resizing as needed
@ -29,11 +32,49 @@
gather_facts: true
strategy: free
vars_files:
- bigboot_vars.yml
tasks:
- name: Expand the logical volume to support /boot expansion
- 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: Extend the timeout values for physical hosts
ansible.builtin.set_fact:
initramfs_post_reboot_delay: 300
initramfs_reboot_timeout: 14400
when:
- "'host' in ansible_virtualization_role"
- name: Shrink the logical volume to support /boot expansion
ansible.builtin.debug:
msg:
- "device: {{ bigboot_adjacent_lvm_device | trim }}"
- "device: {{ bigboot_adjacent_lvm_device }}"
- "size : {{ bigboot_lv_shrink_size | int }}"
when:
- bigboot_execute_shrink_lv | bool
@ -41,4 +82,15 @@
- name: Expand the /boot partition as requested
ansible.builtin.debug:
msg: "{{ bigboot_size }}"
when: bigboot_execute_bigboot | bool
when:
- bigboot_execute_bigboot | bool
- name: Re-enabling services previously disabled
ansible.builtin.service:
name: "{{ item }}"
state: started
enabled: true
loop: "{{ bigboot_systemd_disabled_services }}"
when:
- bigboot_systemd_disabled_services is defined
- bigboot_systemd_disabled_services | length > 0

View File

@ -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

View File

@ -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
...

View File

@ -1,20 +0,0 @@
---
- name: Resize the /boot parition to the desired size
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: Shrink a logical volume for /boot expansion if needed
ansible.builtin.import_tasks: tasks/bigboot_manage_lv.yml
- name: Expand the /boot partition as requested
ansible.builtin.include_role:
name: infra.lvm_snapshots.bigboot

View File

@ -0,0 +1,71 @@
---
- name: Perform logical volume and boot parition resizing as needed
hosts: all
become: true
gather_facts: true
strategy: free
vars_files:
- bigboot_vars.yml
tasks:
- name: Perform 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: 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.import_role:
name: infra.lvm_snapshots.shrink_lv
vars:
shrink_lv_devices:
- device: "{{ bigboot_adjacent_lvm_device }}"
size: "{{ bigboot_lv_shrink_size | int }}"
when:
- bigboot_execute_shrink_lv | bool
- name: Expand the /boot partition as requested
ansible.builtin.import_role:
name: infra.lvm_snapshots.bigboot
when:
- bigboot_execute_bigboot | bool
- name: Re-enabling services previously disabled
ansible.builtin.service:
name: "{{ item }}"
state: started
enabled: true
loop: "{{ bigboot_systemd_disabled_services }}"
when:
- bigboot_systemd_disabled_services is defined
- bigboot_systemd_disabled_services | length > 0

6
bigboot_rear_backup.yml Normal file
View File

@ -0,0 +1,6 @@
---
- 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

View File

@ -0,0 +1,33 @@
---
- name: Capture boot and logical volume information
hosts: all
become: true
gather_facts: true
strategy: free
vars_files:
- bigboot_vars.yml
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
- 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 }}"
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
...

View File

@ -4,21 +4,59 @@
become: true
gather_facts: true
vars:
__part_size: 80GB
__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/sdb
# - /dev/sdc
- /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
- /dev/sdf
- /dev/sdg
- /dev/sdh
- /dev/sdi
- /dev/sdj
- /dev/sdk
- /dev/sdl
- /dev/sdm
- /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
@ -30,57 +68,13 @@
map('regex_replace', '(?P<device>sd.*)', '\\g<device>' + '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 }}"
- name: Include LVM setup creation tasks
ansible.builtin.include_tasks: tasks/create_lvm_setup.yml
loop: "{{ __partition_devices }}"
- name: Create VG
community.general.lvg:
vg : "{{ __vg_name }}"
pvs : "{{ __partition_devices | \
map('regex_replace', '(?P<device>sd.*)', '\\g<device>' + '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
...

5
roles/requirements.yml Normal file
View File

@ -0,0 +1,5 @@
---
- name: autofsck
src: https://gitea.thezengarden.net/ansible_roles/autofsck.git
scm: git
version: main

View File

@ -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
...

View File

@ -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

View File

@ -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

View File

@ -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 }}"

View File

@ -1,21 +1,46 @@
---
- name: Capture logical volume adjacent to /boot
- name: Capture all logical volume paritions on /boot device
ansible.builtin.shell:
cmd: |
set -o pipefail
lsblk -p -o name,type|grep lvm|head -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
- 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: Debug bigboot_lvm_mounts
ansible.builtin.debug:
var: bigboot_lvm_mounts
verbosity: 1
- 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_lvm_mounts | first }}"
- 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:
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:

View File

@ -0,0 +1,31 @@
---
- name: Get the list of services on the host
ansible.builtin.service_facts:
- name: Capture a list of running services
ansible.builtin.set_fact:
bigboot_systemd_running_services:
"{{ bigboot_systemd_running_services | default([]) + [item['key']] }}"
loop: "{{ ansible_facts['services'] | dict2items }}"
loop_control:
label: "{{ item['key'] }}"
when:
- "'running' in item['value']['state']"
- name: Get the stop timeout value for running services
ansible.builtin.shell:
cmd: |
set -o pipefail
systemctl show {{ item }} | grep TimeoutStopUSec
changed_when: false
register: bigboot_systemd_service_timeout
loop: "{{ bigboot_systemd_running_services }}"
- name: Disabling services exceeding the timeout threshold
ansible.builtin.include_tasks: tasks/disable_systemd_services.yml
loop: "{{ bigboot_systemd_service_timeout['results'] }}"
loop_control:
label: "{{ item['item'] }}"
when:
- item['item'] not in bigboot_protected_services
- item['stdout'] | regex_replace('^.*=(.*$)', '\\1') | community.general.to_minutes > bigboot_service_max_timeout

32
tasks/cleanup.yml Normal file
View File

@ -0,0 +1,32 @@
---
- 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:
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
...

View File

@ -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

View File

@ -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']] }}"

22
vars/bigboot_vars.yml Normal file
View File

@ -0,0 +1,22 @@
---
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:
bigboot_service_max_timeout: 2
# List of services which will be excluded from being
# disabled during Bigboot execution:
bigboot_protected_services:
- sshd.service
- user@0.service
- network
- rhnsd.service
- rhnsd
- boksm.service