Add grub role

This commit is contained in:
flyingscorpio@clevo 2022-02-27 11:53:38 +01:00
parent c7fd3bb78e
commit 3bfe29d700
4 changed files with 46 additions and 14 deletions

View file

@ -1,17 +1,3 @@
grub:
- install:
arch:
- grub-theme-vimix
- run:
command: sudo cp /etc/default/grub /etc/default/grub.backup
condition: "[ ! -e /etc/default/grub.backup ]"
- run:
- sudo sed -i -E 's/^#?GRUB_DEFAULT.+/GRUB_DEFAULT=saved/' /etc/default/grub &&
sudo sed -i -E 's@^#?GRUB_THEME.+@GRUB_THEME="/usr/share/grub/themes/Vimix/theme.txt"@' /etc/default/grub &&
sudo sed -i -E 's/^#?GRUB_SAVEDEFAULT.+/GRUB_SAVEDEFAULT=true/' /etc/default/grub &&
sudo sed -i -E 's/^#?GRUB_DISABLE_SUBMENU.+/GRUB_DISABLE_SUBMENU=y/' /etc/default/grub &&
sudo grub-mkconfig -o /boot/grub/grub.cfg
etckeeper:
- install:
- etckeeper

View file

@ -13,6 +13,7 @@
- { role: neovim, tags: [neovim, nvim] }
- { role: ssh-agent, tags: ssh-agent }
- { role: pacman, tags: [pacman, pacman.conf] }
- { role: grub, tags: grub }
- { role: firefox, tags: firefox }
- { role: tor, tags: tor }
- { role: sudoers, tags: sudoers }

3
roles/grub/meta/main.yml Normal file
View file

@ -0,0 +1,3 @@
---
dependencies:
- role: check-sudo

42
roles/grub/tasks/main.yml Normal file
View file

@ -0,0 +1,42 @@
---
- fail:
when: ansible_distribution != 'Archlinux'
- name: Install grub-theme-vimix (Archlinux)
become: true
pacman:
name:
- grub-theme-vimix
when: ansible_distribution == 'Archlinux'
- name: Set confs for grub
become: true
block:
- name: Set GRUB_DEFAULT to saved
replace:
path: /etc/default/grub
regexp: '^#?GRUB_DEFAULT.+'
replace: 'GRUB_DEFAULT=saved'
backup: true
- name: Set GRUB_THEME to Vimix
replace:
path: /etc/default/grub
regexp: '^#?GRUB_THEME.+'
replace: 'GRUB_THEME="/usr/share/grub/themes/Vimix/theme.txt"'
backup: true
- name: Set GRUB_SAVEDEFAULT to true
replace:
path: /etc/default/grub
regexp: '^#?GRUB_SAVEDEFAULT.+'
replace: 'GRUB_SAVEDEFAULT=true'
backup: true
- name: Disable grub submenu
replace:
path: /etc/default/grub
regexp: '^#?GRUB_DISABLE_SUBMENU.+'
replace: 'GRUB_DISABLE_SUBMENU=y'
backup: true
- name: Generate grub config
become: true
command: grub-mkconfig -o /boot/grub/grub.cfg