diff --git a/playbook.yml b/playbook.yml index 58b39da..dc93465 100644 --- a/playbook.yml +++ b/playbook.yml @@ -15,6 +15,10 @@ - common tasks: - import_tasks: 'tasks/setup.yml' + - import_tasks: 'tasks/setup-desktop.yml' + when: platform == 'desktop' + - import_tasks: 'tasks/setup-laptop.yml' + when: platform == 'laptop' - import_tasks: 'tasks/network.yml' - import_tasks: 'tasks/systemd.yml' - import_tasks: 'tasks/git.yml' diff --git a/tasks/setup-desktop.yml b/tasks/setup-desktop.yml new file mode 100644 index 0000000..ea1607e --- /dev/null +++ b/tasks/setup-desktop.yml @@ -0,0 +1,111 @@ +- 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 new file mode 100644 index 0000000..69828e3 --- /dev/null +++ b/tasks/setup-laptop.yml @@ -0,0 +1,18 @@ +# TODO: set fan settings to `quiet` with smbios-thermal-ctl +# TODO: provision mkinitcpio +# TODO: provision modprobe +# TODO: provision sysctl? +# +- name: create udev rule + become: true + file: + path: '/etc/udev/rules.d/00-remove-nvidia.rules' + state: absent + +- name: blacklist kernel module + become: true + file: + path: '/etc/modprobe.d/blacklist-nouveau.conf' + state: absent + owner: root + group: root diff --git a/tasks/setup.yml b/tasks/setup.yml index c133d37..44f56a7 100644 --- a/tasks/setup.yml +++ b/tasks/setup.yml @@ -65,72 +65,3 @@ systemd: name: fstrim.timer enabled: true - -- block: - - 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' - } - when: platform == 'desktop' - -# TODO: set fan settings to `quiet` with smbios-thermal-ctl - -- name: remove old configuration files - block: - - name: create udev rule - become: true - file: - path: '/etc/udev/rules.d/00-remove-nvidia.rules' - state: absent - - name: blacklist kernel module - become: true - file: - path: '/etc/modprobe.d/blacklist-nouveau.conf' - state: absent - owner: root - group: root - when: platform == 'laptop' diff --git a/templates/desktop/mkinitcpio/99-modules.conf.j2 b/templates/desktop/mkinitcpio/99-modules.conf.j2 new file mode 100644 index 0000000..82581fb --- /dev/null +++ b/templates/desktop/mkinitcpio/99-modules.conf.j2 @@ -0,0 +1,3 @@ +# {{ ansible_managed }} + +MODULES=(amdgpu) diff --git a/templates/desktop/mkinitcpio/linux-lts.preset.j2 b/templates/desktop/mkinitcpio/linux-lts.preset.j2 new file mode 100644 index 0000000..175cda7 --- /dev/null +++ b/templates/desktop/mkinitcpio/linux-lts.preset.j2 @@ -0,0 +1,9 @@ +# {{ ansible_managed }} +# +# mkinitcpio preset file for the 'linux' package + +PRESETS=('default') + +default_config="/etc/mkinitcpio.conf" +default_image="/boot/initramfs-linux-lts.img" +default_kver="/boot/vmlinuz-linux-lts" diff --git a/templates/desktop/mkinitcpio/linux.preset.j2 b/templates/desktop/mkinitcpio/linux.preset.j2 new file mode 100644 index 0000000..8aceb4a --- /dev/null +++ b/templates/desktop/mkinitcpio/linux.preset.j2 @@ -0,0 +1,9 @@ +# {{ ansible_managed }} +# +# mkinitcpio preset file for the 'linux' package + +PRESETS=('default') + +default_config="/etc/mkinitcpio.conf" +default_image="/boot/initramfs-linux.img" +default_kver="/boot/vmlinuz-linux"