[ansible-project] Re: loop and pass variables from vars_files to task command
Well I've tried rearranging my playbook to use a lookup plugin, which seems to work but I still can't figure out how to loop over my list until it completes. I added this 'vars' section to the play with the same results as before (a single VLAN gets created and ansible moves onto the next task) vars: name: "{{lookup('vars', 'vlan_name')}}" id: "{{lookup('vars', 'vlan_id')}}" subnet: "{{lookup('vars', 'vlan_subnet')}}" -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20b0e3ad-376c-46ed-9118-20056beabddb%40googlegroups.com.
[ansible-project] loop and pass variables from vars_files to task command
Hi Folks, I'm trying to loop over a list of production vlan's using a vars_file named exos_vlans.yml. The playbook runs fine on the first vlan but doesn't attempt to create the 2nd vlan. It just starts the next task and finishes up w/out any errors. My file includes 3 variables (vlan_name, vlan_id, vlan_subnet). Here's my playbook, any suggestions would be appreciated. --- - hosts: 172.16.1.1 connection: local tags: conf_vlan vars_files: - group_vars/exos_reqs.yml - vault/exos_admin.yml - group_vars/exos_vlans.yml # My list of VLAN/IP/VID tasks: - name: Create production VLAN's exos_config: lines: - create vlan "{{ vlan_name }}" tag "{{ vlan_id }}" - name: Configure VLAN IP exos_config: lines: - configure vlan "{{ vlan_name }}" ipaddress "{{ vlan_subnet }}" - enable ipforwarding vlan "{{ vlan_name }}" - name: Show VLAN exos_command: commands: show vlan register: show_vlan - debug: var=show_vlan.stdout_lines - name: save running to startup when modified exos_config: save_when: modified My vars_file --- - vlan_name: Test1 vlan_id: 10 vlan_subnet: 10.3.10.2/24 - vlan_name: Test2 vlan_id: 20 vlan_subnet: 10.3.20.2/24 -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/bc9b2e4d-1027-4e5d-9acc-395c2b4e0f89%40googlegroups.com.