network interface through loop/iteration

Showing results for 
Show  only  | Search instead for 
Did you mean: 
Please sign in to see details of an important advisory in our Customer Advisories area.

network interface through loop/iteration

L1 Bithead

i'm trying to create interface every time i run my playbook and meanwhile i also need to make sure that it will compare the existing interface details and creating new one by incrementing interface/tunnel no...

i have tried to create two task , first task about to gather interface facts and that works fine. but i'm not sure how use " create interface number only if that is not present in facts" and this keep going on while i run playbook for next time...


***Interface_facts details:***

         - name: load var
           include_vars: provider.yaml

         - name: interface_fact
                   provider: '{{ provider }}'
                   gather_subset: ['interfaces']
           register: interface

         - debug:
                 msg: "{{ interface | json_query('ansible_facts.ansible_net_interfaces[*].name') }}"


         - name: Create tunnel interfaces
               provider: '{{ provider }}'
               if_name: 'tunnel.{{ item }}'
               #ip: '{{ item.ip }}/30'
               management_profile: 'PING-ONLY'
               state: 'present'
               zone_name: 'AWS-REMOTE-ZONE'
               vr_name: 'default'
               commit: False
               #  comment: "AWS {{ account_no }} {{ region }} - {{ ticket }} {{ requester }} - {{ application }} "
           loop: "{{ range(111,112)|list }}"



  • 0 replies
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!