1
0
Fork 0

Fixed stupid ansible python sucks silent name collision

This commit is contained in:
Julien Dessaux 2021-03-04 13:38:44 +01:00
parent e19baa85fa
commit 2451b5ced3
3 changed files with 9 additions and 7 deletions

2
README
View file

@ -15,7 +15,7 @@ Here are some job examples :
- { name: mysqldump, command_to_pipe: "/usr/bin/mysqldump -h {{ mysql_server }} -u{{ ansible_hostname }} -p{{ ansible_local.mysql_client.password }} --single-transaction --add-drop-database -B {{ ansible_hostname }}" }
- { name: gitea, path: "/tmp/gitea.zip", pre_command: "echo '/usr/local/sbin/gitea -C /etc/gitea -c /etc/gitea/app.ini dump -f /tmp/gitea.zip' | su -l _gitea", post_command: "rm -f /tmp/gitea.zip" }
There is an action plugin that parses the borg_server entries from all hosts and set a flag to True in adyxax['is_borg_server'] for any machine specified as a backup target
There is an action plugin that parses the borg_server entries from all host_vars and set the borg.is_server fact to True for any machine specified as a backup target
Usefull commands:
=================

View file

@ -9,14 +9,16 @@ class ActionModule(ActionBase):
result['changed'] = False
result['failed'] = False
is_borg_server = False
is_server = False
for hostname, hostvars in task_vars['hostvars'].items() :
if 'borg_server' in hostvars.keys() and hostvars['borg_server'] == task_vars['ansible_host']:
is_borg_server = True
is_server = True
result['ansible_facts'] = {
'is_borg_server': is_borg_server,
'borg': {
'is_server': is_server,
}
}
return result

View file

@ -1,11 +1,11 @@
---
- action: init
- action: borg_init
- import_tasks: common.yml
when: is_borg_server or borg_server is defined
when: borg.is_server or borg_server is defined
- import_tasks: server.yml
when: is_borg_server
when: borg.is_server
- import_tasks: client.yml
when: borg_server is defined