+grub role

This commit is contained in:
Josh Lay 2025-07-27 09:48:17 -05:00
parent 5ffe2b9be1
commit cfa9a8420a
Signed by: jlay
SSH key fingerprint: SHA256:RwEMoWwXniQX1sqHfSD+3z+LKU/TOkv3i1qsy75vfec
7 changed files with 43 additions and 0 deletions

6
roles/grub/README.md Normal file
View file

@ -0,0 +1,6 @@
grub
=========
Ansible Role for misc. `GRUB` bootloader opinions. Notably:
- `GRUB_RECORDFAIL_TIMEOUT`: prevents requiring human intervention when the _last_ boot failed.

View file

@ -0,0 +1,10 @@
---
# defaults file for grub
#
grub_cfgs:
debian: /etc/default/grub
redhat: /etc/sysconfig/grub # likely a symlink, stub just in case
grub_updatecmd:
debian: update-grub
redhat: grub2-mkconfig -o /etc/grub2.cfg

View file

@ -0,0 +1,9 @@
---
# handlers file for grub
#
- name: Generate Config
ansible.builtin.command:
cmd: "{{ grub_updatecmd[ansible_os_family | lower] }}"
become: true
changed_when: true # handler, assume this cmd is realizing changes/making more
listen: update_grubcfg

View file

@ -0,0 +1,9 @@
---
- name: Ensure 'GRUB_RECORDFAIL_TIMEOUT'
ansible.builtin.lineinfile:
path: "{{ grub_cfgs[ansible_os_family | lower] }}"
regexp: '^GRUB_RECORDFAIL_TIMEOUT'
line: 'GRUB_RECORDFAIL_TIMEOUT=5'
become: true
notify: update_grubcfg

View file

@ -0,0 +1,6 @@
---
# tasks file for grub
#
- name: Include tasks by OS family
ansible.builtin.include_tasks:
file: "{{ ansible_os_family | lower }}.yml"

View file

@ -0,0 +1 @@
---

2
roles/grub/vars/main.yml Normal file
View file

@ -0,0 +1,2 @@
---
# vars file for grub