<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic network interface through loop/iteration in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/network-interface-through-loop-iteration/m-p/509182#M3073</link>
    <description>&lt;P&gt;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...&lt;/P&gt;
&lt;P&gt;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...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=""&gt;&lt;CODE class=""&gt;***Interface_facts details:***

tasks:
         - name: load var
           include_vars: provider.yaml

         - name: interface_fact
           panos_facts:
                   provider: &lt;SPAN class=""&gt;'{{ provider }}'
                   gather_subset: [&lt;SPAN class=""&gt;'interfaces']
           register: interface

         - debug:
                 msg: &lt;SPAN class=""&gt;"{{ interface | json_query('ansible_facts.ansible_net_interfaces[*].name') }}"

***interface_creation:*** 

         - name: Create tunnel interfaces
           panos_tunnel:
               provider: &lt;SPAN class=""&gt;'{{ provider }}'
               if_name: &lt;SPAN class=""&gt;'tunnel.{{ item }}'
               &lt;SPAN class=""&gt;#ip: '{{ item.ip }}/30'
               management_profile: &lt;SPAN class=""&gt;'PING-ONLY'
               state: &lt;SPAN class=""&gt;'present'
               zone_name: &lt;SPAN class=""&gt;'AWS-REMOTE-ZONE'
               vr_name: &lt;SPAN class=""&gt;'default'
               commit: &lt;SPAN class=""&gt;False
               &lt;SPAN class=""&gt;#  comment: "AWS {{ account_no }} {{ region }} - {{ ticket }} {{ requester }} - {{ application }} "
           loop: &lt;SPAN class=""&gt;"{{ range(111,112)|list }}"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jul 2022 13:05:06 GMT</pubDate>
    <dc:creator>MAULIK_NUTA</dc:creator>
    <dc:date>2022-07-18T13:05:06Z</dc:date>
    <item>
      <title>network interface through loop/iteration</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/network-interface-through-loop-iteration/m-p/509182#M3073</link>
      <description>&lt;P&gt;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...&lt;/P&gt;
&lt;P&gt;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...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=""&gt;&lt;CODE class=""&gt;***Interface_facts details:***

tasks:
         - name: load var
           include_vars: provider.yaml

         - name: interface_fact
           panos_facts:
                   provider: &lt;SPAN class=""&gt;'{{ provider }}'
                   gather_subset: [&lt;SPAN class=""&gt;'interfaces']
           register: interface

         - debug:
                 msg: &lt;SPAN class=""&gt;"{{ interface | json_query('ansible_facts.ansible_net_interfaces[*].name') }}"

***interface_creation:*** 

         - name: Create tunnel interfaces
           panos_tunnel:
               provider: &lt;SPAN class=""&gt;'{{ provider }}'
               if_name: &lt;SPAN class=""&gt;'tunnel.{{ item }}'
               &lt;SPAN class=""&gt;#ip: '{{ item.ip }}/30'
               management_profile: &lt;SPAN class=""&gt;'PING-ONLY'
               state: &lt;SPAN class=""&gt;'present'
               zone_name: &lt;SPAN class=""&gt;'AWS-REMOTE-ZONE'
               vr_name: &lt;SPAN class=""&gt;'default'
               commit: &lt;SPAN class=""&gt;False
               &lt;SPAN class=""&gt;#  comment: "AWS {{ account_no }} {{ region }} - {{ ticket }} {{ requester }} - {{ application }} "
           loop: &lt;SPAN class=""&gt;"{{ range(111,112)|list }}"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 13:05:06 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/network-interface-through-loop-iteration/m-p/509182#M3073</guid>
      <dc:creator>MAULIK_NUTA</dc:creator>
      <dc:date>2022-07-18T13:05:06Z</dc:date>
    </item>
  </channel>
</rss>

