mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-15 16:40:45 +02:00
- Introduce global async configuration in group_vars/all/00_general.yml: - ASYNC_ENABLED (disabled in debug mode) - ASYNC_TIME (default 300s, omitted if async disabled) - ASYNC_POLL (0 for async fire-and-forget, 10 for sync mode) - Replace hardcoded async/poll values with global vars in: - svc-db-openldap (03_users.yml, 04_update.yml) - web-app-mig (02_build_data.yml) - web-app-nextcloud (03_admin.yml, 04_system_config.yml, 05_plugin.yml, 06_plugin_routines.yml, 07_plugin_enable_and_configure.yml) - Guard changed_when and failed_when conditions to only evaluate in synchronous mode to avoid accessing undefined rc/stdout/stderr in async runs https://chatgpt.com/share/689cd8cc-7fbc-800f-bd06-a667561573bf
57 lines
2.5 KiB
YAML
57 lines
2.5 KiB
YAML
###############################################################################
|
|
# 1) Create the LDAP entry if it does not yet exist
|
|
###############################################################################
|
|
- name: Ensure LDAP users exist
|
|
community.general.ldap_entry:
|
|
dn: "{{ ldap.user.attributes.id }}={{ item.key }},{{ ldap.dn.ou.users }}"
|
|
server_uri: "{{ openldap_server_uri }}"
|
|
bind_dn: "{{ ldap.dn.administrator.data }}"
|
|
bind_pw: "{{ ldap.bind_credential }}"
|
|
objectClass: "{{ ldap.user.objects.structural }}"
|
|
attributes:
|
|
uid: "{{ item.value.username }}"
|
|
sn: "{{ item.value.sn | default(item.key) }}"
|
|
cn: "{{ item.value.cn | default(item.key) }}"
|
|
userPassword: "{SSHA}{{ item.value.password }}"
|
|
loginShell: /bin/bash
|
|
homeDirectory: "/home/{{ item.key }}"
|
|
uidNumber: "{{ item.value.uid | int }}"
|
|
gidNumber: "{{ item.value.gid | int }}"
|
|
state: present # ↳ creates but never updates
|
|
async: "{{ ASYNC_TIME if ASYNC_ENABLED else omit }}"
|
|
poll: "{{ ASYNC_POLL if ASYNC_ENABLED else omit }}"
|
|
loop: "{{ users | dict2items }}"
|
|
loop_control:
|
|
label: "{{ item.key }}"
|
|
|
|
###############################################################################
|
|
# 2) Keep the objectClass list AND the mail attribute up-to-date
|
|
###############################################################################
|
|
- name: Ensure required objectClass values and mail address are present
|
|
community.general.ldap_attrs:
|
|
dn: "{{ ldap.user.attributes.id }}={{ item.key }},{{ ldap.dn.ou.users }}"
|
|
server_uri: "{{ openldap_server_uri }}"
|
|
bind_dn: "{{ ldap.dn.administrator.data }}"
|
|
bind_pw: "{{ ldap.bind_credential }}"
|
|
attributes:
|
|
objectClass: "{{ ldap.user.objects.structural }}"
|
|
mail: "{{ item.value.email }}"
|
|
state: exact
|
|
async: "{{ ASYNC_TIME if ASYNC_ENABLED else omit }}"
|
|
poll: "{{ ASYNC_POLL if ASYNC_ENABLED else omit }}"
|
|
loop: "{{ users | dict2items }}"
|
|
loop_control:
|
|
label: "{{ item.key }}"
|
|
|
|
- name: "Ensure container for application roles exists"
|
|
community.general.ldap_entry:
|
|
dn: "{{ ldap.dn.ou.roles }}"
|
|
server_uri: "{{ openldap_server_uri }}"
|
|
bind_dn: "{{ ldap.dn.administrator.data }}"
|
|
bind_pw: "{{ ldap.bind_credential }}"
|
|
objectClass: organizationalUnit
|
|
attributes:
|
|
ou: roles
|
|
description: Container for application access profiles
|
|
state: present
|