Compare commits

..

2 Commits

Author SHA1 Message Date
c687b19a6d Added ldap ldif import draft 2025-02-11 18:09:26 +01:00
e193e92443 Added ldap roles draft 2025-02-11 16:19:08 +01:00
9 changed files with 163 additions and 127 deletions

View File

@ -8,7 +8,7 @@ docker_restart_policy: "unless-stopped"
############################################## ##############################################
# By default don't expose openldap to the internet, just if explicit configured # By default don't expose openldap to the internet, just if explicit configured
_ldap_openldap_expose_to_internet: "{{ applications.ldap.openldap.expose_to_internet if applications.ldap is defined and applications.ldap.openldap is defined else false}}" _ldap_openldap_expose_to_internet: "{{ applications.ldap.openldap.expose_to_internet | default(False) if applications.ldap is defined and applications.ldap.openldap is defined else false}}"
defaults_applications: defaults_applications:
@ -74,6 +74,7 @@ defaults_applications:
version: "latest" version: "latest"
expose_to_internet: "{{_ldap_openldap_expose_to_internet}}" # Set to true if you want to expose the LDAP port to the internet expose_to_internet: "{{_ldap_openldap_expose_to_internet}}" # Set to true if you want to expose the LDAP port to the internet
domain: "{{domains.ldap if _ldap_openldap_expose_to_internet else 'openldap'}}" # Mapping for public or locale access domain: "{{domains.ldap if _ldap_openldap_expose_to_internet else 'openldap'}}" # Mapping for public or locale access
modify: False # When false entries will just be added, when true existing entries will be modified during import procedure
phpldapadmin: phpldapadmin:
version: "2.0.0-dev" # @todo Attention: Change this as fast as released to latest version: "2.0.0-dev" # @todo Attention: Change this as fast as released to latest
webinterface: "lam" # The webinterface which should be used. Possible: lam and phpldapadmin webinterface: "lam" # The webinterface which should be used. Possible: lam and phpldapadmin

View File

@ -16,80 +16,21 @@ This Ansible role provides a streamlined implementation of an LDAP server with T
- **Healthcheck Support**: - **Healthcheck Support**:
- Ensures that the LDAP service is healthy and accessible using `ldapsearch`. - Ensures that the LDAP service is healthy and accessible using `ldapsearch`.
--- --
## Maintanance
## 📋 **Requirements** ### Show all Entires
```bash
### Prerequisites docker exec --env LDAP_ADMIN_PASSWORD="$LDAP_ADMIN_PASSWORD" -it openldap bash -c "ldapsearch -LLL -o ldif-wrap=no -x -D 'cn=administrator,dc=veen,dc=world' -w \"\$LDAP_ADMIN_PASSWORD\" -b 'dc=veen,dc=world'";
- A valid domain name.
- Ansible installed on the deployment host.
- Docker and Docker Compose installed on the target host.
---
## 🔧 **Role Variables**
### Key Variables
| Variable | Description | Default Value |
|-------------------------------|----------------------------------------------------------|--------------------------------------|
| `application_id` | Name of the Docker Compose project. | `ldap` |
| `ldap_root` | Base DN for the LDAP directory. | `dc={{primary_domain_sld}},dc={{primary_domain_tld}}` |
| `ldap_admin_dn` | Distinguished Name (DN) for the LDAP administrator. | `cn={{applications.ldap.administrator_username}},{{ldap_root}}` |
| `cert_mount_directory` | Directory to mount SSL/TLS certificates. | `{{docker_compose.directories.instance}}/certs/` |
| `applications.ldap.administrator_username` | Username for the LDAP admin. | `admin` |
| `applications.ldap.administrator_password` | Password for the LDAP admin. | _Required_ |
| `applications.ldap.phpldapadmin.version` | Version of phpLDAPadmin Docker image. | `latest` |
| `applications.ldap.openldap.version` | Version of OpenLDAP Docker image. | `latest` |
---
## 📂 **Role Structure**
```
roles/
docker-ldap/
README.md
vars/
main.yml
tasks/
main.yml
templates/
docker-compose.yml.j2
nginx.stream.conf.j2
``` ```
--- ### Delete Groups and Subgroup
To delete the group inclusive all subgroups use:
```bash
docker exec --env LDAP_ADMIN_PASSWORD="$LDAP_ADMIN_PASSWORD" -it openldap bash -c "ldapsearch -LLL -o ldif-wrap=no -x -D 'cn=administrator,dc=veen,dc=world' -w \"\$LDAP_ADMIN_PASSWORD\" -b 'ou=applications,ou=groups,dc=veen,dc=world' dn | sed -n 's/^dn: //p' | tac | while read -r dn; do echo \"Deleting \$dn\"; ldapdelete -x -D 'cn=administrator,dc=veen,dc=world' -w \"\$LDAP_ADMIN_PASSWORD\" \"\$dn\"; done"
## 📖 **Usage**
Heres an example playbook to use this role:
```yaml
- name: Deploy LDAP
hosts: ldap_servers
roles:
- role: docker-ldap
vars:
docker_compose.directories.instance: "/opt/docker/ldap/"
primary_domain_sld: "veen"
primary_domain_tld: "world"
applications.ldap.administrator_username: "administrator"
applications.ldap.administrator_password: "secure_password_here"
applications.ldap.phpldapadmin.version: "latest"
applications.ldap.openldap.version: "latest"
``` ```
### **Steps to Deploy:** --
1. Clone your playbook repository to the target server.
2. Run the playbook:
```bash
ansible-playbook -i inventory playbook.yml
```
3. Access phpLDAPadmin:
- URL: `http://localhost:8080` (or your configured port)
- Login: Use the admin DN and password.
---
## 🛠️ **Technical Details** ## 🛠️ **Technical Details**

View File

@ -0,0 +1,9 @@
- name: "import missing groups from {{ldif_docker_path}} to OpenLDAP"
shell: >
docker exec -i openldap {{ 'ldapmodify' if applications.ldap.openldap.modify|bool else 'ldapadd' }} -x -D "{{ldap_admin_dn}}" -w "{{applications.ldap.administrator_database_password}}" -c -f "{{ldif_docker_path}}{{ item }}"
loop: "{{ ldif_files }}"
register: ldapadd_result
changed_when: "'adding new entry' in ldapadd_result.stdout"
# Allow return code 0 (all entries added) or 68 (entry already exists)
failed_when: ldapadd_result.rc not in [0, 68]
listen: "Import missing groups to OpenLDAP"

View File

@ -44,3 +44,20 @@
force: yes force: yes
notify: docker compose project setup notify: docker compose project setup
when: applications.ldap.webinterface == 'lam' when: applications.ldap.webinterface == 'lam'
- name: flush docker service
meta: flush_handlers
- name: "create directory {{ldif_host_path}}"
file:
path: "{{ldif_host_path}}"
state: directory
mode: 0755
- name: "Create LDIF files at {{ldif_host_path}}"
template:
src: "templates/ldif/{{item}}.j2"
dest: "{{ldif_host_path}}{{item}}"
mode: '770'
notify: Import missing groups to OpenLDAP
loop: "{{ldif_files}}"

View File

@ -32,6 +32,7 @@ services:
{% endif %} {% endif %}
volumes: volumes:
- 'data:/bitnami/openldap' - 'data:/bitnami/openldap'
- '{{ldif_host_path}}:{{ldif_docker_path}}:ro' # Mounting all ldif files for import
healthcheck: healthcheck:
test: > test: >
ldapsearch -x -H ldap://localhost:389 -b "{{ldap_root}}" -D "{{ldap_admin_dn}}" -w "{{applications.ldap.administrator_database_password}}" ldapsearch -x -H ldap://localhost:389 -b "{{ldap_root}}" -D "{{ldap_admin_dn}}" -w "{{applications.ldap.administrator_database_password}}"

View File

@ -1,3 +1,8 @@
#######################################################################
# This file contains the CyMaIS default groups #
# Groupps define which kind of applications users have access to #
#######################################################################
####################################################################### #######################################################################
# Base container for all role-based groups # Base container for all role-based groups
####################################################################### #######################################################################
@ -7,156 +12,136 @@ ou: groups
description: Container for all role-based groups (by function/profession) description: Container for all role-based groups (by function/profession)
####################################################################### #######################################################################
# Role: System Administrator # Role: Administrators
####################################################################### #######################################################################
dn: cn=systemadministrator,ou=groups,dc=veen,dc=world dn: cn=administrator,ou=groups,dc=veen,dc=world
objectClass: groupOfNames objectClass: groupOfUniqueNames
cn: systemadministrator cn: administrators
description: Role: System Administrator (infrastructure, security, database management, etc.) description: Role: Administrators of this system
member: cn=dummy,ou=users,dc=veen,dc=world uniqueMember: cn=dummy,ou=users,dc=veen,dc=world
####################################################################### #######################################################################
# Role: Developer # Role: Developer
####################################################################### #######################################################################
dn: cn=developer,ou=groups,dc=veen,dc=world dn: cn=developer,ou=groups,dc=veen,dc=world
objectClass: groupOfNames objectClass: groupOfUniqueNames
cn: developer cn: developer
description: Role: Developer and DevOps (coding, automation, CI/CD, etc.) description: Role: Developer and DevOps (coding, automation, CI/CD, etc.)
member: cn=dummy,ou=users,dc=veen,dc=world uniqueMember: cn=dummy,ou=users,dc=veen,dc=world
####################################################################### #######################################################################
# Role: Project Manager # Role: Project Manager
####################################################################### #######################################################################
dn: cn=projectmanager,ou=groups,dc=veen,dc=world dn: cn=projectmanager,ou=groups,dc=veen,dc=world
objectClass: groupOfNames objectClass: groupOfUniqueNames
cn: projectmanager cn: projectmanager
description: Role: Project Manager and Collaboration (project planning, task management, etc.) description: Role: Project Manager and Collaboration (project planning, task management, etc.)
member: cn=dummy,ou=users,dc=veen,dc=world uniqueMember: cn=dummy,ou=users,dc=veen,dc=world
####################################################################### #######################################################################
# Role: Communication Specialist # Role: Communication Specialist
####################################################################### #######################################################################
dn: cn=communicationspecialist,ou=groups,dc=veen,dc=world dn: cn=communicationspecialist,ou=groups,dc=veen,dc=world
objectClass: groupOfNames objectClass: groupOfUniqueNames
cn: communicationspecialist cn: communicationspecialist
description: Role: Communication Specialist (community management, messaging, social networks, etc.) description: Role: Communication Specialist (community management, messaging, social networks, etc.)
member: cn=dummy,ou=users,dc=veen,dc=world uniqueMember: cn=dummy,ou=users,dc=veen,dc=world
####################################################################### #######################################################################
# Role: Content Manager # Role: Content Manager
####################################################################### #######################################################################
dn: cn=contentmanager,ou=groups,dc=veen,dc=world dn: cn=contentmanager,ou=groups,dc=veen,dc=world
objectClass: groupOfNames objectClass: groupOfUniqueNames
cn: contentmanager cn: contentmanager
description: Role: Content Manager/CMS Administrator (content creation, website management, etc.) description: Role: Content Manager/CMS Administrator (content creation, website management, etc.)
member: cn=dummy,ou=users,dc=veen,dc=world uniqueMember: cn=dummy,ou=users,dc=veen,dc=world
####################################################################### #######################################################################
# Role: Marketing Analyst # Role: Marketing Analyst
####################################################################### #######################################################################
dn: cn=marketinganalyst,ou=groups,dc=veen,dc=world dn: cn=marketinganalyst,ou=groups,dc=veen,dc=world
objectClass: groupOfNames objectClass: groupOfUniqueNames
cn: marketinganalyst
description: Role: Marketing, Finance & Analytics (marketing platforms, financial reporting, analytics, etc.)
member: cn=dummy,ou=users,dc=veen,dc=world
#######################################################################
# Role: Developer
#######################################################################
dn: cn=developer,ou=groups,dc=veen,dc=world
objectClass: groupOfNames
cn: developer
description: Role: Developer (coding, software development, and DevOps tasks)
member: cn=dummy,ou=users,dc=veen,dc=world
#######################################################################
# Role: Marketing Analyst
#######################################################################
dn: cn=marketinganalyst,ou=groups,dc=veen,dc=world
objectClass: groupOfNames
cn: marketinganalyst cn: marketinganalyst
description: Role: Marketing Analyst (marketing, finance, and analytics) description: Role: Marketing Analyst (marketing, finance, and analytics)
member: cn=dummy,ou=users,dc=veen,dc=world uniqueMember: cn=dummy,ou=users,dc=veen,dc=world
####################################################################### #######################################################################
# Role: DevOps Engineer # Role: DevOps Engineer
####################################################################### #######################################################################
dn: cn=devopsengineer,ou=groups,dc=veen,dc=world dn: cn=devopsengineer,ou=groups,dc=veen,dc=world
objectClass: groupOfNames objectClass: groupOfUniqueNames
cn: devopsengineer cn: devopsengineer
description: Role: DevOps Engineer (continuous integration, deployment, and container orchestration) description: Role: DevOps Engineer (continuous integration, deployment, and container orchestration)
member: cn=dummy,ou=users,dc=veen,dc=world uniqueMember: cn=dummy,ou=users,dc=veen,dc=world
####################################################################### #######################################################################
# Role: Database Administrator # Role: Database Administrator
####################################################################### #######################################################################
dn: cn=databaseadministrator,ou=groups,dc=veen,dc=world dn: cn=databaseadministrator,ou=groups,dc=veen,dc=world
objectClass: groupOfNames objectClass: groupOfUniqueNames
cn: databaseadministrator cn: databaseadministrator
description: Role: Database Administrator (database management and data integrity) description: Role: Database Administrator (database management and data integrity)
member: cn=dummy,ou=users,dc=veen,dc=world uniqueMember: cn=dummy,ou=users,dc=veen,dc=world
####################################################################### #######################################################################
# Role: Security Specialist # Role: Security Specialist
####################################################################### #######################################################################
dn: cn=securityspecialist,ou=groups,dc=veen,dc=world dn: cn=securityspecialist,ou=groups,dc=veen,dc=world
objectClass: groupOfNames objectClass: groupOfUniqueNames
cn: securityspecialist cn: securityspecialist
description: Role: Security Specialist (container security, vulnerability assessments, and compliance) description: Role: Security Specialist (container security, vulnerability assessments, and compliance)
member: cn=dummy,ou=users,dc=veen,dc=world uniqueMember: cn=dummy,ou=users,dc=veen,dc=world
####################################################################### #######################################################################
# Role: Network Administrator # Role: Network Administrator
####################################################################### #######################################################################
dn: cn=networkadministrator,ou=groups,dc=veen,dc=world dn: cn=networkadministrator,ou=groups,dc=veen,dc=world
objectClass: groupOfNames objectClass: groupOfUniqueNames
cn: networkadministrator cn: networkadministrator
description: Role: Network Administrator (network configuration, connectivity, and firewall management) description: Role: Network Administrator (network configuration, connectivity, and firewall management)
member: cn=dummy,ou=users,dc=veen,dc=world uniqueMember: cn=dummy,ou=users,dc=veen,dc=world
####################################################################### #######################################################################
# Role: IT Support Specialist # Role: IT Support Specialist
####################################################################### #######################################################################
dn: cn=itsupportspecialist,ou=groups,dc=veen,dc=world dn: cn=itsupportspecialist,ou=groups,dc=veen,dc=world
objectClass: groupOfNames objectClass: groupOfUniqueNames
cn: itsupportspecialist cn: itsupportspecialist
description: Role: IT Support Specialist (technical support and troubleshooting) description: Role: IT Support Specialist (technical support and troubleshooting)
member: cn=dummy,ou=users,dc=veen,dc=world uniqueMember: cn=dummy,ou=users,dc=veen,dc=world
####################################################################### #######################################################################
# Role: Quality Assurance Engineer # Role: Quality Assurance Engineer
####################################################################### #######################################################################
dn: cn=qualityassuranceengineer,ou=groups,dc=veen,dc=world dn: cn=qualityassuranceengineer,ou=groups,dc=veen,dc=world
objectClass: groupOfNames objectClass: groupOfUniqueNames
cn: qualityassuranceengineer cn: qualityassuranceengineer
description: Role: Quality Assurance Engineer (testing and ensuring software quality) description: Role: Quality Assurance Engineer (testing and ensuring software quality)
member: cn=dummy,ou=users,dc=veen,dc=world uniqueMember: cn=dummy,ou=users,dc=veen,dc=world
####################################################################### #######################################################################
# Role: Business Analyst # Role: Business Analyst
####################################################################### #######################################################################
dn: cn=businessanalyst,ou=groups,dc=veen,dc=world dn: cn=businessanalyst,ou=groups,dc=veen,dc=world
objectClass: groupOfNames objectClass: groupOfUniqueNames
cn: businessanalyst cn: businessanalyst
description: Role: Business Analyst (analyzing business requirements and translating them into technical needs) description: Role: Business Analyst (analyzing business requirements and translating them into technical needs)
member: cn=dummy,ou=users,dc=veen,dc=world uniqueMember: cn=dummy,ou=users,dc=veen,dc=world
####################################################################### #######################################################################
# Role: Product Owner # Role: Product Owner
####################################################################### #######################################################################
dn: cn=productowner,ou=groups,dc=veen,dc=world dn: cn=productowner,ou=groups,dc=veen,dc=world
objectClass: groupOfNames objectClass: groupOfUniqueNames
cn: productowner cn: productowner
description: Role: Product Owner (oversees product strategy and manages feature prioritization) description: Role: Product Owner (oversees product strategy and manages feature prioritization)
member: cn=dummy,ou=users,dc=veen,dc=world uniqueMember: cn=dummy,ou=users,dc=veen,dc=world
####################################################################### #######################################################################
# Role: Operations Manager # Role: Operations Manager
####################################################################### #######################################################################
dn: cn=operationsmanager,ou=groups,dc=veen,dc=world dn: cn=operationsmanager,ou=groups,dc=veen,dc=world
objectClass: groupOfNames objectClass: groupOfUniqueNames
cn: operationsmanager cn: operationsmanager
description: Role: Operations Manager (oversees daily operations and ensures system performance) description: Role: Operations Manager (oversees daily operations and ensures system performance)
member: cn=dummy,ou=users,dc=veen,dc=world uniqueMember: cn=dummy,ou=users,dc=veen,dc=world

View File

@ -0,0 +1,75 @@
#######################################################################
# This file contains the CyMaIS default roles
# Roles define which kind of rights users have
#######################################################################
#######################################################################
# Generic container for IT roles
#######################################################################
dn: ou=roles,dc=example,dc=com
objectClass: organizationalUnit
ou: roles
description: Container for generic IT roles (for rights management)
#######################################################################
# Role: Super Administrator
#######################################################################
dn: cn=superadministrator,ou=roles,dc=example,dc=com
objectClass: groupOfUniqueNames
cn: superadministrator
description: Role: Super Administrator has full control over all systems and settings.
uniqueMember: cn=dummy,ou=users,dc=example,dc=com
#######################################################################
# Role: Administrator
#######################################################################
dn: cn=administrator,ou=roles,dc=example,dc=com
objectClass: groupOfUniqueNames
cn: administrator
description: Role: Administrator responsible for overall system management and configuration.
uniqueMember: cn=dummy,ou=users,dc=example,dc=com
#######################################################################
# Role: Manager
#######################################################################
dn: cn=manager,ou=roles,dc=example,dc=com
objectClass: groupOfUniqueNames
cn: manager
description: Role: Manager oversees operations, approves changes, and coordinates teams.
uniqueMember: cn=dummy,ou=users,dc=example,dc=com
#######################################################################
# Role: Moderator
#######################################################################
dn: cn=moderator,ou=roles,dc=example,dc=com
objectClass: groupOfUniqueNames
cn: moderator
description: Role: Moderator monitors activity and handles conflict resolution.
uniqueMember: cn=dummy,ou=users,dc=example,dc=com
#######################################################################
# Role: Publisher
#######################################################################
dn: cn=publisher,ou=roles,dc=example,dc=com
objectClass: groupOfUniqueNames
cn: publisher
description: Role: Publisher responsible for releasing content or updates.
uniqueMember: cn=dummy,ou=users,dc=example,dc=com
#######################################################################
# Role: Contributor
#######################################################################
dn: cn=contributor,ou=roles,dc=veen,dc=world
objectClass: groupOfUniqueNames
cn: contributor
description: Contributor (Allowed to participate, but not to publish)
uniqueMember: cn=dummy,ou=users,dc=veen,dc=world
#######################################################################
# Role: Subscriber
#######################################################################
dn: cn=subscriber,ou=roles,dc=veen,dc=world
objectClass: groupOfUniqueNames
cn: subscriber
description: Subscriber (read-only; manage own profile)
uniqueMember: cn=dummy,ou=users,dc=veen,dc=world

View File

@ -0,0 +1 @@
# Default users

View File

@ -4,11 +4,17 @@ ldap_admin_dn: "cn={{applications.ldap.administrator_username}},{
ldap_secure_localhost_port: 1636 ldap_secure_localhost_port: 1636
ldap_secure_internet_port: 636 ldap_secure_internet_port: 636
ldap_localhost_port: 389 ldap_localhost_port: 389
ldap_network_enabled: "{{ldap.enabled}}"
# OAuth2 Proxy Configuration # OAuth2 Proxy Configuration
oauth2_proxy_upstream_application_and_port: "{{ applications.ldap.webinterface }}:{% if applications.ldap.webinterface == 'phpldapadmin' %}8080{% else %}80{% endif %}" oauth2_proxy_upstream_application_and_port: "{{ applications.ldap.webinterface }}:{% if applications.ldap.webinterface == 'phpldapadmin' %}8080{% else %}80{% endif %}"
oauth2_proxy_active: true oauth2_proxy_active: true
enable_wildcard_certificate: false # Activate dedicated Certificate enable_wildcard_certificate: false # Activate dedicated Certificate
ldap_network_enabled: "{{ldap.enabled}}" # Configuration for ldif import
ldif_files:
- "groups.ldif"
- "roles.ldif"
- "users.ldif"
ldif_host_path: "{{docker_compose.directories.volumes}}ldif/"
ldif_docker_path: "/tmp/ldif/"