Skip to content

Commit

Permalink
shrink_lv: use common role initramfs
Browse files Browse the repository at this point in the history
Signed-off-by: Ygal Blum <[email protected]>
  • Loading branch information
ygalblum committed Nov 29, 2023
1 parent 3a1e78d commit 5216e5c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 48 deletions.
15 changes: 0 additions & 15 deletions roles/shrink_lv/tasks/check_kernel.yaml

This file was deleted.

36 changes: 5 additions & 31 deletions roles/shrink_lv/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,9 @@
- kernel
- mounts

- name: Get kernel version
ansible.builtin.set_fact:
kernel_version: "{{ ansible_facts.kernel }}"

- name: Run preflight checks
ansible.builtin.include_tasks: preflight.yaml

- name: Create a backup of the current initramfs
ansible.builtin.copy:
remote_src: true
src: /boot/initramfs-{{ kernel_version }}.img
dest: /boot/initramfs-{{ kernel_version }}.img.{{ shrink_lv_backup_extension }}
mode: "0600"

- name: Copy shrink LV dracut module
ansible.builtin.copy:
src: "{{ item }}"
Expand All @@ -36,26 +25,11 @@
dest: /usr/lib/dracut/modules.d/99shrink_lv/shrink-start.sh
mode: '0554'

- name: Create a new initramfs with the extend boot module
ansible.builtin.command:
cmd: /usr/sbin/dracut -a shrink_lv --kver {{ kernel_version }} --force
changed_when: true

- name: Reboot the server
ansible.builtin.reboot:
post_reboot_delay: 30

- name: Restore previous initramfs
ansible.builtin.copy:
remote_src: true
src: /boot/initramfs-{{ kernel_version }}.img.{{ shrink_lv_backup_extension }}
dest: /boot/initramfs-{{ kernel_version }}.img
mode: "0600"

- name: Remove initramfs backup file
ansible.builtin.file:
path: /boot/initramfs-{{ kernel_version }}.img.{{ shrink_lv_backup_extension }}
state: absent
- name: Create the initramfs and reboot to run the module
vars:
initramfs_add_modules: "shrink_lv"
ansible.builtin.include_role:
name: initramfs

- name: Remove dracut extend boot module
ansible.builtin.file:
Expand Down
6 changes: 4 additions & 2 deletions roles/shrink_lv/tasks/preflight.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
- shrink_lv_devices | length > 0
fail_msg: shrink_lv_devices must be a list and include at least one element

- name: Assert current kernel version is the default
ansible.builtin.include_tasks: check_kernel.yaml
- name: Validate initramfs preflight
ansible.builtin.include_role:
name: initramfs
tasks_from: preflight

- name: Check all devices
ansible.builtin.include_tasks: check_device.yaml
Expand Down

0 comments on commit 5216e5c

Please sign in to comment.