I'm writing a playbook to restore the latest backup of my DB on all my Database servers. This is done in two main steps:
- figure out which backup is the latest (once)
- download that file to all DB servers
- ...and run the restore
While step 2 and 3 are straight forward, my problem is to
acquire the correct filename once and share it among all DB hosts.
I was trying something like this for testing, but I cant access `last_mongo` on the DB hosts.
---
- hosts: localhost
tasks:
- name: get filename of latest mongo backup
shell: s3cmd ls s3://my_backup_bucket/production/ | awk 'NF{p=$4}END{print p}'
register: lmongo
- set_fact: last_mongo="{{lmongo.stdout}}"
- hosts: db
tasks:
- debug:
msg: "mongo: {{latest_mongo}}"
Is there a (idiomatic) way to make this variable accessible to the db hosts?