cron: fix things (mostly about fcron)

Document PATH behavior for each crond implementation.
This commit is contained in:
Hoang Nguyen 2022-11-18 22:53:50 +07:00
parent 583f8ee265
commit 72f10a2bdc
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
4 changed files with 28 additions and 7 deletions

View File

@ -0,0 +1,5 @@
---
- name: Recompile fcron systab
command:
cmd: /usr/bin/fcrontab -z -u systab
removes: /var/spool/fcron/systab.orig

View File

@ -1,4 +1,6 @@
---
# busybox's crond already inherits PATH so no need to do anything.
# It doesn't have allow/deny feature though
- name: crond | Add crond service to runlevel 'default'
service:
name: crond

View File

@ -14,7 +14,8 @@
mode: 0644
# btrbk runs btrfs command directly (without specifying /sbin prefix),
# hence we need to inherit PATH here
# hence we need to inherit PATH here. Also log to syslog
# (the default PATH is /usr/local/bin:/bin:/usr/bin)
- name: cronie | Configure command options for cronie service
copy:
content: |

View File

@ -1,26 +1,39 @@
---
- name: fcron | Install fcron package
community.general.packaging.os.apk:
name: fcron
name: fcron, fcron-pam
state: present
- name: fcron | Deny all users except root to access crontabs
- name: fcron | Deny all users to access crontabs
copy:
content: |
all
dest: /etc/fcron/fcron.deny
owner: root
group: root
mode: 0644
group: fcron
mode: 0640
- name: fcron | Allow {{ username }} to access crontabs
- name: fcron | Allow {{ username }} and root to access crontabs
copy:
content: |
root
{{ username }}
dest: /etc/fcron/fcron.allow
owner: root
group: fcron
mode: 0640
# The default PATH is /bin:/usr/bin
- name: fcron | Set PATH inside system crontab (systab)
lineinfile:
path: /var/spool/fcron/systab.orig
line: "PATH=/bin:/usr/bin:/sbin:/usr/sbin"
insertbefore: BOF
mode: 0640
owner: root
group: root
mode: 0644
state: present
notify: Recompile fcron systab
- name: fcron | Start fcron service on runlevel default
service: