diff --git a/docs/projects/nfc_glpi/config_from_code.md b/docs/projects/nfc_glpi/config_from_code.md index 1257d79..7d73a28 100644 --- a/docs/projects/nfc_glpi/config_from_code.md +++ b/docs/projects/nfc_glpi/config_from_code.md @@ -45,6 +45,15 @@ Each tab provides an example of the JSON file layout, including any additional v !!! 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. + !!! 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" ``` json title="example.json" linenums="1" diff --git a/tasks/api/config.yaml b/tasks/api/config.yaml index fb6fc1e..4a86aff 100644 --- a/tasks/api/config.yaml +++ b/tasks/api/config.yaml @@ -1,16 +1,11 @@ --- -- name: Show {{ list_item.body.name }} - ansible.builtin.debug: - msg: "{{ list_item }}" - - name: Fetch ID for {{ list_item.body.name }} ansible.builtin.uri: url: "http://{{ glpi.host }}/apirest.php/{{ item.api_path }}?searchText[name]={{ list_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 }}" diff --git a/tasks/api/excluded_config.yaml b/tasks/api/excluded_config.yaml new file mode 100644 index 0000000..75995d2 --- /dev/null +++ b/tasks/api/excluded_config.yaml @@ -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' diff --git a/tasks/api/search-add.yaml b/tasks/api/search-add.yaml index 3234ec8..03bd8a1 100644 --- a/tasks/api/search-add.yaml +++ b/tasks/api/search-add.yaml @@ -13,14 +13,8 @@ - name: Config Items to skip - ansible.builtin.set_fact: - skip_config: - - cas_version - - dbversion - - _dbslave_status - - schema_version - - version - when: item.api_path == 'Config' + ansible.builtin.import_tasks: + file: api/excluded_config.yaml - name: Config @@ -30,6 +24,8 @@ item.api_path == 'Config' and not sub_item.name in skip_config + and + sub_item.value is defined loop: "{{ item_body }}" loop_control: loop_var: sub_item @@ -39,7 +35,7 @@ body: context: "{{ sub_item.context }}" name: "{{ sub_item.name }}" - value: "{{ sub_item.value | default('') }}" + value: "{{ sub_item.value }}" - name: Clear temp vars