Skip to content

Commit

Permalink
roles/single: update cron presence check
Browse files Browse the repository at this point in the history
Check if `crontab` file exists as it is possible that OS has a package named differently from default "cron". Checking against binary name presence is safer and expected to cover all cases.

Signed-off-by: Zakhar Bessarab <[email protected]>
  • Loading branch information
zekker6 committed Feb 23, 2024
1 parent e60e87c commit 2fdb317
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 2 additions & 6 deletions roles/single/tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,10 @@
name: victoriametrics
enabled: true

- name: Gather package facts
ansible.builtin.package_facts:
manager: auto

- name: Configure credentials
when:
- victoriametrics_backup_enabled | bool
- "'cron' in ansible_facts.packages"
- crontab_which.rc == 0
block:
- name: Create aws credentials dir
become: true
Expand Down Expand Up @@ -105,4 +101,4 @@
state: absent
when:
- not victoriametrics_backup_enabled | bool
- "'cron' in ansible_facts.packages"
- crontab_which.rc == 0
7 changes: 7 additions & 0 deletions roles/single/tasks/preinstall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@
check_mode: false
register: victoriametrics_current_version
when: victoriametrics_is_installed.stat.exists | bool

- name: Check if crontab is present
ansible.builtin.raw: which crontab
check_mode: false
changed_when: false
failed_when: false
register: crontab_which

0 comments on commit 2fdb317

Please sign in to comment.