Nope, you can put them directly in the playbook in the vars section. 
Similar to 
this: 
https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html

On Thursday, 23 December 2021 at 23:21:23 UTC [email protected] wrote:

> does the vlan Ids need to be in separate vars file? which file should they 
> be in?
>
> On Wednesday, December 22, 2021 at 1:11:10 PM UTC-8 Rodrigues wrote:
>
>> The simplest way would be add the vlans and portgroup names as a list in 
>> vars
>> Then loop through them using with_items
>>
>> Like this
>>
>> vlans:
>> - portgroup_name: vlan 1
>>   vlan_id: 1
>> - portgroup_name: vlan 2
>>   vlan_id: 2
>> - portgroup_name: vlan 3
>>   vlan_id: 3
>>   
>>
>>
>> - name: create_vss_vlan_PGs
>>   vmware_portgroup:
>>     hostname: '{{ vcenter_hostname }}'
>>     username: '{{ vcenter_username }}'
>>     password: '{{ vcenter_password }}'
>>     cluster_name: '{{ cluster_name }}'
>>     switch_name: '{{ vswitch_name }}'
>>     portgroup_name: '{{ item.portgroup_name }}'
>>     vlan_id: '{{ item.vlan_id }}'
>>   delegate_to: localhost
>>   with_items: '{{ vlans }}'
>>
>> On Monday, 20 December 2021 at 15:39:08 UTC [email protected] wrote:
>>
>>> any idea?
>>>
>>> On Sunday, December 19, 2021 at 1:12:36 PM UTC-8 Tony Wong wrote:
>>>
>>>> i got following task to create mul;tiple vlan ports groups on a vswitch 
>>>> on 5 esxi hosts
>>>>
>>>> task playbok is
>>>>
>>>> ---
>>>> - name: create_vss_vlan_PGs
>>>>   vmware_portgroup:
>>>>     hostname: '{{ vcenter_hostname }}'
>>>>     username: '{{ vcenter_username }}'
>>>>     password: '{{ vcenter_password }}'
>>>>     cluster_name: '{{ cluster_name }}'
>>>>     switch_name: '{{ vswitch_name }}'
>>>>     portgroup_name: '{{ portgroup_name }}'
>>>>     vlan_id: '{{ vlan_id }}'
>>>>   delegate_to: localhost
>>>>
>>>>
>>>> i have answer file like so
>>>>
>>>>
>>>> vcenter_hostname: "myvcenter.domain.com"
>>>> vcenter_username: "[email protected]"
>>>> vcenter_password: "xxxxxxxx"
>>>> cluster_name: "cluster"
>>>> switch_name: "vSwitch0"
>>>> portgroup_name: "??????"
>>>> vlan_id: "?????"
>>>>
>>>>
>>>> my hosts file is
>>>>
>>>> [esx]
>>>> esx1
>>>> esx2
>>>> esx3
>>>> esx4
>>>> esx5
>>>>
>>>> [esx:vars]
>>>>
>>>>
>>>> any idea how i would create the portgroups with different vlan ids? 
>>>> which file would i put them in?
>>>>
>>>>
>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d61e94f1-db7c-40c4-b109-0ee68705876an%40googlegroups.com.

Reply via email to