That's it! Thank you! To avoid being "that guy", here is the working playbook:
--- - hosts: dbserver remote_user: jlouthan tasks: - name: Get current timestamp local_action: command bash -c 'date +%Y-%m-%d.%H%M' # Consider switch this to a shell module with date command register: timestamp run_once: true - debug: var=timestamp.stdout - name: Get current datestamp local_action: command bash -c 'date +%Y-%m-%d' # Consider switch this to a shell module with date command register: datestamp run_once: true - debug: var=datestamp.stdout - name: Backup dbname Database mysql_db: "state=dump name=dbname target=~jlouthan/dbname.{{ timestamp.stdout }}.sql" become: yes become_method: sudo - name: See the DB Backups shell: ls -la ~jlouthan/ | grep {{ datestamp.stdout }} register: dumpdb - debug: var=dumpdb.stdout_lines - name: Make sure that the dbname DB Backups look good before you continue pause: This playbook: 1. *Gets current date and time stamps from the remote machine (as oppose to the local machine that is running Ansible*. Something to keep in mind if you have servers in different timezones) - *Note: the debug lines for date and time stamps are merely there for me to see what stamp should I be seeing* 2. *Backup database using the timestamp within the resulting file name* 3. *Double check using just the datestamp (as oppose to the fulltime stamp) and making sure that the backup looks good* -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b3befc8a-0ea3-4f17-bc63-dfc04f7d1ac8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.