Add plymouth playbook

This commit is contained in:
Jika
2026-01-27 16:57:54 +01:00
parent 03f079e669
commit f83174b5f0

88
ansible/plymouth.yml Normal file
View File

@@ -0,0 +1,88 @@
- name: Install and configure Plymouth
hosts: localhost
become: true
vars:
plymouth_theme: "bgrt"
handlers:
- name: rebuild initramfs
command: mkinitcpio -P
- name: rebuild grub config
command: "grub-mkconfig -o /boot/grub/grub.cfg"
tasks:
- name: Install plymouth
pacman:
name:
- plymouth
state: present
update_cache: true
- name: Enable plymouth services
systemd:
name: "{{ item }}"
enabled: true
loop:
- plymouth-start.service
- plymouth-quit-wait.service
# Mkinitcpio update
- name: Read HOOKS line only
shell: "awk '/^HOOKS=/{print $0; exit}' /etc/mkinitcpio.conf"
register: hooks_line
changed_when: false
- name: Fail if encrypt hook not present in HOOKS
fail:
msg: "encrypt hook not found in HOOKS=... in /etc/mkinitcpio.conf"
when:
- hooks_line.stdout == "" or (hooks_line.stdout is not search('(^|\\s)encrypt(\\s|$)'))
- name: Insert plymouth before encrypt (only on HOOKS line)
replace:
path: /etc/mkinitcpio.conf
regexp: '^(HOOKS=\(.*\s)(encrypt)(\s.*\))$'
replace: '\1plymouth \2\3'
when:
- hooks_line.stdout != ""
- hooks_line.stdout is search('(^|\\s)encrypt(\\s|$)')
- hooks_line.stdout is not search('(^|\\s)plymouth(\\s|$)')
notify: rebuild initramfs
- name: Set plymouth theme and rebuild initramfs
command: "plymouth-set-default-theme -R {{ plymouth_theme }}"
register: theme_set
changed_when: theme_set.rc == 0
# GRUB update
- name: Read GRUB_CMDLINE_LINUX_DEFAULT line only
shell: "awk -F= '/^GRUB_CMDLINE_LINUX_DEFAULT=/{print $0; exit}' /etc/default/grub"
register: grub_cmdline_line
changed_when: false
- name: Fail if GRUB_CMDLINE_LINUX_DEFAULT not found
fail:
msg: "GRUB_CMDLINE_LINUX_DEFAULT not found in /etc/default/grub"
when: grub_cmdline_line.stdout == ""
- name: Ensure 'quiet' is present in GRUB_CMDLINE_LINUX_DEFAULT
replace:
path: /etc/default/grub
regexp: '^(GRUB_CMDLINE_LINUX_DEFAULT=")([^"]*)(")$'
replace: '\1\2 quiet\3'
when:
- grub_cmdline_line.stdout is not search('quiet')
notify: rebuild grub config
- name: Ensure 'splash' is present in GRUB_CMDLINE_LINUX_DEFAULT
replace:
path: /etc/default/grub
regexp: '^(GRUB_CMDLINE_LINUX_DEFAULT=")([^"]*)(")$'
replace: '\1\2 splash\3'
when:
- grub_cmdline_line.stdout is not search('splash')
notify: rebuild grub config