Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bigboot - prepend variable names with role name #42

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/bigboot-internal-variable-names.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- bigboot - Rename internal variables with role name prefix
16 changes: 8 additions & 8 deletions roles/bigboot/tasks/get_boot_device_info.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
10 changes: 3 additions & 7 deletions roles/bigboot/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions roles/bigboot/templates/increase-boot-partition.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down