nofusscomputing / ansible_collection_centurion

Ansible Collection for Centurion ERP. https://gitlab.com/nofusscomputing/projects/centurion_erp
0 stars 2 forks source link

Add output to determine inventory upload failure #34

Open jon-nfc opened 1 day ago

jon-nfc commented 1 day ago

failure to upload an inventory should show output.

Details

The inventory upload task should be inside a block so that a task can be setup to show the HTTP status code and the message .msg to stdout on error.

Example ERROR json


{
  "redirected": false,
  "url": "--- truncated---",
  "status": 401,
  "date": "Thu, 31 Oct 2024 15:18:09 GMT",
  "content_type": "application/json",
  "content_length": "58",
  "connection": "close",
  "www_authenticate": "Token",
  "vary": "Accept, Cookie",
  "allow": "POST, OPTIONS",
  "x_frame_options": "DENY",
  "x_content_type_options": "nosniff",
  "referrer_policy": "same-origin",
  "cross_origin_opener_policy": "same-origin",
  "strict_transport_security": "max-age=15724800; includeSubDomains",
  "elapsed": 3,
  "changed": false,
  "json": {
    "detail": "Authentication credentials were not provided."
  },
  "msg": "Status code was 401 and not [200, 201]: HTTP Error 401: Unauthorized",
  "invocation": {
    "module_args": {
      "url": "--- truncated---",
      "method": "POST",
      "body_format": "json",
      "src": "/tmp/--- truncated---.json",
      "remote_src": true,
      "headers": {
        "Authorization": "Token --- truncated---",
        "Content-Type": "application/json",
        "Content-Length": 32922
      },
      "validate_certs": false,
      "timeout": 300,
      "status_code": [
        200,
        201
      ],
      "force": false,
      "http_agent": "ansible-httpget",
      "use_proxy": true,
      "force_basic_auth": false,
      "use_gssapi": false,
      "return_content": false,
      "follow_redirects": "safe",
      "unredirected_headers": [],
      "decompress": true,
      "use_netrc": true,
      "unsafe_writes": false,
      "url_username": null,
      "url_password": null,
      "client_cert": null,
      "client_key": null,
      "dest": null,
      "body": null,
      "creates": null,
      "removes": null,
      "unix_socket": null,
      "ca_path": null,
      "ciphers": null,
      "mode": null,
      "owner": null,
      "group": null,
      "seuser": null,
      "serole": null,
      "selevel": null,
      "setype": null,
      "attributes": null
    }
  },
  "_ansible_no_log": false
}
pvcasillasg commented 1 day ago

PR: https://github.com/nofusscomputing/ansible_collection_centurion/pull/35