Files
fedora-infra_ansible/roles/fedora-messaging-utils/tasks/crontab_path.yml
Nils Philippsen aa1f6ddbad Remove crontab validation
The crontab command only implements the `-T` option from version 1.5.6
of cronie but log01 has 1.5.2 (current release in RHEL 8.4).

Signed-off-by: Nils Philippsen <nils@redhat.com>
2021-09-22 18:29:27 +02:00

40 lines
1.1 KiB
YAML

#####################################################
# Ensure PATH in /etc/crontab contains /usr/local/bin
#####################################################
- name: check if PATH is set in crontab
lineinfile:
path: /etc/crontab
state: absent
regexp: '^PATH\s*='
check_mode: yes
changed_when: false
register: path_set_in_crontab
- name: add PATH if not set in crontab
lineinfile:
path: /etc/crontab
state: present
insertbefore: BOF
line: 'PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin'
when: not path_set_in_crontab.found
- name: check if PATH in crontab contains /usr/local/bin
lineinfile:
path: /etc/crontab
state: absent
regexp: '^PATH\s*=\s*(.*:)?/usr/local/bin(:.*)?\s*'
check_mode: yes
changed_when: false
register: local_in_path_in_crontab
when: path_set_in_crontab.found
- name: append /usr/local/bin to PATH in crontab if missing
lineinfile:
path: /etc/crontab
state: present
backrefs: yes
regexp: '^(PATH\s*=\s*(?:.*\S)?)\s*$'
line: '\1:/usr/local/bin'
when: path_set_in_crontab.found and not local_in_path_in_crontab.found