Vars and register passing on to include playbooks

By all accounts that I can see, the following should work:

`

So vars seems to be incorrectly indented, also you should not need to add ‘bash’ to command

The registered var should persist but it is available only through the server01 host.

indented var: that is a copy/paste mistake.

So those vars and register will not persist to any of the other include playbooks?

`

vars don’t they are play specific, host vars (facts and registered vars) do persist, but they are associated to the specific host.

So in subsequent plays you might need to do hostvars[‘server01’][‘timestamp’] to get the var if they are not also targetting server01.

So in order to access this var/register from server01, I could do something like in playbook-01.yml:

`

hostvars are not accessible at the play level, but should be accessible within the play.

When I do this:
{{ hostvars[‘server1’][‘timestamp.stdout’] }}

as in:

  • name: “Backup {{ proddbname }} Database”
    mysql_db: “state=dump name={{ proddbname }} target={{ homedir }}{{ proddbname }}{{ hostvars[‘server01’][‘timestamp.stdout’] }}.sql.gz”

It gives me the error
fatal: [proddbhost]: FAILED! => {“failed”: true, “msg”: “‘dict object’ has no attribute ‘timestamp.stdout’”}

you are mixing notations

{{ hostvars[‘server1’][‘timestamp’][‘stdout’] }}

DING! That worked. Thank you so much!