ansible ucs intersight error with loop and dictionary list

38 Views Asked by At

any idea why I keep getting this error with this pb?

---
---
- name: "Create UUID Pool"
  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: /uuidpool/Pools
    query_params:
      $filter: "Name eq '{{ item.name_of_uuid_pool }}'"
    api_body: {
      "Name": "{{ item.name_of_uuid_pool }}",
      "Description": "{{ item.name_of_uuid_pool }}",
      "Organization": {
        "Moid": "{{ intersight_org.api_response.Moid }}"
      },
      Tags: [{Key: "configmode", Value: "ansible"}, {Key: "prefix", Value: "{{ prefix }}"}],

      "AssignmentOrder": "default",
      "Prefix": "{{ item.uuid_prefix }}",
      "UuidSuffixBlocks": [
        {
          "From": "{{ item.uuid_from }}",
          "Size": "{{ item.uuid_size }}"
        }
      ]
     }
  with_items: "{{ uuid_pools }}"
  register: uuid_pool_result

the error I get is

TASK [create_pools : Create UUID Pool] **************************************************************
failed: [localhost] (item={'name_of_uuid_pool': 'UUID Pool 1', 'uuid_prefix': '00000000-0000-0000', 'uuid_size': 100, 'uuid_from': '0000-000000000001'}) => {"ansible_loop_var": "item", "changed": false, "item": {"name_of_uuid_pool": "UUID Pool 1", "uuid_from": "0000-000000000001", "uuid_prefix": "00000000-0000-0000", "uuid_size": 100}, "msg": "API error: (400, 'HTTP Error 400: Bad Request', b'{\"code\":\"InvalidRequest\",\"message\":\"Cannot execute the request. The JSON document is malformed.\",\"messageId\":\"barcelona_request_malformed_json\",\"traceId\":\"MITgFj7I9LY9WhE3CmsPWPyfXM6nIqWYFeeBrGUXx5cHPLBhZNY8sg==\",\"cause\":{\"code\":\"InternalServerError\",\"message\":\"Cannot execute the request due to an error. Retry later.\",\"messageId\":\"barcelona_request_internal_error\",\"traceId\":\"MITgFj7I9LY9WhE3CmsPWPyfXM6nIqWYFeeBrGUXx5cHPLBhZNY8sg==\"}}') "}
failed: [localhost] (item={'name_of_uuid_pool': 'UUID Pool 2', 'uuid_prefix': '11111111-1111-1111', 'uuid_size': 50, 'uuid_from': '1111-111111111101'}) => {"ansible_loop_var": "item", "changed": false, "item": {"name_of_uuid_pool": "UUID Pool 2", "uuid_from": "1111-111111111101", "uuid_prefix": "11111111-1111-1111", "uuid_size": 50}, "msg": "API error: (400, 'HTTP Error 400: Bad Request', b'{\"code\":\"InvalidRequest\",\"message\":\"Cannot execute the request. The JSON document is malformed.\",\"messageId\":\"barcelona_request_malformed_json\",\"traceId\":\"uCoQYEn3PXD6v9QT6d8Nz3KDNGP_7KrDsa3Gnz75YuuXecj5ALedPw==\",\"cause\":{\"code\":\"InternalServerError\",\"message\":\"Cannot execute the request due to an error. Retry later.\",\"messageId\":\"barcelona_request_internal_error\",\"traceId\":\"uCoQYEn3PXD6v9QT6d8Nz3KDNGP_7KrDsa3Gnz75YuuXecj5ALedPw==\"}}') "}

My dictionary list is

uuid_pools:
  - name_of_uuid_pool: "UUID Pool 1"
    uuid_prefix: "00000000-0000-0000"
    uuid_size: 100
    uuid_from: "0000-000000000001"

  - name_of_uuid_pool: "UUID Pool 2"
    uuid_prefix: "11111111-1111-1111"
    uuid_size: 50
    uuid_from: "1111-111111111101"

If i change this to not using a loop it works just fine. but not with the loop and dictionary list

any idea how to resolve this?

0

There are 0 best solutions below