-
Ansible NetBox Collection versionv3.13.0 Ansible versionansible [core 2.14.6]
config file = None
configured module search path = ['/Users/pkapos/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /Users/pkapos/Library/Python/3.9/lib/python/site-packages/ansible
ansible collection location = /Users/pkapos/.ansible/collections:/usr/share/ansible/collections
executable location = /Users/pkapos/Library/Python/3.9/bin/ansible
python version = 3.9.6 (default, May 7 2023, 23:32:44) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/Library/Developer/CommandLineTools/usr/bin/python3)
jinja version = 3.1.2
libyaml = True NetBox versionv3.5.4 Python version3.9 Steps to ReproduceI have this data structure in vars file devices:
test-device1:
name: Test Device 1
device_type: test-device-type1
device_role: router1
site: UoP
position: 12
rack: Lande
face: Front
serial: "864kjfhi3y74"
# primary_ip4: ""
# description: ""
# commments: ""
interfaces:
- name: GigabitEthernet22
enabled: true
mgmt_only: false
type: 1000Base-t (1GE)
mode: Access
untagged_vlan: vlan401
- name: GigabitEthernet23
enabled: false
mgmt_only: false
type: 1000Base-t (1GE)
mode: Tagged
untagged_vlan: vlan401
tagged_vlans:
- vlan1000
- vlan1015
lag:
name: port-channel1 and using the following task am trying to add interfaces with tagged vlans - name: Create interfaces
netbox.netbox.netbox_device_interface:
data:
device: "{{ item.value.name }}"
name: "{{ item.value.interfaces.0.name }}"
enabled: "{{ item.value.interfaces.0.enabled }}"
type: "{{ item.value.interfaces.0.type|default(omit) }}"
untagged_vlan:
name: "{{ item.value.interfaces.0.untagged_vlan|default(omit) }}"
tagged_vlans:
name: "{{ item.value.interfaces.0.tagged_vlans.0|default(omit) }}"
site: "{{ item.value.site }}"
mgmt_only: "{{ item.value.interfaces.0.mgmt_only|default(omit) }}"
mode: "{{ item.value.interfaces.0.mode|default(omit) }}"
state: present
loop: "{{ devices | dict2items }}" Expected BehaviorI would expect the module to take the list I am passing and make the changes to the netbox deployment. Observed Behaviorthe error I am getting is which seems like a module issue. What can be fixed here to add the interface with the tagged vlans? If I comment out the tagged vlan from the task it completes fine |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Take a closer look at the examples for how to set the |
Beta Was this translation helpful? Give feedback.
-
With the help of Nikos Kallergis found the answer which is change the datastructure of the tagged_vlans from tagged_vlans:
tagged_vlans:
tagged_vlans: tagged_vlans: "{{ item.1.tagged_vlans.0|default(omit) }}" |
Beta Was this translation helpful? Give feedback.
With the help of Nikos Kallergis found the answer which is change the datastructure of the tagged_vlans from
tagged_vlans:
to
tagged_vlans:
and change the task from
tagged_vlans:
name: "{{ item.1.tagged_vlans.0|default(omit) }}"
to
tagged_vlans: "{{ item.1.tagged_vlans.0|default(omit) }}"