can i get assistance with creating a loop for creating both A and B side.
- name: “Configure Domain VLAN Policy A”
vars:
api_info: &api_info
api_private_key: “{{ api_private_key }}”
api_key_id: “{{ api_key_id }}”
api_uri: “{{ api_uri | default(omit) }}”
validate_certs: “{{ validate_certs | default(omit) }}”
state: “{{ state | default(omit) }}”
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/EthNetworkPolicies
query_params:
$filter: “Name eq ‘{{ name_of_vlan_domain_policy_A }}’”
api_body:
Name: “{{ name_of_vlan_domain_policy_A }}”
Description: “{{ description_of_vlan_domain_policy_A }}”
Organization:
Moid: “{{ intersight_org.api_response.Moid }}”
Tags:
-
Key: “configmode”
Value: “ansible” -
Key: “prefix”
Value: “”
register: domain_vlan_policy_A -
name: “Configure Domain VLAN Policy B”
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/EthNetworkPolicies
query_params:
$filter: “Name eq ‘{{ name_of_vlan_domain_policy_B }}’”
api_body:
Name: “{{ name_of_vlan_domain_policy_B }}”
Description: “{{ description_of_vlan_domain_policy_B }}”
Organization:
Moid: “{{ intersight_org.api_response.Moid }}”
Tags: -
Key: “configmode”
Value: “ansible” -
Key: “prefix”
Value: “”
register: domain_vlan_policy_B -
name: Print return information from the previous tasks
ansible.builtin.debug:
var: item.api_response.Moid
loop: -
“{{ domain_vlan_policy_A }}”
-
“{{ domain_vlan_policy_B }}”
Get Moid for domain_vlan_policy_A
- name: “Get Moid for Domain VLAN Policy A”
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/EthNetworkPolicies
query_params:
$filter: “Name eq ‘{{ name_of_vlan_domain_policy_A }}’”
register: domain_vlan_policy_A
Create VLANs for Domain VLAN Policy A
-
name: “Create VLANs for Domain VLAN Policy A”
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: “/bulk/Requests”
api_body: |
{
“Verb”: “POST”,
“Uri”: “/v1/fabric/Vlans”,
“Requests”: [
{% for vlan in vlan_configs_A %}
{
“ObjectType”: “bulk.RestSubRequest”,
“Body”: {
“Name”: “{{ vlan.name }}”,
“VlanId”: {{ vlan.vlan_id }},
“SharingType”: “None”,
“PrimaryVlanId”: 0,
“MulticastPolicy”: “{{ multicast_policy.api_response.Moid }}”,
“AutoAllowOnUplinks”: false,
“IsNative”: false,
“EthNetworkPolicy”: “{{ domain_vlan_policy_A.api_response.Moid }}”
}
}{% if not loop.last %},{% endif %}
{% endfor %}
]
}
register: bulk_vlan_info_A -
name: Print return information for VLANs created with Domain VLAN Policy A
ansible.builtin.debug:
var: bulk_vlan_info_A.api_response
Get Moid for domain_vlan_policy_B
- name: “Get Moid for Domain VLAN Policy B”
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/EthNetworkPolicies
query_params:
$filter: “Name eq ‘{{ name_of_vlan_domain_policy_B }}’”
register: domain_vlan_policy_B
Create VLANs for Domain VLAN Policy B
-
name: “Create VLANs for Domain VLAN Policy B”
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: “/bulk/Requests”
api_body: |
{
“Verb”: “POST”,
“Uri”: “/v1/fabric/Vlans”,
“Requests”: [
{% for vlan in vlan_configs_B %}
{
“ObjectType”: “bulk.RestSubRequest”,
“Body”: {
“Name”: “{{ vlan.name }}”,
“VlanId”: {{ vlan.vlan_id }},
“SharingType”: “None”,
“PrimaryVlanId”: 0,
“MulticastPolicy”: “{{ multicast_policy.api_response.Moid }}”,
“AutoAllowOnUplinks”: false,
“IsNative”: false,
“EthNetworkPolicy”: “{{ domain_vlan_policy_B.api_response.Moid }}”
}
}{% if not loop.last %},{% endif %}
{% endfor %}
]
}
register: bulk_vlan_info_B -
name: Print return information for VLANs created with Domain VLAN Policy B
ansible.builtin.debug:
var: bulk_vlan_info_B.api_response