- name: add vlan to backbone
  hosts: { devices }
  gather_facts: false
  vars:
    devices:
      - hostname: device1
        ports:
          - type: access
            description: Port 1
            vlan_tag: 100
          - type: trunk
            description: Port 2
            vlan_tag: 200-300
      - hostname: device2
        ports:
          - type: service-instance
            description: Port 1
            vlan_tag: qinq
            vlan_id: 500
            vfi_id: 500
            svi:
              description: SVI 1
              ip: 192.168.1.1/24
              hsrp_ip: 192.168.1.2
              acl_name: SVI1_ACL
  tasks:


    - name: load backbone file
      run_once: true
      set_fact:
        backbone: "{{ lookup('file','/var/lib/awx/projects/_24__cisco_cfg153310/tmp/backbone.json') | from_json }}"


    - name: Check if VLAN exists in Backbone
      meta: end_host
      when: vlan_id in vars['backbone']['vlans_global']


    - name: Check if VFI exists in Backbone
      
      when: ('transport' in vars['backbone']['vlans_global'][vlan_id]['devices'][inventory_hostname] and 'VPLS' in vars['backbone']['vlans_global'][vlan_id]['devices'][inventory_hostname]['transport'])


    - name: Configure ports on device
      ios_config:
        lines:
          - "description {{ item.1.description }}"
          - "switchport {{ item.1.type }}"
          - "switchport access vlan {{ item.1.vlan_tag }}"
        parents: "interface {{ item.0 }}"
      with_nested:
        - "{{ devices.ports }}"
        - item


    - name: Configure BDI/SVI on device
      ios_config:
        lines:
          - "description {{ devices.svi.description }}"
          - "ip address {{ devices.svi.ip }}"
          - "hsrp {{ devices.svi.hsrp_ip }}"
          - "access-list {{ devices.svi.acl_name }}"
        parents: "interface {{ devices.svi.vlan_id }}"


    - name: Create L2 VFI
      include_tasks: edit_vfi_peers.yml
      when: devices.l2_vfi == true
...zur Antwort