shrink_lv/bigboot_execute_resize.yml

76 lines
2.8 KiB
YAML

---
- name: Perform logical volume and boot parition resizing as needed
hosts: all
become: true
gather_facts: true
strategy: free
vars_files:
- bigboot_vars.yml
tasks:
- name: Perform service and filesystem checks prior to Bigboot execution
when:
- bigboot_data[inventory_hostname]['bigboot_execute_bigboot'] | default(false) | bool
block:
- name: Check for and disable services exceeding the timeout threshold
ansible.builtin.import_tasks: tasks/check_systemd_services.yml
- name: Perform filesystem check prior to Bigboot execution
ansible.builtin.import_tasks: tasks/grub_filesystem_check.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_data[inventory_hostname]['bigboot_adjacent_lvm_device'] }}"
size: "{{ bigboot_data[inventory_hostname]['bigboot_lv_shrink_size'] | int }}"
when:
- bigboot_data[inventory_hostname]['bigboot_execute_shrink_lv'] | bool
- name: Expand the /boot partition as requested
ansible.builtin.import_role:
name: infra.lvm_snapshots.bigboot
vars:
bigboot_size: "{{ bigboot_data[inventory_hostname]['bigboot_size'] }}"
when:
- bigboot_data[inventory_hostname]['bigboot_execute_bigboot'] | bool
- name: Ensure service facts are available
ansible.builtin.service_facts:
- name: Restore named-chroot service to its pre-Bigboot state
ansible.builtin.service:
name: "{{ bigboot_named_chroot_service }}"
state: "{{ bigboot_data[inventory_hostname]['bigboot_named_chroot_running'] }}"
enabled: "{{ bigboot_data[inventory_hostname]['bigboot_named_chroot_enabled'] }}"
when:
- ansible_facts['services'][bigboot_named_chroot_service] is defined
- name: Restore Docker service to its pre-Bigboot state
ansible.builtin.service:
name: "{{ bigboot_docker_service }}"
state: "{{ bigboot_data[inventory_hostname]['bigboot_docker_running'] }}"
enabled: "{{ bigboot_data[inventory_hostname]['bigboot_docker_enabled'] }}"
when:
- ansible_facts['services'][bigboot_docker_service] is defined
- 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