Skip to content

Commit 37606ed

Browse files
committed
Bigboot - prepend variable names with role name
Signed-off-by: Ygal Blum <[email protected]>
1 parent ddb7367 commit 37606ed

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minor_changes:
2+
- bigboot - Rename internal variables with role name prefix
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
- name: Find the boot mount entry
22
ansible.builtin.set_fact:
3-
_boot_mount_entry: "{{ ansible_facts.mounts | selectattr('mount', 'equalto', '/boot') | first }}"
3+
bigboot_boot_mount_entry: "{{ ansible_facts.mounts | selectattr('mount', 'equalto', '/boot') | first }}"
44

55
- name: Calculate the partition to look for
66
ansible.builtin.set_fact:
7-
_boot_partition_name: "{{ (_boot_mount_entry.device | split('/'))[-1] }}"
7+
bigboot_boot_partition_name: "{{ (bigboot_boot_mount_entry.device | split('/'))[-1] }}"
88

99
- name: Find the boot device parent
1010
ansible.builtin.set_fact:
11-
_boot_disk: "{{ item.key }}"
11+
bigboot_boot_disk: "{{ item.key }}"
1212
with_dict: "{{ ansible_facts.devices }}"
13-
when: _boot_partition_name in item.value.partitions
13+
when: bigboot_boot_partition_name in item.value.partitions
1414

1515
- name: Capture boot device details
1616
ansible.builtin.set_fact:
17-
boot_device_partition_prefix: "{{ _boot_partition_name[(_boot_disk | length) : -1] }}"
18-
boot_partition_number: "{{ _boot_partition_name[-1] }}"
19-
boot_device_name: "/dev/{{ _boot_disk }}"
20-
boot_device_original_size: "{{ _boot_mount_entry.size_total | int }}"
17+
bigboot_boot_device_partition_prefix: "{{ bigboot_boot_partition_name[(bigboot_boot_disk | length) : -1] }}"
18+
bigboot_boot_partition_number: "{{ bigboot_boot_partition_name[-1] }}"
19+
bigboot_boot_device_name: "/dev/{{ bigboot_boot_disk }}"
20+
bigboot_boot_device_original_size: "{{ bigboot_boot_mount_entry.size_total | int }}"

roles/bigboot/tasks/main.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,10 @@
5757

5858
- name: Capture boot device new size
5959
ansible.builtin.set_fact:
60-
boot_device_new_size: "{{ (ansible_facts.mounts | selectattr('mount', 'equalto', '/boot') | first).size_total | int }}"
61-
62-
- name: Capture expected device size
63-
ansible.builtin.set_fact:
64-
expected_size: "{{ (bigboot_size | human_to_bytes | int) + (boot_device_original_size | int) }}"
60+
bigboot_boot_device_new_size: "{{ (ansible_facts.mounts | selectattr('mount', 'equalto', '/boot') | first).size_total | int }}"
6561

6662
- name: Validate boot partition new size
6763
ansible.builtin.assert:
6864
that:
69-
- boot_device_new_size != boot_device_original_size
70-
fail_msg: "Boot partition size '{{ boot_device_new_size }}' did not change"
65+
- bigboot_boot_device_new_size != bigboot_boot_device_original_size
66+
fail_msg: "Boot partition size '{{ bigboot_boot_device_new_size }}' did not change"

roles/bigboot/templates/increase-boot-partition.sh.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ main() {
1717
start=$(/usr/bin/date +%s)
1818
disable_lvm_lock
1919
# run bigboot.sh to increase boot partition and file system size
20-
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)
20+
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)
2121
status=$?
2222
end=$(/usr/bin/date +%s)
2323
# write the log file
2424
if [[ $status -eq 0 ]]; then
25-
echo "[$name] Boot partition {{ boot_device_name }} successfully increased by {{ bigboot_size }} ("$((end-start))" seconds) " >/dev/kmsg
25+
echo "[$name] Boot partition {{ bigboot_boot_device_name }} successfully increased by {{ bigboot_size }} ("$((end-start))" seconds) " >/dev/kmsg
2626
else
2727
echo "[$name] Failed to extend boot partition: $ret ("$((end-start))" seconds)" >/dev/kmsg
2828
fi

0 commit comments

Comments
 (0)