cleanup
This commit is contained in:
parent
56d5266dc1
commit
f6d129a593
@ -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
|
||||
|
||||
|
||||
...
|
@ -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
|
@ -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
|
||||
|
||||
|
||||
...
|
34
bigboot.yml
34
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
|
||||
|
@ -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', '(?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 }}"
|
||||
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
|
||||
|
||||
|
||||
...
|
@ -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
|
||||
|
||||
|
||||
...
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 }}"
|
Loading…
x
Reference in New Issue
Block a user