--- - name: Shrink logical volumes hosts: bigboot become: false gather_facts: true tasks: - name: Get mounts ansible.builtin.debug: var: ansible_facts.mounts - name: Find the boot mount entry ansible.builtin.set_fact: bigboot_boot_mount_entry: "{{ ansible_facts.mounts | selectattr('mount', 'match', '/boot') | first }}" # - name: Calculate the partition to look for # ansible.builtin.set_fact: # bigboot_boot_partition_name: "{{ (bigboot_boot_mount_entry.device | split('/'))[-1] }}" - name: Calculate the partition to look for ansible.builtin.set_fact: bigboot_boot_partition_name: "{{ bigboot_boot_mount_entry.device | ansible.builtin.regex_replace('.*/(.*$)', '\\1') }}" # - name: Capture boot device new size # ansible.builtin.set_fact: # bigboot_boot_device_new_size_orig: "{{ (ansible_facts.mounts | selectattr('mount', 'equalto', '/boot') | first).size_total | int }}" - name: Capture boot device new size ansible.builtin.set_fact: bigboot_boot_device_new_size: "{{ (ansible_facts.mounts | selectattr('mount', 'match', '/boot') | first).size_total | int }}" - name: Get default kernel ansible.builtin.command: cmd: /sbin/grubby --default-kernel register: initramfs_grubby_rc changed_when: false - name: Parse default kernel version ansible.builtin.set_fact: # split was introduced in 2.11 # initramfs_default_kernel_orig: "{{ ((((initramfs_grubby_rc.stdout_lines[0] | split('/'))[2] | split('-'))[1:]) | join('-')) | trim }}" initramfs_default_kernel_pre: "{{ initramfs_grubby_rc.stdout }}" # fixes compatibility to run on: # Ansible 2.9.27 -> 2.16.2 initramfs_default_kernel: "{{ initramfs_grubby_rc.stdout | ansible.builtin.regex_replace('^.*?-(.*$)', '\\1') }}" - name: Find the boot device parent ansible.builtin.set_fact: bigboot_boot_disk: "{{ item.key }}" with_dict: "{{ ansible_facts.devices }}" when: bigboot_boot_partition_name in item.value.partitions - name: Capture boot device details ansible.builtin.set_fact: bigboot_boot_device_partition_prefix: "{{ bigboot_boot_partition_name | default() | ansible.builtin.regex_replace('^.+([0-9]{1})$', '\\1') }}" when: "'nvme' not in bigboot_boot_disk" - name: Capture boot device details (NVMe) ansible.builtin.set_fact: bigboot_boot_device_partition_prefix: "{{ bigboot_boot_partition_name | default() | ansible.builtin.regex_replace('^.+([a-z0-9]{2})$', '\\1') }}" when: "'nvme' in bigboot_boot_disk" - name: Debug stuffs ansible.builtin.debug: var: item loop: # - "{{ initramfs_grubby_rc }}" # - "{{ initramfs_default_kernel_pre }}" # - "{{ initramfs_default_kernel }}" # - "{{ ansible_facts.kernel }}" - "bigboot_boot_partition_name == {{ bigboot_boot_partition_name }}" - "bigboot_boot_device_new_size == {{ bigboot_boot_device_new_size }}" - "bigboot_boot_disk == {{ bigboot_boot_disk }}" - "bigboot_boot_device_partition_prefix == {{ bigboot_boot_device_partition_prefix }}" ...