ci_testing role -- Configure the GRUB2 boot loader
Note
This role is part of the fedora.linux_system_roles collection.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it use: ansible-galaxy collection install fedora.linux_system_roles.
To use it in a playbook, specify: fedora.linux_system_roles.ci_testing.
Entry point main -- Configure the GRUB2 boot loader
Synopsis
The
bootloaderrole manages GRUB2 boot loader settings: kernel command line parameters, the boot loader timeout, and the boot loader password.Considerations: Fedora 42 (
grubby-8.40-82.fc42.x86_64) introduced a bug, BZ#2361624, that changes the default kernel to a newly added kernel. To keep a specific kernel as the default, setdefault: truefor that kernel in thebootloader_settingsvariable.Collection requirements: To manage
rpm-ostreesystems, the role needs extra modules from external collections. Install them withansible-galaxy collection install -vv -r meta/collection-requirements.yml. Non-ostree systems need no extra collections.For
rpm-ostreesystems, see theREADME-ostree.mdfile in the role.Test
Parameters
Parameter |
Comments |
|---|---|
Whether to gather bootloader facts containing boot information for all kernels. The role returns the facts in the Choices:
|
|
The password to protect boot parameters. When set to |
|
Precomputed GRUB PBKDF2 SHA512 password hash for the root boot loader user. Generate the hash with |
|
Whether the role is allowed to reboot the managed host when changes require a reboot to take effect. If Choices:
|
|
Whether to remove the boot loader password configuration. Choices:
|
|
Whether to suppress potentially sensitive output from tasks that handle credentials by setting Choices:
|
|
List of kernel entries and their command line parameters to configure. Each entry specifies a kernel and the boot loader settings to apply. Default: |
|
Whether to make this kernel the default boot entry. Choices:
|
|
The kernel to update settings for. Accepts the string |
|
List of boot loader arguments to apply to the specified kernel. |
|
Whether to copy the default arguments to the created kernel. Choices:
|
|
The name of the boot loader setting. Not required when using |
|
Whether to replace all previous settings with the given settings. The only supported value is Choices:
|
|
Whether the setting is Choices:
|
|
The value for the setting. Not required when the setting has no value, for example |
|
Whether to keep the kernel entry ( Choices:
|
|
The GRUB boot loader timeout in seconds. When set to |
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: partial
|
CPU architectures the role can run on. |
|
Support: none The role does not support check mode. |
Can run in |
|
Support: partial Kernel command line parameters, the boot loader timeout, and
|
When run twice in a row outside check mode with the same arguments, the second run reports no change. This assumes the managed host has not changed in a relevant way between runs. |
|
Support: full
|
Target operating systems. |
Notes
Note
When setting a kernel option value in
bootloader_settings, the value must not be a YAML bool type. Quote values such asvalue: onasvalue: "on", or otherwise pass them asstr. A value must also not benull:value:,value: ~, andvalue: nullare not allowed and raise an error.
Examples
- name: Manage kernels by path, index, and title, and add, remove, and copy defaults
hosts: all
vars:
bootloader_settings:
# Update an existing kernel using path and replacing previous settings
- kernel:
path: /boot/vmlinuz-6.5.7-100.fc37.x86_64
options:
- name: console
value: tty0
state: present
- previous: replaced
default: false
# Update an existing kernel using index
- kernel:
index: 1
options:
- name: print-fatal-signals
value: 1
default: true
# Update an existing kernel using title
- kernel:
title: Red Hat Enterprise Linux (4.1.1.1.el8.x86_64) 8
options:
- name: no_timer_check
state: present
# Add a kernel with arguments
- kernel:
path: /boot/vmlinuz-6.5.7-100.fc37.x86_64
initrd: /boot/initramfs-6.5.7-100.fc37.x86_64.img
title: My kernel
options:
- name: console
value: tty0
- name: print-fatal-signals
value: 1
- name: no_timer_check
state: present
state: present
# Add a kernel with arguments and copying default arguments
- kernel:
path: /boot/vmlinuz-6.5.7-100.fc37.x86_64
initrd: /boot/initramfs-6.5.7-100.fc37.x86_64.img
title: My kernel
options:
- name: console
value: tty0
- copy_default: true
state: present
# Remove a kernel
- kernel:
title: My kernel
state: absent
# Update all kernels
- kernel: ALL
options:
- name: debug
state: present
# Update the default kernel
- kernel: DEFAULT
options:
- name: quiet
state: present
bootloader_timeout: 5
bootloader_reboot_ok: true
roles:
- linux-system-roles.bootloader
- name: Gather bootloader facts for all kernels without making changes
hosts: all
vars:
bootloader_gather_facts: true
roles:
- linux-system-roles.bootloader
- name: Set a bootloader password (pull the value from Ansible Vault)
hosts: all
vars:
bootloader_password: "{{ vault_bootloader_password }}"
bootloader_secure_logging: true
roles:
- linux-system-roles.bootloader
- name: Set an idempotent password hash from grub2-mkpasswd-pbkdf2
hosts: all
vars:
bootloader_password_hash: "{{ vault_bootloader_password_hash }}"
bootloader_secure_logging: true
roles:
- linux-system-roles.bootloader
- name: Remove the bootloader password
hosts: all
vars:
bootloader_remove_password: true
roles:
- linux-system-roles.bootloader
- name: Allow the role to reboot the host automatically
hosts: all
vars:
bootloader_reboot_ok: true
bootloader_settings:
- kernel: DEFAULT
options:
- name: crashkernel
value: 512M
roles:
- linux-system-roles.bootloader
Return Variables
The following variables are set by this role:
Key |
Description |
|---|---|
Boot information for all kernels, as gathered by the The role sets this in Returned: When Sample: |
|
Command line arguments passed to the kernel. Returned: success |
|
Whether this kernel is the default boot entry. Returned: success |
|
The kernel ID. Returned: success |
|
The kernel index. Returned: success |
|
Path to the kernel initrd image. Returned: success |
|
Path to the kernel image. Returned: success |
|
The root device for this kernel. Returned: success |
|
The boot entry title. Returned: success |
|
The role sets this when Returned: always Sample: |