Browse Source

ssh optional

Fabian Peter Hammerle 7 years ago
parent
commit
3782e130a6
1 changed files with 5 additions and 1 deletions
  1. 5 1
      tasks/main.yml

+ 5 - 1
tasks/main.yml

@@ -4,8 +4,12 @@
 - name: generate commands
   set_fact:
     # escape %
+    # $command .= ' | sed \'s/ AUTO_INCREMENT=[0-9]*\b//\'';
     backup_command: |-
-      ssh -i {{item.ssh_key_path}} {{item.ssh_user}}@{{item.source_host}} /usr/bin/mysqldump --opt --order-by-primary --skip-dump-date {{item.database}} | sed 's$),($),\n($g' >"{{item.target_dir_path}}/$(date -u +'\%Y-\%m-\%dT\%H:\%M:\%SZ').sql"
+      {% if item.source_host is defined %}
+      ssh -i {{item.ssh_key_path}} {{item.ssh_user}}@{{item.source_host}}
+      {%- endif %}
+       /usr/bin/mysqldump --opt --order-by-primary --skip-dump-date {{item.database}} | sed 's$),($),\n($g' >"{{item.target_dir_path}}/$(date -u +'\%Y-\%m-\%dT\%H:\%M:\%SZ').sql"
   with_items: '{{mysql_backups}}'
   register: mysql_backup_commands
 - name: setup cron jobs