02-26-2024 02:19 PM
trying to configure a port policy for domain profile. but keep having issues.
- name: Configure Fabric Port 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) }}"
cisco.intersight.intersight_rest_api:
<<: *api_info
state: "{{ state | default('present') }}"
resource_path: /fabric/PortPolicies
query_params:
$filter: "Name eq '{{ port_policy_name_A }}'"
api_body:
Name: "{{ port_policy_name_A }}"
Description: "{{ port_policy_name_A_description }}"
DeviceModel: "UCS-FI-6454"
Organization:
Moid: "{{ intersight_org.api_response.Moid }}"
Tags: [{"Key": "configmode", "Value": "ansible"}, {"Key": "prefix", "Value": "{{ prefix }}"}]
register: port_resp
- name: configure port mode
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/PortModes
query_params:
$filter: "PortPolicy.Moid eq '{{ port_resp.api_response.Moid }}' and PortId eq {{ item }}"
api_body:
PortId: "{{ item }}"
PortPolicy:
Moid: "{{ port_resp.api_response.Moid }}"
SlotId: 1
CustomMode: "FibreChannel"
loop: "{{ range(1, 8 + 1) | list }}"
when: port_resp.api_response is defined and port_resp.api_response
- name: Configure Server Roles
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/ServerRoles
query_params:
$filter: "PortPolicy.Moid eq '{{ port_resp.api_response.Moid }}' and PortId eq {{ item }}"
api_body:
Fec: "Auto"
PortId: "{{ item }}"
PortPolicy:
Moid: "{{ port_resp.api_response.Moid }}"
SlotId: 1
loop: "{{ range(17, 40 + 1) | list }}"
when: port_resp.api_response is defined and port_resp.api_response
- name: Configure Uplink Port Channel Roles
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/UplinkPcRoles
query_params:
$filter: "PortPolicy.Moid eq '{{ port_resp.api_response.Moid }}'"
api_body:
AdminSpeed: "Auto"
PcId: 1
PortPolicy:
Moid: "{{ port_resp.api_response.Moid }}"
Ports:
- PortId: 53
SlotId: 1
- PortId: 54
SlotId: 1
when: port_resp.api_response is defined and port_resp.api_response
I think the issue is with configure port 1-8 as FC links. any idea?
Solved! Go to Solution.
02-28-2024 06:53 AM
ok got it working now
- name: Configure Fabric Port 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) }}"
cisco.intersight.intersight_rest_api:
<<: *api_info
state: "{{ state | default('present') }}"
resource_path: /fabric/PortPolicies
query_params:
$filter: "Name eq '{{ port_policy_name_A }}'"
api_body:
Name: "{{ port_policy_name_A }}"
Description: "{{ port_policy_name_A_description }}"
DeviceModel: "UCS-FI-6454"
Organization:
Moid: "{{ intersight_org.api_response.Moid }}"
Tags: [{"Key": "configmode", "Value": "ansible"}, {"Key": "prefix", "Value": "{{ prefix }}"}]
register: port_resp
############################################
- name: Configure Fiber Channel Ports on 1-8
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/PortModes
query_params:
$filter: "Name eq '{{ port_policy_name_A }}'"
api_body:
PortIdEnd: 8
PortIdStart: 1
PortPolicy:
Moid: "{{ port_resp.api_response.Moid }}"
SlotId: 1
when: port_resp.api_response is defined and port_resp.api_response
###############################################
- name: Configure FC Roles
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/FcStorageRoles
query_params:
$filter: "PortPolicy.Moid eq '{{ port_resp.api_response.Moid }}' and PortId eq {{ item }}"
api_body:
AdminSpeed: 16Gbps
VsanId: 100
PortId: "{{ item }}"
PortPolicy:
Moid: "{{ port_resp.api_response.Moid }}"
SlotId: 1
loop: "{{ range(1, 8 + 1) | list }}"
when: port_resp.api_response is defined and port_resp.api_response
- name: Configure Server Roles
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/ServerRoles
query_params:
$filter: "PortPolicy.Moid eq '{{ port_resp.api_response.Moid }}' and PortId eq {{ item }}"
api_body:
Fec: "Auto"
PortId: "{{ item }}"
PortPolicy:
Moid: "{{ port_resp.api_response.Moid }}"
SlotId: 1
loop: "{{ range(17, 40 + 1) | list }}"
when: port_resp.api_response is defined and port_resp.api_response
- name: Configure Uplink Port Channel Roles Port Channel 1
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/UplinkPcRoles
query_params:
$filter: "Name eq '{{ port_policy_name_A }}'"
api_body:
AdminSpeed: "Auto"
PcId: 1
PortPolicy:
Moid: "{{ port_resp.api_response.Moid }}"
Ports:
- PortId: 47
SlotId: 1
- PortId: 48
SlotId: 1
when: port_resp.api_response is defined and port_resp.api_response
- name: Configure Uplink Port Channel Roles Port Channel 2
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/UplinkPcRoles
query_params:
$filter: "Name eq '{{ port_policy_name_A }}'"
api_body:
AdminSpeed: "Auto"
PcId: 2
PortPolicy:
Moid: "{{ port_resp.api_response.Moid }}"
Ports:
- PortId: 53
SlotId: 1
- PortId: 54
SlotId: 1
when: port_resp.api_response is defined and port_resp.api_response
02-28-2024 06:53 AM
ok got it working now
- name: Configure Fabric Port 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) }}"
cisco.intersight.intersight_rest_api:
<<: *api_info
state: "{{ state | default('present') }}"
resource_path: /fabric/PortPolicies
query_params:
$filter: "Name eq '{{ port_policy_name_A }}'"
api_body:
Name: "{{ port_policy_name_A }}"
Description: "{{ port_policy_name_A_description }}"
DeviceModel: "UCS-FI-6454"
Organization:
Moid: "{{ intersight_org.api_response.Moid }}"
Tags: [{"Key": "configmode", "Value": "ansible"}, {"Key": "prefix", "Value": "{{ prefix }}"}]
register: port_resp
############################################
- name: Configure Fiber Channel Ports on 1-8
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/PortModes
query_params:
$filter: "Name eq '{{ port_policy_name_A }}'"
api_body:
PortIdEnd: 8
PortIdStart: 1
PortPolicy:
Moid: "{{ port_resp.api_response.Moid }}"
SlotId: 1
when: port_resp.api_response is defined and port_resp.api_response
###############################################
- name: Configure FC Roles
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/FcStorageRoles
query_params:
$filter: "PortPolicy.Moid eq '{{ port_resp.api_response.Moid }}' and PortId eq {{ item }}"
api_body:
AdminSpeed: 16Gbps
VsanId: 100
PortId: "{{ item }}"
PortPolicy:
Moid: "{{ port_resp.api_response.Moid }}"
SlotId: 1
loop: "{{ range(1, 8 + 1) | list }}"
when: port_resp.api_response is defined and port_resp.api_response
- name: Configure Server Roles
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/ServerRoles
query_params:
$filter: "PortPolicy.Moid eq '{{ port_resp.api_response.Moid }}' and PortId eq {{ item }}"
api_body:
Fec: "Auto"
PortId: "{{ item }}"
PortPolicy:
Moid: "{{ port_resp.api_response.Moid }}"
SlotId: 1
loop: "{{ range(17, 40 + 1) | list }}"
when: port_resp.api_response is defined and port_resp.api_response
- name: Configure Uplink Port Channel Roles Port Channel 1
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/UplinkPcRoles
query_params:
$filter: "Name eq '{{ port_policy_name_A }}'"
api_body:
AdminSpeed: "Auto"
PcId: 1
PortPolicy:
Moid: "{{ port_resp.api_response.Moid }}"
Ports:
- PortId: 47
SlotId: 1
- PortId: 48
SlotId: 1
when: port_resp.api_response is defined and port_resp.api_response
- name: Configure Uplink Port Channel Roles Port Channel 2
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/UplinkPcRoles
query_params:
$filter: "Name eq '{{ port_policy_name_A }}'"
api_body:
AdminSpeed: "Auto"
PcId: 2
PortPolicy:
Moid: "{{ port_resp.api_response.Moid }}"
Ports:
- PortId: 53
SlotId: 1
- PortId: 54
SlotId: 1
when: port_resp.api_response is defined and port_resp.api_response
03-01-2024 07:46 AM
I am trying to create policy fo both A and B fabric like this. the policy gets created but the confguration of the unified ports task is skipped. any idea if its the when condiiton and what it should be?
- name: Configure Fabric Port 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) }}"
cisco.intersight.intersight_rest_api:
<<: *api_info
state: "{{ state | default('present') }}"
resource_path: /fabric/PortPolicies
query_params:
$filter: "Name eq '{{ item.name }}'"
api_body:
Name: "{{ item.name }}"
Description: "{{ item.description }}"
DeviceModel: "UCS-FI-6454"
Organization:
Moid: "{{ intersight_org.api_response.Moid }}"
Tags: [{"Key": "configmode", "Value": "ansible"}, {"Key": "prefix", "Value": "{{ prefix }}"}]
register: port_resp
loop: "{{ port_policies }}"
############################################
- name: Configure Fiber Channel Ports on 1-8
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/PortModes
query_params:
$filter: "Name eq '{{ item.name }}'"
api_body:
PortIdEnd: 8
PortIdStart: 1
PortPolicy:
Moid: "{{ port_resp.api_response.Moid }}"
SlotId: 1
when: port_resp.api_response is defined and port_resp.api_response
loop: "{{ port_policies }}"
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide