On Sun, 24 Nov 2019 04:01:16 -0800 (PST) Shifa Shaikh <[email protected]> wrote:
> - name: Play 2
> hosts: desthosts
> tasks:
> - set_fact:
> storerec: "{{storerec | default('') + 'Hello ' + inventory_hostname +
> '\n'}}"
> with_fileglob:
> - "{{ playbook_dir }}/tmpfiles/*"
>
> - name: Play 3
> hosts: localhost
> tasks:
> - local_action: lineinfile line="{{ hostvars['dest_nodes']['storerec'] }}"
> path="{{ playbook_dir }}/files/tricky.txt" create=yes
> [...]
> fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an
> undefined variable. The error was: \"hostvars['desthosts']\" is
> undefined\n
"To get the value of storerecords from desthost" use the *extract* filter. For
example
storerecords: "{{ groups['desthosts'] |
map('extract', hostvars, 'storerec') |
list }}"
Cheers,
-vlado
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/20191124152359.754a4209%40gmail.com.
pgpdrs9yf0Gtx.pgp
Description: OpenPGP digital signature
