32 lines
841 B
YAML
32 lines
841 B
YAML
---
|
|
- name: Find Item ID
|
|
ansible.builtin.uri:
|
|
url: "http://{{ glpi.host }}/apirest.php/{{ item.api_path }}?searchText[name]={{ item.body.name | urlencode }}"
|
|
method: "GET"
|
|
return_content: true
|
|
body: ''
|
|
# status_code: "{{ item.status_code | from_yaml | list }}"
|
|
status_code: [200, 201]
|
|
headers:
|
|
App-Token: "{{ glpi.app_token }}"
|
|
Session-Token: "{{ glpi.session.valid_id }}"
|
|
body_format: json
|
|
register: glpi_search
|
|
no_log: true
|
|
|
|
|
|
- name: Set id
|
|
ansible.builtin.set_fact:
|
|
new_data:
|
|
id: "{{ glpi_search.json[0].id | int }}"
|
|
when: glpi_search.json | length | int == 1
|
|
|
|
|
|
- name: Append id
|
|
ansible.builtin.set_fact:
|
|
item_body: "{{ item_body | ansible.builtin.combine(new_data) }}"
|
|
glpi_search: {}
|
|
new_data: {}
|
|
no_log: true
|
|
when: glpi_search.json | length | int == 1
|