This is again a failed attempt.... To summarise, a task is failing with an error about malformed JSON, if you run it in a loop. And it succeeds without a loop. So, if you run both of them using -v, this will allow you to compare their invocation (to be precise, the api_body key). You should compare that value between the failed and successful run.
On Fri, 15 Sept 2023 at 23:18, Tony Wong <[email protected]> wrote: > added debug to the loop > > The full traceback is: > File > "/var/folders/_f/psbm0b654t9c729qy7r_xl240000gn/T/ansible_cisco.intersight.intersight_rest_api_payload_dxt4y__0/ansible_cisco.intersight.intersight_rest_api_payload.zip/ansible_collections/cisco/intersight/plugins/module_utils/intersight.py", > line 243, in call_api > raise RuntimeError(info['status'], info['msg'], info['body']) > 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, > "invocation": { > "module_args": { > "api_body": { > "AssignmentOrder": "default", > "Description": "UUID Pool 1", > "Name": "UUID Pool 1", > "Organization": { > "Moid": "64fb3cc06972653301785b28" > }, > "Prefix": "00000000-0000-0000", > "Tags": [ > { > "Key": "configmode", > "Value": "ansible" > }, > { > "Key": "prefix", > "Value": "PKXXXPK" > } > ], > "UuidSuffixBlocks": [ > { > "From": "0000-000000000001", > "Size": "100" > } > ] > }, > "api_key_id": > "64fb3cbd7564613301d27632/64fb3cbe7564613301d27636/64fe94c77564613301f091c2", > "api_private_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", > "api_uri": "https://intersight.com/api/v1", > "list_body": null, > "query_params": { > "$filter": "Name eq 'UUID Pool 1'" > }, > "resource_path": "/uuidpool/Pools", > "return_list": false, > "state": "present", > "update_method": "patch", > "use_proxy": true, > "validate_certs": true > } > }, > "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\":\"ur4PRfwWJ10NUyohmov0beVOPV4DCu_Mkab1JyqRHBL371h-FJKcEQ==\",\"cause\":{\"code\":\"InternalServerError\",\"message\":\"Cannot > execute the request due to an error. Retry > later.\",\"messageId\":\"barcelona_request_internal_error\",\"traceId\":\"ur4PRfwWJ10NUyohmov0beVOPV4DCu_Mkab1JyqRHBL371h-FJKcEQ==\"}}') > " > > On Fri, Sep 15, 2023 at 1:08 PM Tony Wong <[email protected]> wrote: > >> this is from the successful attempt without loop >> >> >> TASK [create_pools : Create UUID Pool1] >> ************************************************************* >> ok: [localhost] => {"api_response": {"AccountMoid": >> "64fb3cbd7564613301d27632", "Ancestors": [], "Assigned": 0, >> "AssignmentOrder": "default", "BlockHeads": [{"ClassId": "mo.MoRef", >> "Moid": "65036e7069627531010b73cc", "ObjectType": "uuidpool.Block", "link": >> " >> https://www.intersight.com/api/v1/uuidpool/Blocks/65036e7069627531010b73cc"}], >> "ClassId": "uuidpool.Pool", "CreateTime": "2023-09-14T20:34:56.056Z", >> "Description": "UUID_default_01", "DomainGroupMoid": >> "64fb3cbd7564613301d27633", "ModTime": "2023-09-14T20:34:56.064Z", "Moid": >> "65036e7069627531010b73c9", "Name": "UUID_default_01", "ObjectType": >> "uuidpool.Pool", "Organization": {"ClassId": "mo.MoRef", "Moid": >> "64fb3cc06972653301785b28", "ObjectType": "organization.Organization", >> "link": " >> https://www.intersight.com/api/v1/organization/Organizations/64fb3cc06972653301785b28"}, >> "Owners": ["64fb3cbd7564613301d27632"], "PermissionResources": [{"ClassId": >> "mo.MoRef", "Moid": "64fb3cc06972653301785b28", "ObjectType": >> "organization.Organization", "link": " >> https://www.intersight.com/api/v1/organization/Organizations/64fb3cc06972653301785b28"}], >> "Prefix": "00000000-0000-0000", "Reservations": [], "Reserved": 0, >> "SharedScope": "", "Size": 100, "Tags": [{"Key": "configmode", "Value": >> "ansible"}, {"Key": "prefix", "Value": "PKXXXPK"}], "UuidSuffixBlocks": >> [{"ClassId": "uuidpool.UuidBlock", "From": "0000-000000000001", >> "ObjectType": "uuidpool.UuidBlock", "Size": 100, "To": >> "0000-000000000064"}]}, "changed": false, "trace_id": >> "Cvz_QEUlWzAC1sIt_gToSQMndG0T9FtgfA7_j4r87Gdy62jJzp_eTQ=="} >> >> TASK [create_pools : Create UUID Pool2] >> ************************************************************* >> ok: [localhost] => {"api_response": {"AccountMoid": >> "64fb3cbd7564613301d27632", "Ancestors": [], "Assigned": 0, >> "AssignmentOrder": "default", "BlockHeads": [{"ClassId": "mo.MoRef", >> "Moid": "65036e7169627531010b73d2", "ObjectType": "uuidpool.Block", "link": >> " >> https://www.intersight.com/api/v1/uuidpool/Blocks/65036e7169627531010b73d2"}], >> "ClassId": "uuidpool.Pool", "CreateTime": "2023-09-14T20:34:57.18Z", >> "Description": "liprd-uuid-pool", "DomainGroupMoid": >> "64fb3cbd7564613301d27633", "ModTime": "2023-09-14T20:34:57.187Z", "Moid": >> "65036e7169627531010b73cf", "Name": "liprd-uuid-pool", "ObjectType": >> "uuidpool.Pool", "Organization": {"ClassId": "mo.MoRef", "Moid": >> "64fb3cc06972653301785b28", "ObjectType": "organization.Organization", >> "link": " >> https://www.intersight.com/api/v1/organization/Organizations/64fb3cc06972653301785b28"}, >> "Owners": ["64fb3cbd7564613301d27632"], "PermissionResources": [{"ClassId": >> "mo.MoRef", "Moid": "64fb3cc06972653301785b28", "ObjectType": >> "organization.Organization", "link": " >> https://www.intersight.com/api/v1/organization/Organizations/64fb3cc06972653301785b28"}], >> "Prefix": "00000000-3000-0000", "Reservations": [], "Reserved": 0, >> "SharedScope": "", "Size": 20, "Tags": [{"Key": "configmode", "Value": >> "ansible"}, {"Key": "prefix", "Value": "PKXXXPK"}], "UuidSuffixBlocks": >> [{"ClassId": "uuidpool.UuidBlock", "From": "0000-000000000001", >> "ObjectType": "uuidpool.UuidBlock", "Size": 20, "To": >> "0000-000000000014"}]}, "changed": false, "trace_id": >> "3QF47O7jzsQWGHSx5Loo0HE-KXuV5G9G_gj2WzdUGSmPAOCYJBrxTg=="} >> >> On Fri, Sep 15, 2023 at 12:00 PM Dick Visser <[email protected]> wrote: >> >>> >>> This looks like another failed attempt. >>> Compare a failed attempt with a successful attempt using -v and look >>> closely at the payload. >>> >>> >>> Sent from Gmail Mobile >>> >>> >>> On Fri, 15 Sep 2023 at 16:15, Tony Wong <[email protected]> wrote: >>> >>>> 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\":\"3W5INgQdjpSiG4-JcJ4GUxrlpnuU7Ksyjj2zDfhbucx5_enmAf2wHw==\",\"cause\":{\"code\":\"InternalServerError\",\"message\":\"Cannot >>>> execute the request due to an error. Retry >>>> later.\",\"messageId\":\"barcelona_request_internal_error\",\"traceId\":\"3W5INgQdjpSiG4-JcJ4GUxrlpnuU7Ksyjj2zDfhbucx5_enmAf2wHw==\"}}') >>>> "} >>>> 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\":\"VZYagTdrbBl92Gj4ePwQdT1-Ttwce57ZJYiCdkZ0bmz1CFpzsJ1h-A==\",\"cause\":{\"code\":\"InternalServerError\",\"message\":\"Cannot >>>> execute the request due to an error. Retry >>>> later.\",\"messageId\":\"barcelona_request_internal_error\",\"traceId\":\"VZYagTdrbBl92Gj4ePwQdT1-Ttwce57ZJYiCdkZ0bmz1CFpzsJ1h-A==\"}}') >>>> "} >>>> >>>> PLAY RECAP >>>> ****************************************************************************************** >>>> localhost : ok=10 changed=0 unreachable=0 >>>> failed=1 skipped=0 rescued=0 ignored=0 >>>> >>>> On Fri, Sep 15, 2023 at 12:38 AM Dick Visser <[email protected]> >>>> wrote: >>>> >>>>> >>>>> >>>>> On Fri, 15 Sept 2023 at 00:30, Tony Wong <[email protected]> wrote: >>>>> >>>>>> The dictionary loop is not working. But when I specify the parameters >>>>>> not in a dictionary and not in a loop it works. >>>>>> >>>>> >>>>> Run that with -v, and then compare the invocation dict with the one >>>>> above that fails. >>>>> >>>>> -- >>>>> You received this message because you are subscribed to a topic in the >>>>> Google Groups "Ansible Project" group. >>>>> To unsubscribe from this topic, visit >>>>> https://groups.google.com/d/topic/ansible-project/2IhA8gwVLuM/unsubscribe >>>>> . >>>>> To unsubscribe from this group and all its topics, send an email to >>>>> [email protected]. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/ansible-project/CAF8BbLZ0DV%3DGG-JkM2_SB7ekww72H%2Bs2ebRXAc2kFv49BbEoAQ%40mail.gmail.com >>>>> <https://groups.google.com/d/msgid/ansible-project/CAF8BbLZ0DV%3DGG-JkM2_SB7ekww72H%2Bs2ebRXAc2kFv49BbEoAQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Ansible Project" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/ansible-project/CALmkhkq%2BFGygw136EbWgzVOWE4dJbcnkWqfLDqiP0mVUdvt%2BFA%40mail.gmail.com >>>> <https://groups.google.com/d/msgid/ansible-project/CALmkhkq%2BFGygw136EbWgzVOWE4dJbcnkWqfLDqiP0mVUdvt%2BFA%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "Ansible Project" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/ansible-project/2IhA8gwVLuM/unsubscribe >>> . >>> To unsubscribe from this group and all its topics, send an email to >>> [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/ansible-project/CAF8BbLZLN4xnXyMdqj%2BZj8Kr2fm3mNx5NQDh-RALSFpoSvzFwQ%40mail.gmail.com >>> <https://groups.google.com/d/msgid/ansible-project/CAF8BbLZLN4xnXyMdqj%2BZj8Kr2fm3mNx5NQDh-RALSFpoSvzFwQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/CALmkhkpbdbQBtY2ejx00Gspz096vH90Sb%2BWyLq7965HFkahfog%40mail.gmail.com > <https://groups.google.com/d/msgid/ansible-project/CALmkhkpbdbQBtY2ejx00Gspz096vH90Sb%2BWyLq7965HFkahfog%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAF8BbLb3xAHdV0GSXhLGAjk-f8WwinZnRhaVvu%2BM%3DuHTV%2BfPTw%40mail.gmail.com.
