Added kernel role

This commit is contained in:
2026-08-26 07:31:18 +02:00
parent 49f40991eb
commit a668fb269a
7 changed files with 87 additions and 30 deletions
+84
View File
@@ -0,0 +1,84 @@
- name: Add the bc250-cachyos pacman repository
become: true
ansible.builtin.blockinfile:
path: /etc/pacman.conf
marker: "# {mark} - Ansible managed"
prepend_newline: true
block: |
[bc250-cachyos]
SigLevel = Optional TrustAll
Server = https://github.com/MastaG/linux-cachyos-bc250/releases/download/repo
register: pacman_repo
# Full upgrade first: installing from a freshly added repo without -Syu
# would be a partial upgrade.
- name: Perform a full system upgrade
become: true
community.general.pacman:
update_cache: "{{ pacman_repo.changed }}"
upgrade: true
register: sys_upgrade
- name: Give the BC-250 kernel priority in BOOT_ORDER
become: true
ansible.builtin.lineinfile:
path: /etc/default/limine
regexp: '^BOOT_ORDER='
line: 'BOOT_ORDER="*bc250, *lts, *, *fallback, Snapshots"'
register: boot_order
- name: Install the BC-250 kernel and the fallback
become: true
community.general.pacman:
name:
- linux-cachyos-bc250
- linux-cachyos-bc250-headers
- linux-cachyos
- linux-cachyos-headers
state: present
register: kernel_pkg
- name: Regenerate Limine entries when only BOOT_ORDER changed
become: true
ansible.builtin.command: limine-mkinitcpio
when: boot_order.changed and not kernel_pkg.changed
changed_when: true
- name: Preselect the BC-250 kernel for the next boot
become: true
ansible.builtin.shell:
executable: /bin/bash
cmd: |
set -eu
EFIVAR=$(ls /sys/firmware/efi/efivars/LimineLastBootedEntry-*)
[ "$(tail -c +5 "$EFIVAR" | tr -d '\0')" = 'CachyOS/linux-cachyos-bc250' ] && exit 90
chattr -i "$EFIVAR"
printf '\x07\x00\x00\x00CachyOS/linux-cachyos-bc250\x00' > "$EFIVAR"
register: efivar_write
changed_when: efivar_write.rc == 0
failed_when: efivar_write.rc not in [0, 90]
- name: Reboot into the new kernel
become: true
ansible.builtin.reboot:
reboot_timeout: 600
when: kernel_pkg.changed or boot_order.changed or sys_upgrade.changed
- name: Re-gather kernel facts after reboot
ansible.builtin.setup:
filter: ansible_kernel
# Guards the removal below: never drop deckify unless we are already
# running the BC-250 kernel.
- name: Make sure the BC-250 kernel is the running one
ansible.builtin.assert:
that: "'bc250' in ansible_kernel"
fail_msg: "Running {{ ansible_kernel }}"
- name: Remove the deckify kernel
become: true
community.general.pacman:
name:
- linux-cachyos-deckify
- linux-cachyos-deckify-headers
state: absent
-10
View File
@@ -1,10 +0,0 @@
# Test Role
A brief description about the role...
## Variables
| Name | Is Required? | Default |
|:-------------------------------:|:------------:|:-------------:|
| `test_role__hello_world_string` | ✔️ | Hello, World! |
| `test_role__lorem_ipsum_string` | ❌ | |
-1
View File
@@ -1 +0,0 @@
test_role__hello_world_string: Hello, World!
-12
View File
@@ -1,12 +0,0 @@
- name: Ping
ansible.builtin.ping:
- name: Print an "Hello, World!"
ansible.builtin.debug:
msg: "{{ test_role__hello_world_string }}"
- name: Test the `ansible_managed` variable
ansible.builtin.template:
dest: /tmp/ansible.txt
src: ansible.txt.j2
mode: preserve
-3
View File
@@ -1,3 +0,0 @@
{{ ansible_managed | comment('plain') }}
{{ test_role__lorem_ipsum_string }}