Hi,
I have a list of 200+ items (showing sample below).  I need to update a 
database with these records using the URI module.  The backend API only 
supports 100 records at at time.  
How can I loop through the URI module with 100 records at a time.  I was 
thinking of using json_query and doing slicing as per the JMEPath docs but 
cant find any examples of the syntax for Ansible.
If using the json_quere, I would need some sort of variable in the slice.

  - name: Add/Update switchport in cmdb
    uri:
      url: https://{{ cmdb }}/{{ switchports }}/batchUpsert
      method: PUT
      validate_certs: no
      body_format: json
      body: '{{ new_list | json_query([:100] }}'
    register: batchupsert_result
   loop:???



    "new_list": [
        {
            "description": null,
            "id": "cjzu47wi6000301yu0dse3q53",
            "lastSeenDate": "2019-09-05 10:06:42",
            "mediaType": "access",
            "name": "GigabitEthernet2/1/1",
            "poeEnabledInd": true,
            "portDuplexModeId": "cjzodb84y001201fmbox90ygt",
            "portFastInd": true,
            "portSpeedId": "cjzodk5zx001301fmac9u54oc",
            "securityShutdownInd": "false",
            "status": "down",
            "voiceInd": false
        },
        {
            "description": null,
            "id": "cjzu4jsq1000u01yu9cw4a9h7",
            "lastSeenDate": "2019-09-05 10:06:42",
            "mediaType": "access",
            "name": "GigabitEthernet2/0/9",
            "poeEnabledInd": true,
            "portDuplexModeId": "cjzodb84y001201fmbox90ygt",
            "portFastInd": true,
            "portSpeedId": "cjzodk5zx001301fmac9u54oc",
            "securityShutdownInd": "false",
            "status": "down",
            "voiceInd": false
        },
        {
            "description": null,
            "id": "cjzu4jxhc000v01yuf9c7atd3",
            "lastSeenDate": "2019-09-05 10:06:42",
            "mediaType": "access",
            "name": "TenGigabitEthernet2/1/3",
            "poeEnabledInd": true,
            "portDuplexModeId": "cjzodb84y001201fmbox90ygt",
            "portFastInd": true,
            "portSpeedId": "cjzodk5zx001301fmac9u54oc",
            "securityShutdownInd": "false",
            "status": "shutdown",
            "voiceInd": false
        },
        {
            "description": null,
            "id": "cjzu48c09000401yu1o443fuq",
            "lastSeenDate": "2019-09-05 10:06:42",
            "mediaType": "access",
            "name": "TenGigabitEthernet2/1/4",
            "poeEnabledInd": true,
            "portDuplexModeId": "cjzodb84y001201fmbox90ygt",
            "portFastInd": true,
            "portSpeedId": "cjzodk5zx001301fmac9u54oc",
            "securityShutdownInd": "false",
            "status": "down",
            "voiceInd": false
        }
    ]



-- 
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/5e0510be-e7bf-4b3c-b40f-829c953f75d8%40googlegroups.com.

Reply via email to