91 lines
2.6 KiB
YAML
91 lines
2.6 KiB
YAML
---
|
|
- name: Check if zfs-linux-lts is installed
|
|
ansible.builtin.command: pacman -Qi zfs-dkms
|
|
register: zfs_dkms_installed
|
|
changed_when: false
|
|
failed_when: false
|
|
|
|
- name: Install zfs
|
|
when: zfs_dkms_installed.stderr
|
|
block:
|
|
- name: Disable SUDOERS password prompt for makepkg
|
|
no_log: true
|
|
ansible.builtin.lineinfile:
|
|
dest: /etc/sudoers
|
|
state: present
|
|
regexp: "^#?%wheel"
|
|
line: "%wheel ALL=(ALL) NOPASSWD: ALL"
|
|
validate: /usr/sbin/visudo -cf %s
|
|
|
|
# Note: I successfully tried zfs-linux-lts and zfs-linux-lts-headers, but
|
|
# the next kernel upgrade failed: cyclic dependency.
|
|
# Using dkms with the lts linux kernel is a better approach IMO.
|
|
- name: Install zfs
|
|
become: false
|
|
ansible.builtin.command:
|
|
cmd: "paru -S --noconfirm zfs-dkms zfs-utils"
|
|
|
|
- name: Restore SUDOERS password prompt after yay
|
|
no_log: true
|
|
ansible.builtin.lineinfile:
|
|
dest: /etc/sudoers
|
|
state: present
|
|
regexp: "^#?%wheel"
|
|
line: "%wheel ALL=(ALL:ALL) ALL"
|
|
validate: /usr/sbin/visudo -cf %s
|
|
|
|
- name: Check if /etc/hostid is present
|
|
ansible.builtin.stat:
|
|
path: /etc/hostid
|
|
register: hostid
|
|
changed_when: false
|
|
|
|
- name: Generate /etc/hostid if not present
|
|
when: not hostid.stat.exists
|
|
ansible.builtin.command: zgenhostid $(hostid)
|
|
- name: Check if zrepl is installed
|
|
ansible.builtin.command: pacman -Qi zrepl
|
|
register: zrepl_installed
|
|
changed_when: false
|
|
failed_when: false
|
|
|
|
- name: Install zrepl
|
|
when: zrepl_installed.stderr
|
|
block:
|
|
- name: Disable SUDOERS password prompt for makepkg
|
|
no_log: true
|
|
ansible.builtin.lineinfile:
|
|
dest: /etc/sudoers
|
|
state: present
|
|
regexp: "^#?%wheel"
|
|
line: "%wheel ALL=(ALL) NOPASSWD: ALL"
|
|
validate: /usr/sbin/visudo -cf %s
|
|
|
|
- name: Install zrepl
|
|
become: false
|
|
ansible.builtin.command:
|
|
cmd: "paru -S --noconfirm zrepl"
|
|
|
|
- name: Restore SUDOERS password prompt after paru
|
|
no_log: true
|
|
ansible.builtin.lineinfile:
|
|
dest: /etc/sudoers
|
|
state: present
|
|
regexp: "^#?%wheel"
|
|
line: "%wheel ALL=(ALL:ALL) ALL"
|
|
validate: /usr/sbin/visudo -cf %s
|
|
|
|
- name: Enable zfs services
|
|
ansible.builtin.service:
|
|
name: "{{ item }}"
|
|
enabled: true
|
|
state: started
|
|
loop:
|
|
- zfs.target
|
|
- zfs-import.target
|
|
- zfs-volumes.target
|
|
- zfs-import-scan.service
|
|
- zfs-volume-wait.service
|
|
# Please note /etc/zfs/zpool.cache should not be present, as it is deprecated
|
|
# and we are using zfs-import-scan.service, which rely on blkid.
|