cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
837
Views
0
Helpful
19
Replies

ansible create domain vlan/vsan policy

tdubb123
Level 1
Level 1

trying to create domain vlan/vsan policy but keep failing. any idea? I think i need to assign a multicast policy to it? or resource path is wrong?

 

- name: "Configure Domain Vlan policy"
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: /vnic/VlanDomainPolicies
query_params:
$filter: "Name eq '{{ name_of_vlan_domain_policy }}'"
api_body:
Name: "{{ name_of_vlan_domain_policy }}"
Description: "{{ description_of_vlan_domain_policy }}"
DefaultSettings:
VlanSettings:
Name: "{{ name_of_vlan_domain_policy }}"
VlanType: "Ethernet"
VlanList: "{{ vlan_ids }}"
# Organization:
# Moid: "{{ intersight_org.api_response.Moid }}"
Tags:
- Key: "configmode"
Value: "ansible"
- Key: "prefix" # <- Make sure this line is properly indented
Value: "" # <- Add the Value for "prefix"
register: domain_vlan_policy
19 Replies 19

got this working but need help with the loop:

 

- name: "Configure VSAN 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/FcNetworkPolicies
query_params:
$filter: "Name eq '{{ name_of_vsan_policy_A }}'"
api_body:
Name: "{{ name_of_vsan_policy_A }}"
Description: "{{ description_of_vsan_policy_A }}"
Organization:
Moid: "{{ intersight_org.api_response.Moid }}"
Tags:
- Key: "configmode"
Value: "ansible"
- Key: "prefix"
Value: ""
register: vsan_policy_A

- name: "Configure VSAN Policy B"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/FcNetworkPolicies
query_params:
$filter: "Name eq '{{ name_of_vsan_policy_B }}'"
api_body:
Name: "{{ name_of_vsan_policy_B }}"
Description: "{{ description_of_vsan_policy_B }}"
Organization:
Moid: "{{ intersight_org.api_response.Moid }}"
Tags:
- Key: "configmode"
Value: "ansible"
- Key: "prefix"
Value: ""
register: vsan_policy_B

- name: Print return information from the previous tasks
ansible.builtin.debug:
var: item.api_response.Moid
loop:
- "{{ vsan_policy_A }}"
- "{{ vsan_policy_B }}"

# Create VSANs
- name: "Create VSANS for VSAN Policy A"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: "/bulk/Requests"
api_body: {
"Verb": "POST",
"Uri": "/v1/fabric/Vsans",
"Requests": [
{
"ObjectType": "bulk.RestSubRequest",
"Body": {
"Name": "vsan100",
"VsanId": 100,
"FcoeVlan": 100,
"VsanScope": "Uplink",
"FcNetworkPolicy": "{{ vsan_policy_A.api_response.Moid }}"
}
},
{
"ObjectType": "bulk.RestSubRequest",
"Body": {
"Name": "vsan200",
"VsanId": 200,
"FcoeVlan": 200,
"VsanScope": "Storage",
"FcNetworkPolicy": "{{ vsan_policy_A.api_response.Moid }}"
}
}
]}

##################

# Create VSANs
- name: "Create VSANS for VSAN Policy B"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: "/bulk/Requests"
api_body: {
"Verb": "POST",
"Uri": "/v1/fabric/Vsans",
"Requests": [
{
"ObjectType": "bulk.RestSubRequest",
"Body": {
"Name": "vsan100",
"VsanId": 100,
"FcoeVlan": 1000,
"VsanScope": "Uplink",
"FcNetworkPolicy": "{{ vsan_policy_B.api_response.Moid }}"
}
},
{
"ObjectType": "bulk.RestSubRequest",
"Body": {
"Name": "vsan200",
"VsanId": 200,
"FcoeVlan": 2000,
"VsanScope": "Storage",
"FcNetworkPolicy": "{{ vsan_policy_B.api_response.Moid }}"
}
}
]}

any idea why this is not working. I keep getting "msg": "API error: (400, 'HTTP Error 400: Bad Request',

- name: "Configure VSAN Policies"
  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/FcNetworkPolicies
    query_params:
      $filter: "Name eq '{{ item.name }}'"
    api_body:
      Name: "{{ item.name }}"
      Description: "{{ item.description }}"
      Organization:
        Moid: "{{ intersight_org.api_response.Moid }}"
      Tags:
        - Key: "configmode"
          Value: "ansible"
        - Key: "prefix"
          Value: ""
  register: vsan_policy_result
  loop:
    - { name: "{{ name_of_vsan_policy_A }}", description: "{{ description_of_vsan_policy_A }}" }
    - { name: "{{ name_of_vsan_policy_B }}", description: "{{ description_of_vsan_policy_B }}" }
    
- name: Print return information
  ansible.builtin.debug:
    var: item.api_response.Moid
  loop: "{{ vsan_policy_result.results }}"

- name: "Get Moid for Domain VSAN Policy"
  cisco.intersight.intersight_rest_api:
    <<: *api_info
    resource_path: /fabric/FcNetworkPolicies
    query_params:
      $filter: "Name eq '{{ name_of_vsan_policy_A }}'"
  register: vsan_policy_A

# Get Org Info
- name: "Get Organization Info"
  intersight_rest_api:
    <<: *api_info
    resource_path: /organization/Organizations
    query_params:
      $filter: "Name eq 'default'"
    return_list: true
  register: org_info
- name: Print return information from the previous task
  ansible.builtin.debug:
    var: org_info.api_response[0].Moid

- name: "Create VSANs for VSAN Policy"
  cisco.intersight.intersight_rest_api:
    <<: *api_info
    resource_path: "/bulk/Requests"
    api_body: |
      {
        "Verb": "POST",
        "Uri": "/v1/fabric/Vsans",
        "Requests": [
          {% for vsan in vsan_configs_A %}
          {
            "ObjectType": "bulk.RestSubRequest",
            "Body": {
              "Name": "{{ vsan.name }}",
              "VsanId": "{{ vsan.vsan_id }}",
              "FcoeVlan": "{{ vsan.fcoe_vsan_id }}",
              "Scope": "Uplink",
              "FcNetworkPolicy": "{{ vsan_policy_A.api_response.Moid }}"
            }
          }{% if not loop.last %},{% endif %}
          {% endfor %}
        ]
      }
  register: bulk_vsan_info

# Add a debug task to print information from the creation of VSANs
- name: Debug VSAN creation result
  ansible.builtin.debug:
    var: bulk_vsan_info

"Scope" parameter is incorrect. It should be "VsanScope": "Uplink"

Hi Sandeep,

 

any examples for SNMP, termal, power? 

Hi Sandeep,

 

any examples for SNMP, switch control, port config policy?