chore: ansible-lint
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
---
|
||||
# due to Ansible limitations, we cannot loop over a block, so we loop over a distinct tasks file...
|
||||
# @see https://stackoverflow.com/a/58911694
|
||||
- name: set ownership on dataset mountpoint
|
||||
- name: Set ownership on dataset mountpoint
|
||||
block:
|
||||
- name: get the mountpoint
|
||||
ansible.builtin.shell: "zfs get -H -o value mountpoint {{ dataset.name }}"
|
||||
- name: Get the mountpoint
|
||||
ansible.builtin.command: "zfs get -H -o value mountpoint {{ dataset.name }}"
|
||||
register: mountpoint
|
||||
changed_when: false
|
||||
- name: set owner of mountpoints
|
||||
file:
|
||||
- name: Set owner of mountpoints
|
||||
ansible.builtin.file:
|
||||
path: "{{ mountpoint.stdout }}"
|
||||
owner: "{{ dataset.user | default(main_user) }}"
|
||||
group: "{{ dataset.group | default(main_user) }}"
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
---
|
||||
# see: https://docs.ansible.com/ansible/latest/collections/community/general/zfs_module.html
|
||||
- name: managing filesystems, volumes, snapshots
|
||||
zfs:
|
||||
- name: Managing filesystems, volumes, snapshots
|
||||
community.general.zfs:
|
||||
name: "{{ item.name }}"
|
||||
state: "{{ item.state }}"
|
||||
extra_zfs_properties: "{{ item.extra_zfs_properties|default(omit) }}"
|
||||
origin: "{{ item.origin|default(omit) }}"
|
||||
extra_zfs_properties: "{{ item.extra_zfs_properties | default(omit) }}"
|
||||
origin: "{{ item.origin | default(omit) }}"
|
||||
with_items: "{{ zfs_datasets }}"
|
||||
|
||||
- command:
|
||||
- ansible.builtin.command:
|
||||
cmd: whoami
|
||||
no_log: true
|
||||
become: false
|
||||
register: main_user
|
||||
|
||||
- set_fact:
|
||||
- ansible.builtin.set_fact:
|
||||
main_user: "{{ main_user.stdout }}"
|
||||
no_log: true
|
||||
|
||||
- name: set dataset ownership
|
||||
include_tasks: "./dataset-ownership.yml"
|
||||
- name: Set dataset ownership
|
||||
ansible.builtin.include_tasks: "./dataset-ownership.yml"
|
||||
loop: "{{ zfs_datasets }}"
|
||||
loop_control:
|
||||
loop_var: dataset
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
---
|
||||
# due to Ansible limitations, we cannot loop over a block, so we loop over a distinct tasks file...
|
||||
# @see https://stackoverflow.com/a/58911694
|
||||
- name: prompt the user for confirmation
|
||||
- name: Prompt the user for confirmation
|
||||
ansible.builtin.pause:
|
||||
prompt: "[IRREVERSIBLE] Are you sure you want to delete zpool {{ zpool.name }}?"
|
||||
echo: yes
|
||||
echo: true
|
||||
register: confirmation
|
||||
|
||||
- name: deleting zpool
|
||||
- name: Deleting zpool
|
||||
ansible.builtin.command: "zpool destroy {{ zpool.name }}"
|
||||
when: confirmation.user_input | lower in ['yes', 'y']
|
||||
|
||||
+15
-16
@@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: Check if zfs-linux-lts is installed
|
||||
command: pacman -Qi zfs-dkms
|
||||
ansible.builtin.command: pacman -Qi zfs-dkms
|
||||
register: zfs_dkms_installed
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
@@ -8,9 +8,9 @@
|
||||
- name: Install zfs
|
||||
when: zfs_dkms_installed.stderr
|
||||
block:
|
||||
- name: disable SUDOERS password prompt for makepkg
|
||||
- name: Disable SUDOERS password prompt for makepkg
|
||||
no_log: true
|
||||
lineinfile:
|
||||
ansible.builtin.lineinfile:
|
||||
dest: /etc/sudoers
|
||||
state: present
|
||||
regexp: "^#?%wheel"
|
||||
@@ -22,30 +22,29 @@
|
||||
# Using dkms with the lts linux kernel is a better approach IMO.
|
||||
- name: Install zfs
|
||||
become: false
|
||||
command:
|
||||
ansible.builtin.command:
|
||||
cmd: "paru -S --noconfirm zfs-dkms zfs-utils"
|
||||
|
||||
- name: Restore SUDOERS password prompt after yay
|
||||
no_log: true
|
||||
lineinfile:
|
||||
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
|
||||
stat:
|
||||
- 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
|
||||
- name: Generate /etc/hostid if not present
|
||||
when: not hostid.stat.exists
|
||||
command: zgenhostid $(hostid)
|
||||
|
||||
ansible.builtin.command: zgenhostid $(hostid)
|
||||
- name: Check if zrepl is installed
|
||||
command: pacman -Qi zrepl
|
||||
ansible.builtin.command: pacman -Qi zrepl
|
||||
register: zrepl_installed
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
@@ -53,9 +52,9 @@
|
||||
- name: Install zrepl
|
||||
when: zrepl_installed.stderr
|
||||
block:
|
||||
- name: disable SUDOERS password prompt for makepkg
|
||||
- name: Disable SUDOERS password prompt for makepkg
|
||||
no_log: true
|
||||
lineinfile:
|
||||
ansible.builtin.lineinfile:
|
||||
dest: /etc/sudoers
|
||||
state: present
|
||||
regexp: "^#?%wheel"
|
||||
@@ -64,12 +63,12 @@
|
||||
|
||||
- name: Install zrepl
|
||||
become: false
|
||||
command:
|
||||
ansible.builtin.command:
|
||||
cmd: "paru -S --noconfirm zrepl"
|
||||
|
||||
- name: Restore SUDOERS password prompt after paru
|
||||
no_log: true
|
||||
lineinfile:
|
||||
ansible.builtin.lineinfile:
|
||||
dest: /etc/sudoers
|
||||
state: present
|
||||
regexp: "^#?%wheel"
|
||||
@@ -77,7 +76,7 @@
|
||||
validate: /usr/sbin/visudo -cf %s
|
||||
|
||||
- name: Enable zfs services
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: "{{ item }}"
|
||||
enabled: true
|
||||
state: started
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
---
|
||||
- name: Install ZFS
|
||||
include_tasks: install.yml
|
||||
|
||||
ansible.builtin.include_tasks: install.yml
|
||||
- name: Configure Zpools
|
||||
include_tasks: pools.yml
|
||||
|
||||
ansible.builtin.include_tasks: pools.yml
|
||||
- name: "Setup ZFS datasets: filesystems, snapshots, volumes"
|
||||
include_tasks: datasets.yml
|
||||
ansible.builtin.include_tasks: datasets.yml
|
||||
|
||||
+13
-11
@@ -3,21 +3,22 @@
|
||||
# Based on: https://github.com/mrlesmithjr/ansible-zfs/blob/master/tasks/manage_zfs.yml
|
||||
# Expected variables in your inventory: zfs_pools.
|
||||
|
||||
- name: checking existing zpool(s)
|
||||
ansible.builtin.shell: "zpool list -H -o name"
|
||||
- name: Checking existing zpool(s)
|
||||
ansible.builtin.command: "zpool list -H -o name"
|
||||
changed_when: false
|
||||
register: current_zp_state
|
||||
check_mode: no
|
||||
check_mode: false
|
||||
when: zfs_pools is defined
|
||||
|
||||
- name: gather zpool status
|
||||
ansible.builtin.shell: zpool status
|
||||
- name: Gather zpool status
|
||||
ansible.builtin.command: zpool status
|
||||
changed_when: false
|
||||
register: zpool_devices
|
||||
when: zfs_pools is defined
|
||||
|
||||
- name: creating basic zpool(s)
|
||||
ansible.builtin.command: "zpool create {{ '-o '+ item.options.items() |map('join', '=') | join (' -o ') if item.options is defined else '' }} {{ item.name }} {{ item.devices|join (' ') }}"
|
||||
- name: Creating basic zpool(s)
|
||||
ansible.builtin.command: "zpool create {{ '-o '+ item.options.items() |map('join', '=') | join (' -o ') if item.options is defined else '' }} {{ item.name }} {{
|
||||
item.devices|join (' ') }}"
|
||||
with_items: "{{ zfs_pools }}"
|
||||
when:
|
||||
- zfs_pools is defined
|
||||
@@ -26,8 +27,9 @@
|
||||
- item.state == "present"
|
||||
- item.devices[0] not in zpool_devices.stdout
|
||||
|
||||
- name: creating mirror/zraid zpool(s)
|
||||
ansible.builtin.command: "zpool create {{ '-o '+ item.options.items() |map('join', '=') | join (' -o ') if item.options is defined else '' }} {{ item.name }} {{ item.type }} {{ item.devices|join (' ') }}"
|
||||
- name: Creating mirror/zraid zpool(s)
|
||||
ansible.builtin.command: "zpool create {{ '-o '+ item.options.items() |map('join', '=') | join (' -o ') if item.options is defined else '' }} {{ item.name }} {{
|
||||
item.type }} {{ item.devices|join (' ') }}"
|
||||
with_items: "{{ zfs_pools }}"
|
||||
when:
|
||||
- zfs_pools is defined
|
||||
@@ -36,8 +38,8 @@
|
||||
- item.state == "present"
|
||||
- item.devices[0] not in zpool_devices.stdout
|
||||
|
||||
- name: deleting zpool(s) with care
|
||||
include_tasks: "./delete-pool.yml"
|
||||
- name: Deleting zpool(s) with care
|
||||
ansible.builtin.include_tasks: "./delete-pool.yml"
|
||||
when:
|
||||
- zfs_pools is defined
|
||||
- zpool.name in current_zp_state.stdout_lines
|
||||
|
||||
Reference in New Issue
Block a user