refactor(api_config): updated flow and docs

!1
This commit is contained in:
2023-07-29 12:03:40 +09:30
parent 4407e57fdd
commit d2902b9ab0
4 changed files with 30 additions and 14 deletions

View File

@ -45,6 +45,15 @@ Each tab provides an example of the JSON file layout, including any additional v
!!! info !!! info
The structure of this JSON file is different than the rest. The body is a **list** of **ALL** of the Config options. This includes the item ID. it was done this way, so that only one API query is required to export all config options. The structure of this JSON file is different than the rest. The body is a **list** of **ALL** of the Config options. This includes the item ID. it was done this way, so that only one API query is required to export all config options.
!!! info "Further Information"
Any config item that does not contain a value field, is excluded from being added or updated. In addition, the following items by name, are excluded
``` yaml title="tasks/api/excluded_config.yaml" linenums="1"
--8<-- "tasks/api/excluded_config.yaml"
```
=== "Entity" === "Entity"
``` json title="example.json" linenums="1" ``` json title="example.json" linenums="1"

View File

@ -1,16 +1,11 @@
--- ---
- name: Show {{ list_item.body.name }}
ansible.builtin.debug:
msg: "{{ list_item }}"
- name: Fetch ID for {{ list_item.body.name }} - name: Fetch ID for {{ list_item.body.name }}
ansible.builtin.uri: ansible.builtin.uri:
url: "http://{{ glpi.host }}/apirest.php/{{ item.api_path }}?searchText[name]={{ list_item.body.name | urlencode }}" url: "http://{{ glpi.host }}/apirest.php/{{ item.api_path }}?searchText[name]={{ list_item.body.name | urlencode }}"
method: "GET" method: "GET"
return_content: true return_content: true
body: '' body: ''
# status_code: "{{ item.status_code | from_yaml | list }}"
status_code: [200, 201] status_code: [200, 201]
headers: headers:
App-Token: "{{ glpi.app_token }}" App-Token: "{{ glpi.app_token }}"

View File

@ -0,0 +1,16 @@
---
- name: Config Items to skip
ansible.builtin.set_fact:
skip_config:
- cas_version
- dbversion
- _dbslave_status
- init_all
- notification_uuid
- proxy_passwd
- registration_uuid
- schema_version
- smtp_passwd
- version
when: item.api_path == 'Config'

View File

@ -13,14 +13,8 @@
- name: Config Items to skip - name: Config Items to skip
ansible.builtin.set_fact: ansible.builtin.import_tasks:
skip_config: file: api/excluded_config.yaml
- cas_version
- dbversion
- _dbslave_status
- schema_version
- version
when: item.api_path == 'Config'
- name: Config - name: Config
@ -30,6 +24,8 @@
item.api_path == 'Config' item.api_path == 'Config'
and and
not sub_item.name in skip_config not sub_item.name in skip_config
and
sub_item.value is defined
loop: "{{ item_body }}" loop: "{{ item_body }}"
loop_control: loop_control:
loop_var: sub_item loop_var: sub_item
@ -39,7 +35,7 @@
body: body:
context: "{{ sub_item.context }}" context: "{{ sub_item.context }}"
name: "{{ sub_item.name }}" name: "{{ sub_item.name }}"
value: "{{ sub_item.value | default('') }}" value: "{{ sub_item.value }}"
- name: Clear temp vars - name: Clear temp vars