VictoriaMetrics / ansible-playbooks

Ansible Playbooks for Victoria Metrics monorepo
Apache License 2.0
99 stars 34 forks source link

VM single role: doesn't work on systems without cron, even when backups are not enabled #52

Closed kennethso168 closed 8 months ago

kennethso168 commented 8 months ago

The culprit:

https://github.com/VictoriaMetrics/ansible-playbooks/blob/db4e16e4428e4a2cd87675762d5ecf4108e857a5/roles/single/tasks/configure.yml#L90

I believe that as the roles configured VictoriaMetrics to be run as SystemD service, the backup timers should be migrated from using cron to systemd timers as well.

But as I don't need backups for now, a quicker fix may be to just adjust the conditions to skip this when there is no cron on the system.

zekker6 commented 8 months ago

Hello @kennethso168 Release v0.52.0 addressed this issue, could you verify if that helps in your case?

kennethso168 commented 8 months ago

Thanks @zekker6. I have tested v0.52.0 on my system without cron and the playbook ran successfully.

However, I had a look of the fix in fbb63b59d3773fc081a9fe3104d0dd48fe936544 and I noticed that there might be issues for this check:

  when:
    - not victoriametrics_backup_enabled | bool
    - "'cron' in ansible_facts.packages"

The deletion of backup drops will be skipped when there is cron in the installed packages. But in fact there are multiple cron implementations with different package names. For example, on Debian there are also bcron and systemd-cron apart from the simple cron. On Arch linux there are cronie, fcron, etc. This would break if user don't have the exact package called cron installed on the system.

A better way maybe to check whether the command crontab exists (or whether there is an executable named crontab in $PATH, as the ansible module mainly used the crontab command for its functionality. https://github.com/ansible/ansible/blob/1b209d742e39900e676e6a43f900801e67cc9154/lib/ansible/modules/cron.py#L240

zekker6 commented 8 months ago

@kennethso168 Thank you for the suggestion, it was implemented in 2fdb31787580c27098ddb6e64be9ec45e1c1802b.