feat(ldap-user-backend): add role for managing ldap user backend in nextcloud
This commit is contained in:
45
roles/ldap-user-backend/tasks/main.yml
Normal file
45
roles/ldap-user-backend/tasks/main.yml
Normal file
@ -0,0 +1,45 @@
|
||||
---
|
||||
|
||||
- name: Default api config
|
||||
meta: noop
|
||||
vars: &api_defaults
|
||||
http_agent: "{{ nc_ldap_meta_http_agent }}"
|
||||
headers: "{{ nc_ldap_api_headers }}"
|
||||
url_username: "{{ nc_ldap_api_basic_auth_user }}"
|
||||
url_password: "{{ nc_ldap_api_basic_auth_password }}"
|
||||
force_basic_auth: yes
|
||||
force: yes
|
||||
|
||||
- name: Check if configuration with given config ID already exists
|
||||
uri:
|
||||
<<: *api_defaults
|
||||
url: "{{ nc_ldap_api_path }}/{{ nc_ldap_config_id }}{{ query_params }}"
|
||||
method: GET
|
||||
vars:
|
||||
query_params: "?showPassword=1&format={{nc_ldap_api_parameter_format }}"
|
||||
|
||||
register: nc_ldap_existing_config
|
||||
|
||||
# TODO: Can we force an ID on POST?
|
||||
- name: Create ldap configuration with id={{ nc_ldap_config_id }}
|
||||
uri:
|
||||
<<: *api_defaults
|
||||
url: "{{ nc_ldap_api_path }}"
|
||||
method: POST
|
||||
when: nc_ldap_existing_config.status != 200
|
||||
|
||||
- name: Create changeset
|
||||
set_fact:
|
||||
nc_ldap_config_changeset: "{{ nc_ldap_config_changeset | combine(changed_entry) }}"
|
||||
vars:
|
||||
changed_entry: "{{ { item : nc_ldap_config_keys[item] } }}"
|
||||
loops: "{{ nc_ldap_config_keys.keys() }}"
|
||||
when: "{{ nc_ldap_config_keys[item] is defined and nc_ldap_config_keys[item] is not None }}"
|
||||
|
||||
- name: Ensure ldap configuration is in sync
|
||||
uri:
|
||||
<<: *api_defaults
|
||||
url:
|
||||
method: PUT
|
||||
body:
|
||||
body_format: "form-urlencoded"
|
Reference in New Issue
Block a user