cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
175
Views
0
Helpful
5
Replies

ansible chassis profile

tdubb123
Level 1
Level 1

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

 

 

 

5 Replies 5

Torbjørn
Spotlight
Spotlight

What output are you getting for the failed/malfunctioning step when you run the playbook with -vvv?

Happy to help! Please mark as helpful/solution if applicable.
Get in touch: https://torbjorn.dev

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==\"}') "
}

i think it does not like how i attach the tehermal policy in policybucket

 

"PolicyBucket": [
{
"Moid": "{{ thermal_policy.api_response.Moid }}",
"ObjectType": "thermal.Policy"
}
]
 
is therew something wrong with this ?

Torbjørn
Spotlight
Spotlight

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"
}
]
}

 

Happy to help! Please mark as helpful/solution if applicable.
Get in touch: https://torbjorn.dev

Sandeep Kumar
Cisco Employee
Cisco Employee

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