generated from nicolabelluti/template-ansible
85 lines
2.5 KiB
YAML
85 lines
2.5 KiB
YAML
- 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
|