Skip to content

Commit

Permalink
roles/zfs: implement removal
Browse files Browse the repository at this point in the history
Signed-off-by: John Helmert III <[email protected]>
  • Loading branch information
ajakk committed Nov 15, 2023
1 parent 7e7d655 commit 68b032c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
14 changes: 14 additions & 0 deletions roles/zfs/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
---
zfs_cronjobs:
- cron.d/zfs-auto-snapshot
- cron.hourly/zfs-auto-snapshot
- cron.daily/zfs-auto-snapshot
- cron.weekly/zpool-scrub
- cron.weekly/zfs-auto-snapshot
- cron.monthly/zfs-auto-snapshot
zfs_services:
- zfs-import-cache.service
- zfs-mount.service
- zfs-share.service
- zfs-zed.service
- zfs-volume-wait.service
- zfs.target
zfs: false
20 changes: 6 additions & 14 deletions roles/zfs/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,18 @@
when: zfs
ansible.builtin.copy:
src: etc/{{ item }}
dest: /etc
dest: /etc/{{ item }}
owner: root
group: root
mode: "0744"
with_items:
- cron.d
- cron.hourly
- cron.daily
- cron.weekly
- cron.monthly
with_items: "{{ zfs_cronjobs }}"
- name: Start and enable zfs services
when: zfs
ansible.builtin.service:
name: "{{ item }}"
state: started
enabled: true
loop:
- zfs-import-cache.service
- zfs-mount.service
- zfs-share.service
- zfs-zed.service
- zfs-volume-wait.service
- zfs.target
loop: "{{ zfs_services }}"
- name: Remove zfs configuration
when: not zfs
ansible.builtin.include_tasks: remove.yml
12 changes: 12 additions & 0 deletions roles/zfs/tasks/remove.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: Remove zfs cron jobs
ansible.builtin.file:
path: "/etc/{{ item }}"
state: absent
with_items: "{{ zfs_cronjobs }}"
- name: Stop and disable zfs services
ansible.builtin.service:
name: "{{ item }}"
state: stopped
enabled: false
loop: "{{ zfs_services }}"

0 comments on commit 68b032c

Please sign in to comment.