diff --git a/changelogs/fragments/bigboot-internal-variable-names.yml b/changelogs/fragments/bigboot-internal-variable-names.yml new file mode 100644 index 0000000..dbdc56c --- /dev/null +++ b/changelogs/fragments/bigboot-internal-variable-names.yml @@ -0,0 +1,2 @@ +minor_changes: +- bigboot - Rename internal variables with role name prefix \ No newline at end of file diff --git a/roles/bigboot/tasks/get_boot_device_info.yml b/roles/bigboot/tasks/get_boot_device_info.yml index 7b63205..b8e941e 100644 --- a/roles/bigboot/tasks/get_boot_device_info.yml +++ b/roles/bigboot/tasks/get_boot_device_info.yml @@ -1,20 +1,20 @@ - name: Find the boot mount entry ansible.builtin.set_fact: - _boot_mount_entry: "{{ ansible_facts.mounts | selectattr('mount', 'equalto', '/boot') | first }}" + bigboot_boot_mount_entry: "{{ ansible_facts.mounts | selectattr('mount', 'equalto', '/boot') | first }}" - name: Calculate the partition to look for ansible.builtin.set_fact: - _boot_partition_name: "{{ (_boot_mount_entry.device | split('/'))[-1] }}" + bigboot_boot_partition_name: "{{ (bigboot_boot_mount_entry.device | split('/'))[-1] }}" - name: Find the boot device parent ansible.builtin.set_fact: - _boot_disk: "{{ item.key }}" + bigboot_boot_disk: "{{ item.key }}" with_dict: "{{ ansible_facts.devices }}" - when: _boot_partition_name in item.value.partitions + when: bigboot_boot_partition_name in item.value.partitions - name: Capture boot device details ansible.builtin.set_fact: - boot_device_partition_prefix: "{{ _boot_partition_name[(_boot_disk | length) : -1] }}" - boot_partition_number: "{{ _boot_partition_name[-1] }}" - boot_device_name: "/dev/{{ _boot_disk }}" - boot_device_original_size: "{{ _boot_mount_entry.size_total | int }}" + bigboot_boot_device_partition_prefix: "{{ bigboot_boot_partition_name[(bigboot_boot_disk | length) : -1] }}" + bigboot_boot_partition_number: "{{ bigboot_boot_partition_name[-1] }}" + bigboot_boot_device_name: "/dev/{{ bigboot_boot_disk }}" + bigboot_boot_device_original_size: "{{ bigboot_boot_mount_entry.size_total | int }}" diff --git a/roles/bigboot/tasks/main.yaml b/roles/bigboot/tasks/main.yaml index 3b819a8..65f4e29 100644 --- a/roles/bigboot/tasks/main.yaml +++ b/roles/bigboot/tasks/main.yaml @@ -57,14 +57,10 @@ - name: Capture boot device new size ansible.builtin.set_fact: - boot_device_new_size: "{{ (ansible_facts.mounts | selectattr('mount', 'equalto', '/boot') | first).size_total | int }}" - -- name: Capture expected device size - ansible.builtin.set_fact: - expected_size: "{{ (bigboot_size | human_to_bytes | int) + (boot_device_original_size | int) }}" + bigboot_boot_device_new_size: "{{ (ansible_facts.mounts | selectattr('mount', 'equalto', '/boot') | first).size_total | int }}" - name: Validate boot partition new size ansible.builtin.assert: that: - - boot_device_new_size != boot_device_original_size - fail_msg: "Boot partition size '{{ boot_device_new_size }}' did not change" + - bigboot_boot_device_new_size != bigboot_boot_device_original_size + fail_msg: "Boot partition size '{{ bigboot_boot_device_new_size }}' did not change" diff --git a/roles/bigboot/templates/increase-boot-partition.sh.j2 b/roles/bigboot/templates/increase-boot-partition.sh.j2 index 35075fd..c18bcd2 100644 --- a/roles/bigboot/templates/increase-boot-partition.sh.j2 +++ b/roles/bigboot/templates/increase-boot-partition.sh.j2 @@ -17,12 +17,12 @@ main() { start=$(/usr/bin/date +%s) disable_lvm_lock # run bigboot.sh to increase boot partition and file system size - ret=$(sh /usr/bin/bigboot.sh -d="{{ boot_device_name }}" -s="{{ bigboot_size }}" -b="{{ boot_partition_number }}" -p="{{ boot_device_partition_prefix }}" 2>/dev/kmsg) + ret=$(sh /usr/bin/bigboot.sh -d="{{ bigboot_boot_device_name }}" -s="{{ bigboot_size }}" -b="{{ bigboot_boot_partition_number }}" -p="{{ bigboot_boot_device_partition_prefix }}" 2>/dev/kmsg) status=$? end=$(/usr/bin/date +%s) # write the log file if [[ $status -eq 0 ]]; then - echo "[$name] Boot partition {{ boot_device_name }} successfully increased by {{ bigboot_size }} ("$((end-start))" seconds) " >/dev/kmsg + echo "[$name] Boot partition {{ bigboot_boot_device_name }} successfully increased by {{ bigboot_size }} ("$((end-start))" seconds) " >/dev/kmsg else echo "[$name] Failed to extend boot partition: $ret ("$((end-start))" seconds)" >/dev/kmsg fi