cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
272
Views
0
Helpful
0
Replies

Ansible loop through Array

netmart2
Level 1
Level 1

Hello,

I was wondering, whether it is possible to loop through an array instead generating a line for each element in array.

 

Extract:

:

vars:
      ansible_become_pass: "{{ vault_sudo_password }}"
      ansible_python_interpreter: /usr/bin/python3

      prefix:
         -  10.0.0.0/24
         -  10.0.1.0/24
         -  10.0.2.0/24
 
:

     - name: Task3- remove prefix

       ios_config:

         commands:

             - no ip prefix-list bgp-net permit {{prefix[0]}}

       when: output2.stdout is search ~prefix[0]

 

     - name: Task4- remove prefix

       ios_config:

         commands:

             - no ip prefix-list bgp-net permit {{prefix[1]}}

       when: output2.stdout is search ~prefix[1]

 

:

 

Please advise.

Thanks.

 

 

0 Replies 0