cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
320
Views
0
Helpful
6
Replies

ansible vnic templates cisco intersight

tdubb123
Level 1
Level 1

any idea or where I can find out how to create vnic templates using ansible in interight?

I basically need vnic templates for ESX server

vnic0-mgmt

vnic1-mgmt

vnic2-vmotion

vnic3 - vmotion

vnic4 - VM

vnic5 - vm

thanks

6 Replies 6

tdubb123
Level 1
Level 1

any idea? i followed this repo but it does not crrate vnic templates

 

https://github.com/ucs-compute-solutions/FlashStack_IMM_Ansible

any idea whats wrong with this? i keeop getting an error

 

 

- name: "Configure vNIC Template"
  vars:
    api_info: &api_info_vnic
      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_vnic
    resource_path: /vnic/VnicTemplates
    query_params:
      $filter: "Name eq '{{ name_of_vnic_template }}'"
    api_body:
      Name: "{{ name_of_vnic_template }}"
      Description: "{{ description_of_vnic_template }}"
      MacPool:
        Moid: "{{ mac_pool_fi_a_details.api_response.Moid }}"
      SwitchId: "A"
      Organization:
        Moid: "{{ intersight_org.api_response.Moid }}"
      PolicyBucket:
        - Moid: "{{ ethernet_network_group_policy_details.api_response.Moid }}"
          ObjectType: "vnic.EthNetworkGroupPolicy"
        - Moid: "{{ ethernet_network_control_policy_details.api_response.Moid }}"
          ObjectType: "vnic.EthNetworkControlPolicy"
        - Moid: "{{ ethernet_qos_policy_details.api_response.Moid }}"
          ObjectType: "qos.Policy"
        - Moid: "{{ ethernet_adapter_policy_details.api_response.Moid }}"
          ObjectType: "vnic.EthAdapterPolicy"
​

 

any idea? I check and look like vnic template dont support policybucket.

 

I changed it to

- name: "Configure vNIC Template"
  vars:
    api_info: &api_info_vnic
      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('present') }}"


  cisco.intersight.intersight_rest_api:
    <<: *api_info_vnic
    resource_path: "/vnic/VnicTemplates"
    query_params:
      $filter: "Name eq '{{ name_of_vnic_template }}'"
    api_body:
      ClassId: "vnic.VnicTemplate"
      Name: "{{ name_of_vnic_template }}"
      Description: "{{ description_of_vnic_template }}"
      SwitchId: "A"
      EnableOverride: true
      MacPool:
        Moid: "{{ mac_pool_fi_a_details.api_response.Moid }}"
        ClassId: "macpool.Pool"
      Organization:
        Moid: "{{ intersight_org.api_response.Moid }}"
        ClassId: "organization.Organization"
      FabricEthNetworkGroupPolicy:
        Moid: "{{ ethernet_network_group_policy_details.api_response.Moid }}"
        ClassId: "fabric.EthNetworkGroupPolicy"
      FabricEthNetworkControlPolicy:
        Moid: "{{ ethernet_network_control_policy_details.api_response.Moid }}"
        ClassId: "fabric.EthNetworkControlPolicy"
      EthQosPolicy:
        Moid: "{{ ethernet_qos_policy_details.api_response.Moid }}"
        ClassId: "vnic.EthQosPolicy"
      EthAdapterPolicy:
        Moid: "{{ ethernet_adapter_policy_details.api_response.Moid }}"
        ClassId: "vnic.EthAdapterPolicy"
      FailoverEnabled: false
      Tags:
        - Key: "configmode"
          Value: "ansible"
        - Key: "prefix"
          Value: "{{ prefix }}"

 

but stil failing

I'll post a full example including deriving vNICs from a template to the intersight-ansible repo on GitHub, but here's a working example of just creating a vNIC template:

---
#
# Configure vNIC Templates
#
- name: "Configure vNIC Template"
hosts: localhost
connection: local
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
# if api_key vars are omitted, INTERSIGHT_API_KEY_ID, INTERSIGHT_API_PRIVATE_KEY,
# and INTERSIGHT_API_URI environment variables used for API key data
api_private_key: "{{ api_private_key | default(omit) }}"
api_key_id: "{{ api_key_id | default(omit) }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
# vNIC Template name
template_name: vnic-devnet
org_name: Demo-DevNet
mac_pool: DevNet-MACPool
network_group: DevNet-Eth-Net-Group
network_control_policy: DevNet-Eth-Net-Control
qos_policy: DevNet-Eth-QoS
ethernet_adapter: DevNet-EthAdapter-Windows
tasks:
# Get the Organization Moid
- name: "Get Organization Moid"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /organization/Organizations
query_params:
$filter: "Name eq '{{ org_name }}'"
register: org_resp
- name: "Get MAC Pool Moid"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /macpool/Pools
query_params:
$filter: "Name eq '{{ mac_pool }}'"
register: mac_resp
- name: "Get Network Group Moid"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/EthNetworkGroupPolicies
query_params:
$filter: "Name eq '{{ network_group }}'"
register: network_resp
- name: "Get Network Control Policy Moid"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/EthNetworkControlPolicies
query_params:
$filter: "Name eq '{{ network_control_policy }}'"
register: control_resp
- name: "Get QoS Policy Moid"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /vnic/EthQosPolicies
query_params:
$filter: "Name eq '{{ qos_policy }}'"
register: qos_resp
- name: "Get Ethernet Adapter Moid"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /vnic/EthAdapterPolicies
query_params:
$filter: "Name eq '{{ ethernet_adapter }}'"
register: adapter_resp
# Config vNIC Template
- name: "Configure vNIC Template"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /vnic/VnicTemplates
# method: POST
query_params:
$filter: "Name eq '{{ template_name }}'"
api_body: {
"Name": "{{ template_name }}",
"Organization": {
"Moid": "{{ org_resp.api_response.Moid }}"
},
"Cdn": {
"Source": "vnic"
},
"EnableOverride": false,
"EthAdapterPolicy": {
"Moid": "{{ adapter_resp.api_response.Moid }}"
},
"EthQosPolicy": {
"Moid": "{{ qos_resp.api_response.Moid }}"
},
"FabricEthNetworkControlPolicy": {
"Moid": "{{ control_resp.api_response.Moid }}"
},
"FabricEthNetworkGroupPolicy": [
{
"Moid": "{{ network_resp.api_response.Moid }}"
}
],
"FailoverEnabled": false,
"MacPool": {
"Moid": "{{ mac_resp.api_response.Moid }}"
},
"SwitchId": "A"
}
register: template_resp

dsoper
Cisco Employee
Cisco Employee

hi

 

any idea how to atttach this to a lan connectivity policy?

Review Cisco Networking for a $25 gift card