Update:
I figured it out:
---
- 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: {{{hostvars['localhost']['last_mongo']}}}"
Is there a better way?
Am Mittwoch, 23. Juli 2014 15:51:24 UTC+2 schrieb Benjamin Bauer:
>
> 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:
>
> 1. figure out which backup is the latest (once)
> 2. download that file to all DB servers
> 3. ...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?
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/f5a545ee-fc6b-422f-887b-eb4dac456fba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.