Files
fedora-infra_ansible/roles/fedora-messaging-utils/tasks/crontab_path.yml
Ryan Lerch 691adee6ee Fix name[casing] ansible-lint issues
fix 1900 failures of the following case issue:

`name[casing]: All names should start with an uppercase letter.`

Signed-off-by: Ryan Lerch <rlerch@redhat.com>
2025-01-14 20:20:07 +10:00

41 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