Cisco FMC PortGroupObject id extraction

I am trying to extract port object ids from an API call to cisco FMC using Ansible and it has been a nightmare. After I extract the portobject ids, I’ll use it to create a portobject group. This is a part of the overall code. I am trying to automate route-based VPNs. My code is below

When I try to access the ids, I get <built-in method items of dict object at 0x7efc91b5bb40>"

This doesn’t seem to be an error but I don’t know how to workaround or fix this to get the desired outcome. Please help me!!

Code snippet:

  • hosts: wa-fmc2500
    connection: httpapi
    tasks:
    • name: Get Domain UUID
      cisco.fmcansible.fmc_configuration:
      operation: getAllDomain
      register_as: domain

    • name: Execute ‘getAllProtocolPortObject’ operation
      cisco.fmcansible.fmc_configuration:
      operation: “getAllProtocolPortObject”
      path_params:
      domainUUID: “{{ domain[0].uuid }}”
      query_params:
      filter: “nameOrValue:{{ item }}”
      loop:

      • obj_tcp_www
      • obj_tcp_https
      • obj_tcp_8080
      • obj_tcp_8443
      • obj_tcp_8092
      • obj_tcp_8095
      • obj_tcp_8161
      • obj_tcp_8300-8499
      • obj_tcp_9300-9499
      • obj_tcp_9600-9799
        register: portobj
    • debug:
      msg: “{{ portobj.results[0].response.items }}”

Code output:


(ansible_netauto) [rezeh@netauto fmc_ansible]$ ansible-playbook  get_proto_objs_2.yml 

PLAY [wa-fmc2500] *********************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************
ok: [wa-fmc2500]

TASK [Get Domain UUID] ****************************************************************************************************
ok: [wa-fmc2500]

TASK [Execute 'getAllProtocolPortObject' operation] ***********************************************************************
ok: [wa-fmc2500] => (item=obj_tcp_www)
ok: [wa-fmc2500] => (item=obj_tcp_https)
ok: [wa-fmc2500] => (item=obj_tcp_8080)
ok: [wa-fmc2500] => (item=obj_tcp_8443)
ok: [wa-fmc2500] => (item=obj_tcp_8092)
ok: [wa-fmc2500] => (item=obj_tcp_8095)
ok: [wa-fmc2500] => (item=obj_tcp_8161)
ok: [wa-fmc2500] => (item=obj_tcp_8300-8499)
ok: [wa-fmc2500] => (item=obj_tcp_9300-9499)
ok: [wa-fmc2500] => (item=obj_tcp_9600-9799)

TASK [debug] **************************************************************************************************************
ok: [wa-fmc2500] => {
    "msg": {
        "items": [
            {
                "id": "40CE2481-5D56-0ed3-0000-081604387193",
                "links": {
                    "parent": "https://wa-fmc2500/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/object/ports",
                    "self": "https://wa-fmc2500/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/object/protocolportobjects/40CE2481-5D56-0ed3-0000-081604387193"
                },
                "name": "obj_tcp_www",
                "type": "ProtocolPortObject"
            },
            {
                "id": "40CE2481-5D56-0ed3-0000-081604387201",
                "links": {
                    "parent": "https://wa-fmc2500/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/object/ports",
                    "self": "https://wa-fmc2500/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/object/protocolportobjects/40CE2481-5D56-0ed3-0000-081604387201"
                },
                "name": "obj_tcp_www1",
                "type": "ProtocolPortObject"
            },
            {
                "id": "40CE2481-5D56-0ed3-0000-081604387331",
                "links": {
                    "parent": "https://wa-fmc2500/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/object/ports",
                    "self": "https://wa-fmc2500/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/object/protocolportobjects/40CE2481-5D56-0ed3-0000-081604387331"
                },
                "name": "obj_tcp_www2",
                "type": "ProtocolPortObject"
            },
            {
                "id": "40CE2481-5D56-0ed3-0000-176094395035",
                "links": {
                    "parent": "https://wa-fmc2500/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/object/ports",
                    "self": "https://wa-fmc2500/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/object/protocolportobjects/40CE2481-5D56-0ed3-0000-176094395035"
                },
                "name": "obj_tcp_www3",
                "type": "ProtocolPortObject"
            }
        ],
        "links": {
            "self": "https://wa-fmc2500/api/fmc_config/v1/domain/e276abec-e0f2-11e3-8169-6d9ed49b625f/object/protocolportobjects?offset=0&limit=25&filter=nameOrValue:obj_tcp_www"
        },
        "paging": {
            "count": 4,
            "limit": 25,
            "offset": 0,
            "pages": 1
        }
    }
}

PLAY RECAP ****************************************************************************************************************
wa-fmc2500                 : ok=4    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

(ansible_netauto) [rezeh@netauto fmc_ansible]$ vim get_proto_objs_2.yml 
(ansible_netauto) [rezeh@netauto fmc_ansible]$ ansible-playbook  get_proto_objs_2.yml 

PLAY [wa-fmc2500] *********************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************
ok: [wa-fmc2500]

TASK [Get Domain UUID] ****************************************************************************************************
ok: [wa-fmc2500]

TASK [Execute 'getAllProtocolPortObject' operation] ***********************************************************************
ok: [wa-fmc2500] => (item=obj_tcp_www)
ok: [wa-fmc2500] => (item=obj_tcp_https)
ok: [wa-fmc2500] => (item=obj_tcp_8080)
ok: [wa-fmc2500] => (item=obj_tcp_8443)
ok: [wa-fmc2500] => (item=obj_tcp_8092)
ok: [wa-fmc2500] => (item=obj_tcp_8095)
ok: [wa-fmc2500] => (item=obj_tcp_8161)
ok: [wa-fmc2500] => (item=obj_tcp_8300-8499)
ok: [wa-fmc2500] => (item=obj_tcp_9300-9499)
ok: [wa-fmc2500] => (item=obj_tcp_9600-9799)

TASK [debug] **************************************************************************************************************
ok: [wa-fmc2500] => {
    "msg": "<built-in method items of dict object at 0x7efc91b5bb40>"
}

PLAY RECAP ****************************************************************************************************************
wa-fmc2500                 : ok=4    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0