chore(ldap_user_backend): cleanup
This commit is contained in:
@@ -1,22 +1,24 @@
|
||||
---
|
||||
|
||||
- name: Check if configuration with given config ID already exists
|
||||
community.docker.docker_container_exec:
|
||||
vars: &_nc_ldap_container_parameters
|
||||
container: "{{ nc_ldap_container }}"
|
||||
command: "{{ nc_ldap_occ_command }} ldap:show-config --output json {{ '--show-password' if nc_ldap_config_agent_password else '' }} {{ nc_ldap_config_id }}"
|
||||
user: "{{ nc_ldap_occ_user }}"
|
||||
tty: yes
|
||||
tty: true
|
||||
community.docker.docker_container_exec:
|
||||
<<: *_nc_ldap_container_parameters
|
||||
command: >-2
|
||||
{{ nc_ldap_occ_command }} ldap:show-config --output json {{ '--show-password' if nc_ldap_config_agent_password else '' }} {{ nc_ldap_config_id }}
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
register: nc_ldap_existing_config_occ
|
||||
|
||||
- name: Create ldap configuration with id={{ nc_ldap_config_id }}
|
||||
community.docker.docker_container_exec:
|
||||
container: "{{ nc_ldap_container }}"
|
||||
<<: *_nc_ldap_container_parameters
|
||||
command: "{{ nc_ldap_occ_command }} ldap:create-empty-config --output json {{ nc_ldap_config_id }}"
|
||||
user: "{{ nc_ldap_occ_user }}"
|
||||
tty: yes
|
||||
when: nc_ldap_existing_config_occ.rc != 0 and nc_ldap_config_id not in (nc_ldap_existing_config_occ.stdout | from_json).keys()
|
||||
when: >-2
|
||||
(nc_ldap_existing_config_occ.rc != 0)
|
||||
and nc_ldap_config_id not in (nc_ldap_existing_config_occ.stdout | from_json).keys()
|
||||
|
||||
- name: Parse output of query command to dict
|
||||
ansible.builtin.set_fact:
|
||||
@@ -29,21 +31,20 @@
|
||||
vars:
|
||||
changed_entry: "{{ { item : nc_ldap_config_keys[item] } }}"
|
||||
loop: "{{ nc_ldap_config_keys.keys() }}"
|
||||
when: ((nc_ldap_config_keys[item] is defined) and nc_ldap_config_keys[item] and (nc_ldap_config_keys[item] != nc_ldap_existing_config[nc_ldap_config_id][item])) | bool
|
||||
when: >-2
|
||||
((nc_ldap_config_keys[item] is defined)
|
||||
and nc_ldap_config_keys[item]
|
||||
and (nc_ldap_config_keys[item] != nc_ldap_existing_config[nc_ldap_config_id][item])) | bool
|
||||
|
||||
- name: Ensure ldap configuration is in sync
|
||||
community.docker.docker_container_exec:
|
||||
container: "{{ nc_ldap_container }}"
|
||||
<<: *_nc_ldap_container_parameters
|
||||
command: "{{ nc_ldap_occ_command }} ldap:set-config \"{{ nc_ldap_config_id }}\" \"{{ item.key }}\" \"{{ item.value }}\""
|
||||
user: "{{ nc_ldap_occ_user }}"
|
||||
tty: yes
|
||||
loop: "{{ nc_ldap_config_changeset | dict2items }}"
|
||||
|
||||
- name: Ensure ldap configuration is working
|
||||
community.docker.docker_container_exec:
|
||||
container: "{{ nc_ldap_container }}"
|
||||
<<: *_nc_ldap_container_parameters
|
||||
command: "{{ nc_ldap_occ_command }} ldap:test-config {{ nc_ldap_config_id }}"
|
||||
user: "{{ nc_ldap_occ_user }}"
|
||||
tty: yes
|
||||
changed_when: false
|
||||
when: nc_ldap_test_configuration
|
||||
|
||||
Reference in New Issue
Block a user