So I have a little PB that makes and API call to get some data:

- name: API Commmand to get Snipe-IT List User asests checked out
       ansible.builtin.uri:
        url: http://snipeit.xxx.com/api/v1/users/{{uuid}}/assets
        headers:
          Authorization: '{{ snipe }}'
          Content-Type: "application/json"
        method: GET
        return_content: yes
        status_code:
          - 200
       register: asset_content

     - debug:
        msg: '{{asset_content.json }}'
=================================================================
it gives me (TMI):
{
  "msg": {
    "total": 2,
    "rows": [
      {
        "id": 54,
        "name": "",
        "asset_tag": "10.246.76.194",
        "serial": "",
        "model": {
          "id": 51,
          "name": "Openstack Director"
        },
        "model_number": null,
        "eol": null,
        "status_label": {
          "id": 2,
          "name": "Ready to Deploy",
          "status_type": "deployable",
          "status_meta": "deployable"
        },
        "category": {
          "id": 2,
          "name": "R640 Compute"
        },
        "manufacturer": {
          "id": 1,
          "name": "Dell Compute"
        },
        "supplier": null,
        "notes": null,
        "order_number": null,
        "company": null,
        "location": null,
        "rtd_location": {
          "id": 1,
          "name": "COS - ARV"
        },
        "image": null,
        "qr": null,
        "alt_barcode": 
"http://snipeit.devops.XXXXXXXXXXXXXX.com/uploads/barcodes/c128-1024676194.png";,
        "assigned_to": null,
        "warranty_months": null,
        "warranty_expires": null,
        "created_at": {
          "datetime": "2022-11-11 21:20:54",
          "formatted": "2022-11-11 09:20 PM"
        },
        "updated_at": {
          "datetime": "2022-11-14 23:36:38",
          "formatted": "2022-11-14 11:36 PM"
        },
        "last_audit_date": null,
        "next_audit_date": null,
        "deleted_at": null,
        "purchase_date": null,
        "last_checkout": {
          "datetime": "2022-11-14 23:36:38",
          "formatted": "2022-11-14 11:36 PM"
        },
        "expected_checkin": null,
        "purchase_cost": null,
        "checkin_counter": 0,
        "checkout_counter": 1,
        "requests_counter": 0,
        "user_can_checkout": false,
        "custom_fields": [],
        "available_actions": {
          "checkout": true,
          "checkin": true,
          "clone": true,
          "restore": false,
          "update": true,
          "delete": false
        }
      },
      {
        "id": 58,
        "name": "",
        "asset_tag": "10.246.76.28",
        "serial": "",
        "model": {
          "id": 53,
          "name": "vCenter Teledyne"
        },
        "model_number": null,
        "eol": null,
        "status_label": {
          "id": 2,
          "name": "Ready to Deploy",
          "status_type": "deployable",
          "status_meta": "deployable"
        },
        "category": {
          "id": 3,
          "name": "Peripherals"
        },
        "manufacturer": {
          "id": 5,
          "name": "Teledyne Q-Flex"
        },
        "supplier": null,
        "notes": null,
        "order_number": null,
        "company": null,
        "location": null,
        "rtd_location": {
          "id": 1,
          "name": "COS - ARV"
        },
        "image": null,
        "qr": null,
        "alt_barcode": 
"http://snipeit.devops.XXXXXXXXXXXXXX.com/uploads/barcodes/c128-102467628.png";,
        "assigned_to": null,
        "warranty_months": null,
        "warranty_expires": null,
        "created_at": {
          "datetime": "2022-11-11 21:20:54",
          "formatted": "2022-11-11 09:20 PM"
        },
        "updated_at": {
          "datetime": "2022-11-14 21:52:55",
          "formatted": "2022-11-14 09:52 PM"
        },
        "last_audit_date": null,
        "next_audit_date": null,
        "deleted_at": null,
        "purchase_date": null,
        "last_checkout": {
          "datetime": "2022-11-11 21:27:13",
          "formatted": "2022-11-11 09:27 PM"
        },
        "expected_checkin": {
          "date": "2022-11-14",
          "formatted": "2022-11-14"
        },
        "purchase_cost": null,
        "checkin_counter": 0,
        "checkout_counter": 1,
        "requests_counter": 0,
        "user_can_checkout": false,
        "custom_fields": [],
        "available_actions": {
          "checkout": true,
          "checkin": true,
          "clone": true,
          "restore": false,
          "update": true,
          "delete": false
        }
      }
    ]
  },
  "_ansible_verbose_always": true,
  "_ansible_no_log": false,
  "changed": false
}
=======================================================================

now the issue I want  to do I just want the 

{
        "id": 54,
        "name": "",
        "asset_tag": "10.246.76.194",
        "serial": "",
        "model": {
          "id": 51,
          "name": "Openstack Director"
        },

and 

 "category": {
          "id": 2,
          "name": "R640 Compute"
        },
and
        "manufacturer": {
          "id": 1,
          "name": "Dell Compute"
        },

and there could me more then 1 set of this data, plus I am at a total loss 
on how to do it been trying with jq and just get errors at my wits end here 
i am no json expert any help I would be grateful

Thanks

W

-- 
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/318b9160-729a-49fe-92df-58db535f5eb3n%40googlegroups.com.

Reply via email to