Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#34 (Inventory Upload): Add output to determine inventory upload failure #35

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions playbooks/inventory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,24 @@

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use conventional commit format (with footer) for ALL commit messages, please fix your commit message.

within the commits foote close #34.

If not known, since you have a single commit only, you can use git commit --amend to fix the commit message. Then you'll have to use git push --force to update the remote


- name: Upload inventory - {{ ansible_hostname }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name belongs to the task not the block.

The block will need a name however, possibly "Capture error and display trace information"

ansible.builtin.uri:
url: |-
{{ lookup('env', 'ITSM_API') }}/api/device/inventory

method: POST
body_format: json
src: "/tmp/{{ ansible_hostname }}.json"
remote_src: true
headers:
Authorization: Token {{ lookup('env', 'ITSM_TOKEN') }}
validate_certs: "{{ lookup('env', 'ITSM_VALIDATE_CERTS') | default(true) | bool }}"
timeout: 300
status_code:
- 200
- 201
no_log: > # Contains a secret that logging shows
{{ nfc_pb_disable_log | default(true) }}
block:
- ansible.builtin.uri:
Comment on lines +106 to +107
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
block:
- ansible.builtin.uri:
block:
- ansible.builtin.uri:

add two blank lines between tasks, begin and end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

task is missing name. return the name that it used to have

url: "{{ lookup('env', 'ITSM_API') }}/api/device/inventory"
method: POST
body_format: json
src: "/tmp/{{ ansible_hostname }}.json"
remote_src: true
headers:
Authorization: Token {{ lookup('env', 'ITSM_TOKEN') }}
validate_certs: "{{ lookup('env', 'ITSM_VALIDATE_CERTS') | default(true) | bool }}"
status_code:
- 200
- 201
no_log: > # Contains a secret that logging shows
{{ nfc_pb_disable_log | default(true) }}
rescue:
Comment on lines +120 to +121
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{{ nfc_pb_disable_log | default(true) }}
rescue:
{{ nfc_pb_disable_log | default(true) }}
rescue:

add two blank lines between tasks, begin and end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whilst the output will only be shown on error, which meets the intent of #34, the play will now, not fail. you'll need to add a task to ensure the play fails.

- debug:
Comment on lines +121 to +122
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rescue:
- debug:
rescue:
- debug:

add two blank lines between tasks, begin and end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use FQCN

msg: "Error uploading inventory: HTTP status {{ result.status }} - {{ result.msg }}"


always:
Expand Down
Loading