49 lines
1.2 KiB
YAML
49 lines
1.2 KiB
YAML
---
|
|
|
|
- name: Search item_id
|
|
ansible.builtin.include_tasks:
|
|
file: api/search/item_id.yaml
|
|
when: >
|
|
not item.body.id is defined
|
|
|
|
|
|
- name: Show Body
|
|
ansible.builtin.debug:
|
|
msg: "{{ item_body }}"
|
|
when: item_body is defined
|
|
|
|
|
|
- name: Create Item
|
|
ansible.builtin.uri:
|
|
url: "http://{{ glpi.host }}/apirest.php/{{ item.api_path }}"
|
|
method: "POST"
|
|
return_content: true
|
|
body: "{\"input\": {{ item_body | from_yaml | to_json }} }"
|
|
status_code: [200, 201]
|
|
headers:
|
|
App-Token: "{{ glpi.app_token }}"
|
|
Session-Token: "{{ glpi.session.valid_id }}"
|
|
body_format: json
|
|
no_log: true
|
|
when: not item_body.id is defined
|
|
|
|
|
|
- name: Update Item
|
|
ansible.builtin.uri:
|
|
url: "http://{{ glpi.host }}/apirest.php/{{ item.api_path }}{% if item.api_path != 'Config' %}/{{ item_body.id }}{% endif %}"
|
|
method: "PATCH"
|
|
return_content: true
|
|
body: "{\"input\": {{ item_body | from_yaml | to_json }} }"
|
|
status_code: [200, 201]
|
|
headers:
|
|
App-Token: "{{ glpi.app_token }}"
|
|
Session-Token: "{{ glpi.session.valid_id }}"
|
|
body_format: json
|
|
no_log: true
|
|
when: item_body.id is defined
|
|
|
|
|
|
- name: Clear temp vars
|
|
ansible.builtin.set_fact:
|
|
item_body: {}
|