Files
computer-playbook/roles/svc-db-openldap/tasks/main.yml
Kevin Veen-Birkenbach 716ebef33b Refactor task includes and update variable handling for Ansible 2.20 migration
This commit updates multiple roles to ensure compatibility with Ansible 2.20.
Several include paths and task-loading mechanisms required adjustments,
as Ansible 2.20 applies stricter evaluation rules for complex Jinja expressions
and no longer resolves certain relative include paths the way Ansible 2.18 did.

Key changes:
- Replaced legacy once_finalize.yml and once_flag.yml with the new structure
  under tasks/utils/once/finalize.yml and tasks/utils/once/flag.yml.
- Updated all include_tasks statements to use 'path_join' with playbook_dir,
  ensuring deterministic and absolute file resolution across roles.
- Fixed all network helper includes by converting direct relative paths such as
  'roles/docker-compose/tasks/utils/network.yml' to proper Jinja-evaluated paths.
- Normalized MATOMO_* variable names for consistency with the updated variable
  scope behavior in Ansible 2.20.
- Removed deprecated patterns that were implicitly supported in Ansible 2.18
  but break under the more strict variable and path resolution model in 2.20.

These changes are part of the full migration step required to ensure the
infinito-nexus roles remain stable, deterministic, and forward-compatible with
Ansible 2.20.

Details of the discussion and reasoning can be found in this conversation:
https://chatgpt.com/share/69300a8d-24d4-800f-bec0-e895a695618a
2025-12-03 11:02:34 +01:00

79 lines
2.2 KiB
YAML

---
- name: "Setup docker network for {{ application_id }}"
include_tasks: "{{ [playbook_dir, 'roles/docker-compose/tasks/utils/network.yml' ] | path_join }}"
vars:
docker_network_name: "{{ OPENLDAP_NETWORK }}"
docker_network_subnet: "{{ networks.local[application_id].subnet }}"
- name: Create {{ domains | get_domain(application_id) }}.conf if LDAP is exposed to internet
template:
src: "nginx.stream.conf.j2"
dest: "{{ NGINX.DIRECTORIES.STREAMS }}{{ domains | get_domain(application_id) }}.conf"
notify: restart openresty
when: OPENLDAP_NETWORK_SWITCH_PUBLIC | bool
- name: Remove {{ domains | get_domain(application_id) }}.conf if LDAP is not exposed to internet
file:
path: "{{ NGINX.DIRECTORIES.STREAMS }}{{ domains | get_domain(application_id) }}.conf"
state: absent
when: not OPENLDAP_NETWORK_SWITCH_PUBLIC | bool
- name: "Wait for LDAP to be available"
wait_for:
host: "127.0.0.1"
port: "{{ ports.localhost.ldap[application_id] }}"
delay: 5
timeout: 120
state: started
- name: "Reset LDAP Credentials"
include_tasks: 01_credentials.yml
when:
- OPENLDAP_NETWORK_SWITCH_LOCAL | bool
- OPENLDAP_PROVISION_CREDENTIALS | bool
- name: "create directory {{ OPENLDAP_LDIF_PATH_HOST }}{{ item }}"
file:
path: "{{ OPENLDAP_LDIF_PATH_HOST }}{{ item }}"
state: directory
mode: "0755"
loop: "{{ OPENLDAP_LDIF_TYPES }}"
- name: "Import LDIF Configuration"
include_tasks: _ldifs_creation.yml
loop:
- configuration
loop_control:
loop_var: folder
when: OPENLDAP_PROVISION_CONFIGURATION | bool
- name: flush LDIF handlers
meta: flush_handlers
- name: install python-ldap
community.general.pacman:
name:
- python-ldap
state: present
- name: "Include Schemas (if enabled)"
include_tasks: 02_schemas.yml
when: OPENLDAP_PROVISION_SCHEMAS | bool
- name: "Import LDAP Entries (if enabled)"
include_tasks: 03_users.yml
when: OPENLDAP_PROVISION_USERS | bool
- name: "Import LDIF Data (if enabled)"
include_tasks: _ldifs_creation.yml
loop:
- groups
loop_control:
loop_var: folder
when: OPENLDAP_PROVISION_GROUPS | bool
- meta: flush_handlers
- name: "Add Objects to all users"
include_tasks: 04_update.yml
when: OPENLDAP_PROVISION_UPDATE | bool