Hi. I’m trying to use the VMware module to configure my vCenters.
I have over 100 vlans and roughly 30 dv switches that I’m trying to configure. The dvs switches could have any combination of the vlans. I could do something like
`
-
vlanid: vlan1
vlan: 1
dvs: DSwitch1
numports: 128 -
vlanid: vlan2
vlan: 2
dvs: DSwitch1
numports: 128 -
vlanid: vlan1
vlan: 1
dvs: DSwitch2
numports: 128 -
vlanid: vlan2
vlan: 2
dvs: DSwitch2
numports: 128
`
But then I end up having a ridiculous list that has stuff duplicated all over the place.
Is there a way to do something like:
`
- vlanid: vlan1
vlan: 1
dvs: - DSwitch1
- DSwitch2
numports: 128 - vlanid: vlan2
vlan: 2
dvs:
-DSwitch2
numports: 128
`
Or another way to be able to do that? This is an issue all over my vCenter config playbook, not just vlans. So finding a better way than building a long dictionary would be ideal. I imagine I’d need to change the way the loop works, but I’m not sure what road to go down.
`
Playbook.yml
- name: Create DVS portgroup
vmware_dvs_portgroup:
hostname: “{{secret.vcenter}}”
username: “{{secret.vcusername}}”
password: “{{secret.vcpassword}}”
validate_certs: no
portgroup_name: “{{item.vlanid}}”
vlan_id: “{{item.vlan}}”
portgroup_type: earlyBinding
num_ports: “{{item.numports}}”
state: present
switch_name: “{{item.dvs}}”
loop: “{{config.vlans}}”
`
Thanks!
Barry