change to script user: zfs_health (#253)

Co-authored-by: Michael Grote <michael.grote@posteo.de>
Reviewed-on: mg/ansible#253
Co-authored-by: mg <michael.grote@posteo.de>
Co-committed-by: mg <michael.grote@posteo.de>
This commit is contained in:
Michael Grote 2021-11-24 11:54:31 +01:00
parent d2c425f014
commit 869131dabe
3 changed files with 32 additions and 4 deletions

View file

@ -1,3 +1,7 @@
---
### when should the script be run
zfs_extra_cron_minutes_zfs_health: "0,15,30,45"
zfs_extra_cron_hours_zfs_health: "*"
### under which user the script is run
zfs_health_user_group: "root"
zfs_health_user: "zfs-health"

View file

@ -1,16 +1,22 @@
---
- name: copy "zfs-health.sh"
- name: include user tasks
include_tasks: user.yml
- name: template script
become: yes
ansible.builtin.template:
src: zfs-health.sh
dest: /usr/local/bin/zfs-health.sh
mode: "+x"
mode: 0744
owner: "{{ zfs_health_user }}"
group: "{{ zfs_health_user_group }}"
- name: add cronjob "zfs-health.sh"
- name: ensure cronjob exists
become: yes
ansible.builtin.cron:
name: zfs-health
name: zfs_health
state: present
job: "/usr/local/bin/zfs-health.sh"
minute: "{{ zfs_extra_cron_minutes_zfs_health }}"
hour: "{{ zfs_extra_cron_hours_zfs_health }}"
user: "{{ zfs_health_user }}"

View file

@ -0,0 +1,18 @@
---
- name: ensure group exists
become: true
ansible.builtin.group:
name: "{{ zfs_health_user_group }}"
state: present
when:
- zfs_health_user_group is defined
- name: ensure user exists
become: true
ansible.builtin.user:
name: "{{ zfs_health_user }}"
group: "{{ zfs_health_user_group }}"
shell: /usr/sbin/nologin
when:
- zfs_health_user_group is defined
- zfs_health_user is defined