How to pass variable of in memory inventory to following next plays using hostvars. "nfs_server" variable to be passed from play 2 to play 3 and these plays are using in-memory inventories.
Play:1 - add_host: name: "{{ group1_host }}" groups: group1 Play 2: - name: hosts: group1 become: yes tasks: - name: set_fact: nfs_server: "{{ nfs_server }}" - shell: /usr/sbin/exportfs -av 2> /dev/null | awk {'print $2'} | cut -d ':' -f1 | grep -v '*' register: nfs_clients_out - add_host: name: "{{ item }}" group: "group 2" with_items: "{{ nfs_clients_out.stdout_lines }}" Play 3: - name: hosts: group2 become: yes tasks: - name: Fetch Variable from Previous Play set_fact: nfs_server: "{{ hostvars['item']['nfs_server'] }}" with_items: "{{ groups['group1'] }}" -- 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/dcb03a73-afcf-4bb3-bd55-e9b68e185c3f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.