vars: hubs: "{{groups['Hubs']}}" connection: local tasks: - name: debug tasks debug: msg: "{{hostvars[item].tunnel_address}}" with_items: "{{ hubs }}" - name: test ios config ios_config: parents: interface Tunnel1 lines: - description {{ hostvars[item].tunnel_address }} with_items: "{{ hubs }}"
Output of the playbook: TASK [debug tasks] *************************************************************** ok: [Spoke1] => (item=Hub1) => { "changed": false, "item": "Hub1", "msg": "1.1.1.1" } ok: [Spoke1] => (item=Hub2) => { "changed": false, "item": "Hub2", "msg": "1.1.1.2" } ok: [Spoke2] => (item=Hub1) => { "changed": false, "item": "Hub1", "msg": "1.1.1.1" } ok: [Spoke2] => (item=Hub2) => { "changed": false, "item": "Hub2", "msg": "1.1.1.2" } TASK [test ios config] *********************************************************** fatal: [Spoke1]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'item' is undefined\n\nThe error appears to have been in '/Users/vishlpa4/central-orchestration/cso-transit-vpc-poc/configureSpokes.yml':line 28, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: test ios config\n ^ here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'item' is undefined"} fatal: [Spoke2]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'item' is undefined\n\nThe error appears to have been in '/Users/vishlpa4/central-orchestration/cso-transit-vpc-poc/configureSpokes.yml':line 28, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: test ios config\n ^ here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'item' is undefined"} to retry, use: --limit @/Users/vishlpa4/central-orchestration/cso-transit-vpc-poc/configureSpokes.retry Any idea why this is failing ? Am I not supposed to use item in ios_config module -- 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/4715d4f5-099b-438e-8a4d-8a46324813e1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.