Last active
April 23, 2017 20:51
-
-
Save rodrigoSyscop/8a47b48e399e3c9349a4c610692a6546 to your computer and use it in GitHub Desktop.
Search for bkpus in multiple servers, if found put on the list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# first play just check for backups | |
- hosts: srvA srvB srvC srvD | |
gather_facts: no | |
vars: | |
file: '/etc/not-sync.txt' | |
vars_prompt: | |
- name: 'client' | |
prompt: 'CLIENT' | |
private: no | |
tasks: | |
- name: check if there is a CLIENT backup | |
find: | |
paths: "/mnt/data/bkps/mysql" | |
file_type: file | |
age: "-1d" | |
recurse: yes | |
patterns: "*{{ client }}.tgz" | |
register: found | |
changed_when: found.matched|int > 0 | |
notify: "insert the CLIENT in the NOT sync list" | |
- debug: | |
msg: "{{ found.files.0.path }} found" | |
when: found.files.0 is defined | |
handlers: | |
- name: insert the CLIENT in the NOT sync list | |
lineinfile: | |
dest: '{{ file }}' | |
regexp: '/{{ client }}/' | |
line: '/{{ client }}/' | |
delegate_to: controller0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment