Hello Team,

 

Below is my playbook & variable for Ansible. Could you please check and 
help with my query.

 

*Playbook*

 

- name: GIN_MNG Routing

  lineinfile:

      line: set routing-instances GIN_MNG routing-options static route {{ 
item.dst }} next-hop {{ item.nhp }} {{item.action | default()}}

      line: set routing-instances GIN_MNG routing-options static route {{ 
item.dst }} {{item.option | default()}}

      path: config/{{ inventory_hostname }}_common-config.conf

  with_items: "{{ routing.GIN_MNG.srouting }}"

 

*Variable*

 

routing: 

            srouting:

                    - { dst : 0.0.0.0/0, nhp: 172.19.66.65 }

                    - { dst : 10.227.222.0/28, nhp: 192.168.1.10, action: 
retain }

                    - { dst : 10.227.222.16/28, nhp: 192.168.1.10, option: 
discard }

 

*Issue* : This loop runs only on line2 <<<set routing-instances GIN_MNG 
routing-options static route {{ item.dst }} {{item.option | default()}} >>> 
and yields below result.

 

*Result*

 

set routing-instances GIN_MNG routing-options static route 0.0.0.0/0 

set routing-instances GIN_MNG routing-options static route 10.227.222.0/28 

set routing-instances GIN_MNG routing-options static route 10.227.222.16/28 
discard

 

*Expected* : I want to run loop on both lines and expects below result. I 
don’t want to create new task for each line since my variable is common.

 

*Expected Result*

 

set routing-instances GIN_MNG routing-options static route 0.0.0.0/0 
next-hop 172.19.66.65

set routing-instances GIN_MNG routing-options static route 10.227.222.0/28 
next-hop 192.168.1.10 retain

set routing-instances GIN_MNG routing-options static route 10.227.222.16/28 
next-hop 192.168.1.10

set routing-instances GIN_MNG routing-options static route 0.0.0.0/0 

set routing-instances GIN_MNG routing-options static route 10.227.222.0/28 

set routing-instances GIN_MNG routing-options static route 10.227.222.16/28 
discard

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/18ef88d5-aa51-44f6-9dc2-3326678c13fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to