03-07-2024 12:28 PM
i am able to create the chassis profile but having issues with assigning policies to it. any idea? I got the values from developer tools
- name: "Configure chassis profile"
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: /chassis/Profiles
query_params:
$filter: "Name eq '{{ chassis_profile_name }}'"
api_body: {
Name: "{{ chassis_profile_name }}",
Description: "{{ description_of_chassis_profile }}",
Organization: {
"Moid": "{{ intersight_org.api_response.Moid }}"
}}
register: chassis_profile
- name: "Get IMC Access Policy"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /access/Policies
query_params:
$filter: "Name eq '{{ name_of_imc_access_policy }}'"
register: imc_access
- name: "Get Power Policy"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /power/Policies
query_params:
$filter: "Name eq '{{ name_of_power_policy }}'"
register: power_policy
- name: "Get SNMP Policy"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /snmp/Policies
query_params:
$filter: "Name eq '{{ snmp_policy_name }}'"
register: snmp_policy
- name: "Get Thermal Policy"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /thermal/Policies
query_params:
$filter: "Name eq '{{ name_of_thermal_policy }}'"
register: thermal_policy
# Config Chassis Profile with Policy Bucket
- name: "Configure A Chassis Profile"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /chassis/Profiles
query_params:
$filter: "Name eq '{{ chassis_profile_name }}'"
api_body: {
"Name": "{{ chassis_profile_name }}",
"Profile": {
"Moid": "{{ chassis_profile.api_response.Moid }}"
},
"PolicyBucket": [
{
"Moid": "{{ thermal_policy.api_response.Moid }}",
"ObjectType": "thermal.Policy"
}
]}
when: chassis_profile.api_response is defined and chassis_profile.api_response
03-07-2024 02:50 PM
What output are you getting for the failed/malfunctioning step when you run the playbook with -vvv?
03-08-2024 06:08 AM
this is the error
"msg": "API error: (400, 'HTTP Error 400: Bad Request', b'{\"code\":\"InvalidRequest\",\"message\":\"Cannot create or modify the object \\'65ea392e77696e31016e33bd\\'. The property \\'chassis.Profile:Profile\\' does not exist.\",\"messageId\":\"barcelona_request_property_does_not_exist\",\"messageParams\":{\"1\":\"65ea392e77696e31016e33bd\",\"2\":\"chassis.Profile\",\"3\":\"Profile\"},\"traceId\":\"Pofm4ADB4trZ__ePI_52rC-j9Ag4WpOzHDbcqnYMDXTpDQMZmJyrHw==\"}') "
}
03-08-2024 07:46 AM
i think it does not like how i attach the tehermal policy in policybucket
03-08-2024 03:32 PM - edited 03-08-2024 03:44 PM
It seems that it is not expecting the "profile" key in your request body. I believe it isn't necessary to specify the name or moid of the profile in the body as it is already defined. As far as I can see the PolicyBucket specification looks good. Can you test with the following body?
{
"PolicyBucket": [
{
"Moid": "{{ thermal_policy.api_response.Moid }}",
"ObjectType": "thermal.Policy"
}
]
}
03-09-2024 12:05 AM - edited 03-09-2024 12:07 AM
Tested below sample code in lab:
- name: Create Chassis Profile
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: "/chassis/Profiles/{{ chassis_profile_X.api_response.Moid }}"
api_body: {
"PolicyBucket": [
{
"ObjectType": "access.Policy",
"Moid": "{{ imc_access_X.api_response.Moid }}"
}
]
}
state: present
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