diff --git a/tasks/setup-desktop.yml b/tasks/setup-desktop.yml index ea1607e..ed97d53 100644 --- a/tasks/setup-desktop.yml +++ b/tasks/setup-desktop.yml @@ -1,111 +1 @@ -- name: remove the sysctl.d directory - become: true - file: - path: /etc/sysctl.d - state: absent - -- name: recreate the sysctl.d directory - become: true - file: - path: /etc/sysctl.d - state: directory - mode: 755 - -- name: copy sysctl files - become: true - template: - src: '{{ item.src }}' - dest: '{{ item.dest }}' - loop: - - { - src: 'templates/desktop/sysctl/99-sysrq.conf.j2', - dest: '/etc/sysctl.d/99-sysrq.conf' - } - - { - src: 'templates/desktop/sysctl/98-forward.conf.j2', - dest: '/etc/sysctl.d/98-foward.conf' - } - notify: reload sysctl configuration - -- name: remove the modprobe.d directory - become: true - file: - path: /etc/modprobe.d - state: absent - -- name: recreate the modprobe.d directory - become: true - file: - path: /etc/modprobe.d - state: directory - mode: 755 - -- name: copy modprobe files - become: true - template: - src: '{{ item.src }}' - dest: '{{ item.dest }}' - loop: - - { - src: 'templates/desktop/modprobe/99-amdgpu.conf.j2', - dest: '/etc/modprobe.d/99-amdgpu.conf' - } - -- name: remove the mkinitcpio directories - become: true - file: - path: '{{ item }}' - state: absent - loop: - - /etc/mkinitcpio.conf.d - - /etc/mkinitcpio.d - -- name: recreate the mkinitcpio directories - become: true - file: - path: '{{ item }}' - state: directory - mode: 755 - loop: - - /etc/mkinitcpio.conf.d - - /etc/mkinitcpio.d - -- name: copy mkinitcpio configuration files - become: true - template: - src: '{{ item.src }}' - dest: '{{ item.dest }}' - loop: - - { - src: 'templates/desktop/mkinitcpio/99-modules.conf.j2', - dest: '/etc/mkinitcpio.conf.d/99-amdgpu.conf' - } - - { - src: 'templates/desktop/mkinitcpio/linux.preset.j2', - dest: '/etc/mkinitcpio.d/linux.preset' - } - - { - src: 'templates/desktop/mkinitcpio/linux-lts.preset.j2', - dest: '/etc/mkinitcpio.d/linux-lts.preset' - } - - -- name: remove old initramfs files - become: true - file: - path: '{{ item }}' - state: absent - loop: - - /boot/initramfs-linux-lts-fallback.img - - /boot/initramfs-linux-fallback.img - -- name: regenerate initramfs images - become: true - command: 'mkinitcpio --allpresets' - register: mkinitcpio_stats - -- name: log mkinitcpio stdout - debug: - var: mkinitcpio_stats.stdout_lines - -# TODO: provision systemd-boot +--- diff --git a/tasks/setup-laptop.yml b/tasks/setup-laptop.yml index bc74a32..b6c81b1 100644 --- a/tasks/setup-laptop.yml +++ b/tasks/setup-laptop.yml @@ -1,134 +1,2 @@ # TODO: set fan settings to `quiet` with smbios-thermal-ctl -- name: remove the sysctl.d directory - become: true - file: - path: /etc/sysctl.d - state: absent - -- name: recreate the sysctl.d directory - become: true - file: - path: /etc/sysctl.d - state: directory - mode: 755 - -- name: copy sysctl files - become: true - template: - src: '{{ item.src }}' - dest: '{{ item.dest }}' - loop: - - { - src: 'templates/laptop/sysctl/99-sysrq.conf.j2', - dest: '/etc/sysctl.d/99-sysrq.conf' - } - - { - src: 'templates/laptop/sysctl/98-forward.conf.j2', - dest: '/etc/sysctl.d/98-foward.conf' - } - notify: reload sysctl configuration - -- name: remove the modprobe.d directory - become: true - file: - path: /etc/modprobe.d - state: absent - -- name: recreate the modprobe.d directory - become: true - file: - path: /etc/modprobe.d - state: directory - mode: 755 - -- name: copy kernel parameters template - become: true - template: - src: 'templates/laptop/cmdline.j2' - dest: '/etc/kernel/cmdline' - -- name: remove the mkinitcpio directories - become: true - file: - path: '{{ item }}' - state: absent - loop: - - /etc/mkinitcpio.conf.d - - /etc/mkinitcpio.d - -- name: recreate the mkinitcpio directories - become: true - file: - path: '{{ item }}' - state: directory - mode: 755 - loop: - - /etc/mkinitcpio.conf.d - - /etc/mkinitcpio.d - -- name: copy mkinitcpio configuration files - become: true - template: - src: '{{ item.src }}' - dest: '{{ item.dest }}' - loop: - - { - src: 'templates/laptop/mkinitcpio/99-modules.conf.j2', - dest: '/etc/mkinitcpio.conf.d/99-modules.conf' - } - - { - src: 'templates/laptop/mkinitcpio/99-hooks.conf.j2', - dest: '/etc/mkinitcpio.conf.d/99-hooks.conf' - } - - { - src: 'templates/laptop/mkinitcpio/linux.preset.j2', - dest: '/etc/mkinitcpio.d/linux.preset' - } - - { - src: 'templates/laptop/mkinitcpio/linux-lts.preset.j2', - dest: '/etc/mkinitcpio.d/linux-lts.preset' - } - -- name: regenerate initramfs images - become: true - command: 'mkinitcpio --allpresets' - register: mkinitcpio_stats - -- name: log mkinitcpio stdout - debug: - var: mkinitcpio_stats.stdout_lines - -- name: create a Linux UEFI boot entry - become: true - command: efibootmgr \ - --create \ - --disk /dev/nvme0n1 \ - --part 1 \ - --label 'Arch Linux' \ - --loader '\EFI\Linux\linux.efi'\ - --unicode - register: efi_linux_stats - when: register_uefi_entry - -- name: log efibootmgr stdout - debug: - var: efi_linux_stats.stdout_lines - when: register_uefi_entry - -- name: create a Linux LTS UEFI boot entry - become: true - command: efibootmgr \ - --create \ - --disk /dev/nvme0n1 \ - --part 1 \ - --label 'Arch Linux LTS' \ - --loader '\EFI\Linux\linux-lts.efi'\ - --unicode - register: efi_linux_lts_stats - when: register_uefi_entry - -- name: log efibootmgr LTS stdout - debug: - var: efi_linux_lts_stats.stdout_lines - when: register_uefi_entry diff --git a/tasks/setup.yml b/tasks/setup.yml index 44f56a7..0833f95 100644 --- a/tasks/setup.yml +++ b/tasks/setup.yml @@ -65,3 +65,131 @@ systemd: name: fstrim.timer enabled: true + +- name: remove the sysctl.d directory + become: true + file: + path: /etc/sysctl.d + state: absent + +- name: recreate the sysctl.d directory + become: true + file: + path: /etc/sysctl.d + state: directory + mode: 755 + +- name: copy sysctl files + become: true + template: + src: '{{ item.src }}' + dest: '{{ item.dest }}' + loop: + - { + src: 'templates/{{ platform }}/sysctl/99-sysrq.conf.j2', + dest: '/etc/sysctl.d/99-sysrq.conf' + } + - { + src: 'templates/{{ platform }}/sysctl/98-forward.conf.j2', + dest: '/etc/sysctl.d/98-foward.conf' + } + notify: reload sysctl configuration + +- name: remove the modprobe.d directory + become: true + file: + path: /etc/modprobe.d + state: absent + +- name: recreate the modprobe.d directory + become: true + file: + path: /etc/modprobe.d + state: directory + mode: 755 + +- name: copy modprobe configuration files + become: true + template: + src: '{{ item.src }}' + dest: '{{ item.dest }}' + loop: '{{ modprobe_templates }}' + when: modprobe_templates + +- name: copy kernel parameters template + become: true + template: + src: 'templates/{{ platform }}/cmdline.j2' + dest: '/etc/kernel/cmdline' + +- name: remove the mkinitcpio directories + become: true + file: + path: '{{ item }}' + state: absent + loop: + - /etc/mkinitcpio.conf.d + - /etc/mkinitcpio.d + +- name: recreate the mkinitcpio directories + become: true + file: + path: '{{ item }}' + state: directory + mode: 755 + loop: + - /etc/mkinitcpio.conf.d + - /etc/mkinitcpio.d + +- name: copy mkinitcpio configuration files + become: true + template: + src: '{{ item.src }}' + dest: '{{ item.dest }}' + loop: '{{ mkinitcpio_templates }}' + when: mkinitcpio_templates + +- name: regenerate initramfs images + become: true + command: 'mkinitcpio --allpresets' + register: mkinitcpio_stats + +- name: log mkinitcpio stdout + debug: + var: mkinitcpio_stats.stdout_lines + +- name: create a Linux UEFI boot entry + become: true + command: efibootmgr \ + --create \ + --disk '{{ boot_configuration.disk }}' \ + --part '{{ boot_configuration.partition }}' \ + --label 'Arch Linux' \ + --loader '\EFI\Linux\linux.efi'\ + --unicode + --index 0 + register: efi_linux_stats + when: register_uefi_entries + +- name: log efibootmgr stdout + debug: + var: efi_linux_stats.stdout_lines + when: register_uefi_entries + +- name: create a Linux LTS UEFI boot entry + become: true + command: efibootmgr \ + --create \ + --disk '{{ boot_configuration.disk }}' \ + --part '{{ boot_configuration.partition }}' \ + --label 'Arch Linux LTS' \ + --loader '\EFI\Linux\linux-lts.efi'\ + --unicode + --index 1 + register: efi_linux_lts_stats + when: register_uefi_entries + +- name: log efibootmgr LTS stdout + debug: + var: efi_linux_lts_stats.stdout_lines + when: register_uefi_entries diff --git a/templates/desktop/cmdline.j2 b/templates/desktop/cmdline.j2 new file mode 100644 index 0000000..08259b5 --- /dev/null +++ b/templates/desktop/cmdline.j2 @@ -0,0 +1 @@ +root=UUID=c5fe300d-97bf-476d-abd4-edfe7460bc81 rw bgrt_disable diff --git a/templates/desktop/mkinitcpio/99-modules.conf.j2 b/templates/desktop/mkinitcpio/1-modules.conf.j2 similarity index 100% rename from templates/desktop/mkinitcpio/99-modules.conf.j2 rename to templates/desktop/mkinitcpio/1-modules.conf.j2 diff --git a/templates/desktop/mkinitcpio/linux-lts.preset.j2 b/templates/desktop/mkinitcpio/linux-lts.preset.j2 index 175cda7..71d2550 100644 --- a/templates/desktop/mkinitcpio/linux-lts.preset.j2 +++ b/templates/desktop/mkinitcpio/linux-lts.preset.j2 @@ -4,6 +4,5 @@ PRESETS=('default') -default_config="/etc/mkinitcpio.conf" -default_image="/boot/initramfs-linux-lts.img" +default_uki="/boot/EFI/Linux/linux-lts.efi" default_kver="/boot/vmlinuz-linux-lts" diff --git a/templates/desktop/mkinitcpio/linux.preset.j2 b/templates/desktop/mkinitcpio/linux.preset.j2 index 8aceb4a..22097bb 100644 --- a/templates/desktop/mkinitcpio/linux.preset.j2 +++ b/templates/desktop/mkinitcpio/linux.preset.j2 @@ -4,6 +4,5 @@ PRESETS=('default') -default_config="/etc/mkinitcpio.conf" -default_image="/boot/initramfs-linux.img" +default_uki="/boot/EFI/Linux/linux.efi" default_kver="/boot/vmlinuz-linux" diff --git a/templates/laptop/mkinitcpio/99-modules.conf.j2 b/templates/laptop/mkinitcpio/1-modules.conf.j2 similarity index 100% rename from templates/laptop/mkinitcpio/99-modules.conf.j2 rename to templates/laptop/mkinitcpio/1-modules.conf.j2 diff --git a/templates/laptop/mkinitcpio/99-hooks.conf.j2 b/templates/laptop/mkinitcpio/2-hooks.conf.j2 similarity index 100% rename from templates/laptop/mkinitcpio/99-hooks.conf.j2 rename to templates/laptop/mkinitcpio/2-hooks.conf.j2 diff --git a/vars/desktop.yml b/vars/desktop.yml index 66792c9..fc9fc0f 100644 --- a/vars/desktop.yml +++ b/vars/desktop.yml @@ -1,5 +1,29 @@ platform_packages: [] +modprobe_templates: + - { + src: 'templates/desktop/modprobe/99-amdgpu.conf.j2', + dest: '/etc/modprobe.d/99-amdgpu.conf' + } + +mkinitcpio_templates: + - { + src: 'templates/desktop/mkinitcpio/1-modules.conf.j2', + dest: '/etc/mkinitcpio.conf.d/1-amdgpu.conf' + } + - { + src: 'templates/desktop/mkinitcpio/linux.preset.j2', + dest: '/etc/mkinitcpio.d/linux.preset' + } + - { + src: 'templates/desktop/mkinitcpio/linux-lts.preset.j2', + dest: '/etc/mkinitcpio.d/linux-lts.preset' + } + +boot_configuration: + disk: /dev/sdc + partition: 1 + vpn_default: ip: '10.0.0.3' subnet: '24' diff --git a/vars/laptop.yml b/vars/laptop.yml index cf815f4..0b8c907 100644 --- a/vars/laptop.yml +++ b/vars/laptop.yml @@ -4,10 +4,28 @@ platform_packages: - nvidia-prime - nvidia-utils - lib32-nvidia-utils - - systemd-ukify - - efibootmgr -register_uefi_entry: false +boot_configuration: + disk: /dev/nvme0n1 + partition: 1 + +mkinitcpio_templates: + - { + src: 'templates/laptop/mkinitcpio/1-modules.conf.j2', + dest: '/etc/mkinitcpio.conf.d/1-modules.conf' + } + - { + src: 'templates/laptop/mkinitcpio/2-hooks.conf.j2', + dest: '/etc/mkinitcpio.conf.d/2-hooks.conf' + } + - { + src: 'templates/laptop/mkinitcpio/linux.preset.j2', + dest: '/etc/mkinitcpio.d/linux.preset' + } + - { + src: 'templates/laptop/mkinitcpio/linux-lts.preset.j2', + dest: '/etc/mkinitcpio.d/linux-lts.preset' + } vpn_default: ip: '10.0.0.2' diff --git a/vars/main.yml b/vars/main.yml index daecfe9..9f8d919 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,6 +1,8 @@ xdg_config_dir: '{{ ansible_env.HOME }}/.config' xdg_script_dir: '{{ ansible_env.HOME }}/.local/bin' +register_uefi_entries: false + packages: - firefox - mpv @@ -30,5 +32,11 @@ packages: - pipewire-alsa - wireguard-tools - otf-monaspace-nerd + - systemd-ukify + - efibootmgr platform_packages: [] +modprobe_templates: [] +mkinitcpio_templates: [] + +boot_configuration: