diff --git a/localhost.yml b/localhost.yml index 67b5fff..0986417 100644 --- a/localhost.yml +++ b/localhost.yml @@ -2,6 +2,7 @@ - hosts: localhost roles: - prepare + - systemd-boot - ubuntu - ubuntu-java - ubuntu-firefox diff --git a/roles/systemd-boot/tasks/arch.yml b/roles/systemd-boot/tasks/arch.yml new file mode 100644 index 0000000..09ff836 --- /dev/null +++ b/roles/systemd-boot/tasks/arch.yml @@ -0,0 +1,69 @@ +--- +- name: "[Arch] install efi drivers for ext4" + become: yes + community.general.pacman: + update_cache: yes + name: + - efifs + +- name: "[Arch] Install systemd-boot" + become: yes + shell: + cmd: | + bootctl --esp-path {{ efs }} --boot-path {{ boot }} install + +- name: "[Arch] Copy ext4 driver to systemd drivers" + become: yes + copy: + remote_src: true + content: /usr/lib/efifs-x64/ext2_x64.efi + dest: "{{ efs }}/EFI/systemd/drivers/ext2_x64.efi" + +- name: "[Arch] Add main entry" + become: yes + template: + src: loader/entries/arch.conf.j2 + dest: "{{ boot }}/loader/entries/arch.conf" + vars: + name: "" + variant: "" + version: "linux" + +- name: "[Arch] Add fallback entry" + become: yes + template: + src: loader/entries/arch.conf.j2 + dest: "{{ boot }}/loader/entries/arch-fallback.conf" + vars: + name: " Fallback" + variant: "-fallback" + version: "linux" + +- name: "[Arch] Check if lts kernel is installed" + stat: + path: "{{ boot }}/vmlinuz-linux-lts" + register: lts_kernel + +- name: "[Arch] Add lts entry" + become: yes + template: + src: loader/entries/arch.conf.j2 + dest: "{{ boot }}/loader/entries/arch-lts.conf" + vars: + name: " LTS" + variant: "" + version: "linux-lts" + when: + - lts_kernel.stat.exists + +- name: "[Arch] Add lts fallback entry" + become: yes + template: + src: loader/entries/arch.conf.j2 + dest: "{{ boot }}/loader/entries/arch-lts-fallback.conf" + vars: + name: " LTS Fallback" + variant: "-fallback" + version: "linux-lts" + when: + - lts_kernel.stat.exists diff --git a/roles/systemd-boot/tasks/main.yml b/roles/systemd-boot/tasks/main.yml new file mode 100644 index 0000000..6d32278 --- /dev/null +++ b/roles/systemd-boot/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- import_tasks: arch.yml + when: ansible_distribution == "Archlinux" diff --git a/roles/systemd-boot/templates/loader/entries/arch.conf.j2 b/roles/systemd-boot/templates/loader/entries/arch.conf.j2 new file mode 100644 index 0000000..1930a6a --- /dev/null +++ b/roles/systemd-boot/templates/loader/entries/arch.conf.j2 @@ -0,0 +1,4 @@ +title Arch Linux{{ name }} +linux /vmlinuz-{{ version }} +initrd /initramfs-{{ version }}{{ variant }}.img +options root={{ root }} cryptdevice={{ cryptdevice }} {{ options }} diff --git a/roles/systemd-boot/vars/main.yml b/roles/systemd-boot/vars/main.yml new file mode 100644 index 0000000..36632b8 --- /dev/null +++ b/roles/systemd-boot/vars/main.yml @@ -0,0 +1,6 @@ +--- +root: /dev/mapper/vgubuntu-root +cryptdevice: /dev/nvme0n1p3:cryptlvm +options: rw add_efi_memmap amd_pstate=active loglevel=3 +boot: /boot +efs: /boot/efi