How to restore from backup for synchronize module if service fails to start

26 views
Skip to first unread message

Vikram Kone

unread,
Mar 15, 2016, 12:25:03 PM3/15/16
to Ansible Project
Hi,
I'm new to ansible, so looking for some pointers or samples.
I have a directory of monit conf files on my ansible server that I want to send to remote hosts using synchronize module.
Once I synchronize the conf directory, I want to reload monit. If monit fails to start due to syntax errors in the conf files, then I want to restore the original conf files that are working before from backup.
I couldn't figure out how to do this last step. any pointers?

This is what I have so far

---
- hosts: remote_hosts
  gather_facts: false
  tasks:
   - name: rsync monit configruation files
     synchronize: src=/home/foo/conf/ dest=/opt/monit/conf/ backup=yes
     notify: reload monit
  handlers:
    - name: reload monit
      service: name=monit state=reloaded


Reply all
Reply to author
Forward
0 new messages