2024-10-25 10:01:14 +00:00
|
|
|
# Added password protection to restrict only GRUB editing, leaving menu entries unprotected.
|
|
|
|
# Added --unrestricted option to 09_make_OS_entries_unrestricted custom template.
|
|
|
|
# Oficial grub Manual -->> https://www.gnu.org/software/grub/manual/grub/html_node/Authentication-and-authorisation.html
|
|
|
|
# Questions -->> http://daniel-lange.com/archives/75-Securing-the-grub-boot-loader.html
|
|
|
|
# Questions -->> https://askubuntu.com/questions/1088215/grub-2-avoid-unrestricted-boot-options-are-overwritten-with-kernel-updates
|
|
|
|
# Resolution -->> https://wiki.archlinux.org/title/Talk:GRUB/Tips_and_tricks
|
2024-10-24 14:38:14 +00:00
|
|
|
- name: GRUB edit unrestricted option
|
|
|
|
copy:
|
2024-10-25 10:01:14 +00:00
|
|
|
content: |
|
|
|
|
#!/bin/sh
|
|
|
|
exec tail -n +3 $0
|
|
|
|
# This file provides an easy way to add custom menu entries. Simply type the
|
|
|
|
# menu entries you want to add after this comment. Be careful not to change
|
|
|
|
# the 'exec tail' line above.
|
|
|
|
menuentry_id_option="--unrestricted $menuentry_id_option"
|
|
|
|
dest: /etc/grub.d/09_make_OS_entries_unrestricted
|
2024-10-24 14:38:14 +00:00
|
|
|
owner: root
|
|
|
|
group: root
|
2024-10-25 10:01:14 +00:00
|
|
|
checksum: fed5c365f11a919b857b78207565cf341b86082b
|
2024-10-24 14:38:14 +00:00
|
|
|
mode: u=rwx,g=rx,o=rx
|
2024-10-25 10:01:14 +00:00
|
|
|
register: grubunrestricted
|
2024-10-24 14:38:14 +00:00
|
|
|
- name: GRUB edit password protection
|
|
|
|
copy:
|
|
|
|
content: |
|
|
|
|
#!/bin/sh
|
|
|
|
exec tail -n +3 $0
|
|
|
|
set superusers="{{ grub_user }}"
|
|
|
|
password_pbkdf2 {{ grub_user }} {{ grub_code }}
|
|
|
|
dest: /etc/grub.d/00_before
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: u=rwx,g=rx,o=rx
|
|
|
|
register: grubpass
|
|
|
|
- name: Change GRUB_TIMEOUT from 5 to 1
|
|
|
|
copy:
|
|
|
|
content: |
|
|
|
|
GRUB_TIMEOUT=1
|
|
|
|
dest: /etc/default/grub.d/timeout.cfg
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: u=rw,g=r,o=r
|
|
|
|
register: grubtime
|
|
|
|
- name: Generate GRUB configuration
|
|
|
|
command: update-grub
|
2024-10-25 10:01:14 +00:00
|
|
|
when: grubunrestricted.changed or grubpass.changed or grubtime.changed
|