forked from redhat-cop/infra.lvm_snapshots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.yml
37 lines (32 loc) · 1.41 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---
- name: Make sure the required related facts are available
ansible.builtin.setup:
gather_subset:
- "!all"
- "!min"
- kernel
- name: Get kernel version
ansible.builtin.set_fact:
initramfs_kernel_version: "{{ ansible_facts.kernel }}"
- name: Create a backup of the current initramfs
ansible.builtin.copy:
remote_src: true
src: /boot/initramfs-{{ initramfs_kernel_version }}.img
dest: /root/initramfs-{{ initramfs_kernel_version }}.img.{{ initramfs_backup_extension }}
mode: "0600"
- name: Create a new initramfs with the optional additional modules
# yamllint disable-line rule:line-length
ansible.builtin.command: '/usr/bin/dracut {{ ((initramfs_add_modules | length) > 0) | ternary("-a", "") }} "{{ initramfs_add_modules }}" --kver {{ initramfs_kernel_version }} --force'
changed_when: true
- name: Configure initramfs restore reboot cron
ansible.builtin.cron:
name: initramfs restore
cron_file: initramfs_restore
user: root
special_time: reboot
# yamllint disable-line rule:line-length
job: '(mv -f /root/initramfs-{{ initramfs_kernel_version }}.img.{{ initramfs_backup_extension }} /boot/initramfs-{{ initramfs_kernel_version }}.img; rm -f /etc/cron.d/initramfs_restore) > /dev/null 2>&1'
- name: Reboot the server
ansible.builtin.reboot:
post_reboot_delay: "{{ initramfs_post_reboot_delay }}"
reboot_timeout: "{{ initramfs_reboot_timeout }}"