Skip to content

Commit

Permalink
update to OpenLDAP 2.6 + deploy certificates + new multi-master recipe (
Browse files Browse the repository at this point in the history
  • Loading branch information
David Coutadeur committed Nov 21, 2024
1 parent 695a689 commit ec41ed7
Show file tree
Hide file tree
Showing 19 changed files with 593 additions and 238 deletions.
37 changes: 20 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ You'll need to store the hash value for your admin passwords. You'll get it like
/usr/local/openldap/sbin/slappasswd -o module-path="/usr/local/openldap/libexec/openldap" -o module-load="argon2" -h "{ARGON2}" -s "password"
```

Store the passwords in the vault file in: `tests/credentials-vault.yml`
Store the passwords in the vault file in: `playbook/credentials-vault.yml`


Playbook examples
Expand All @@ -38,46 +38,49 @@ ansible.cfg
roles_path=../
```

See `tests/standalone.yml`
See `playbook/standalone.yml`

Run playbook with:


```
ansible-playbook tests/standalone.yml -i tests/inventory --ask-vault-pass
ansible-playbook playbook/standalone.yml -i playbook/inventory --ask-vault-pass
```

or:
You can also run an openldap cluster with 2 masters and 2 slaves with the multimaster playbook:

```
ansible-playbook tests/standalone.yml -i tests/inventory --vault-password-file .vault_pass
ansible-playbook playbook/multimaster.yml -i playbook/inventory --ask-vault-pass
```

If you need a two-nodes multimaster example, give a look at `tests/multimaster1.yml` and `tests/multimaster2.yml`
or:

```
ansible-playbook playbook/multimaster.yml -i playbook/inventory --vault-password-file .vault_pass
```

Give a look to `tests/monitoring.yml` for an example of playbook that deploys LTB monitoring and statistics tools
For using this cluster, you must create the corresponding machines and declare the routes, as defined in `playbook/inventory`.

Run the corresponding task with:
You also have to fill the certificate in `playbook/certificates-vault.yml`. You can use this command for editing the file: (the default password is: secret)

```
ansible-playbook tests/monitoring.yml -i tests/inventory
ansible-vault edit playbook/certificates-vault.yml
```


If you want to install openldap on RHEL-like OS with certificates, you can define them in `tests/standalone.yml`:
Give a look at `playbook/group_vars/prod.yml`, `playbook/host_vars/master1.yml` and `playbook/host_vars/master2.yml` for variable customization
You can also use `--extra-vars variable=value` at the command line for overloading any variable.

```
ldaptoolbox_openldap_olcTLSCACertificateFile=/etc/pki/ca-trust/source/anchors/ca-cert.pem
ldaptoolbox_openldap_olcTLSCertificateFile=/etc/pki/tls/certs/ldaps-cert.pem
ldaptoolbox_openldap_olcTLSCertificateKeyFile=/etc/pki/tls/private/ldaps.key
```

You can also overload these variables in the command line:
Give a look to `playbook/monitoring.yml` for an example of playbook that deploys LTB monitoring and statistics tools

Run the corresponding task with:

```
ansible-playbook tests/standalone.yml -i tests/inventory --ask-vault-pass --extra-vars "ldaptoolbox_openldap_olcTLSCACertificateFile=/etc/pki/ca-trust/source/anchors/ca-cert.pem ldaptoolbox_openldap_olcTLSCertificateFile=/etc/pki/tls/certs/ldaps-cert.pem ldaptoolbox_openldap_olcTLSCertificateKeyFile=/etc/pki/tls/private/ldaps.key"
ansible-playbook playbook/monitoring.yml -i playbook/inventory
```


License
-------

Expand Down
5 changes: 5 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[defaults]
roles_path=../
[colors]
warn = white
error = yellow
69 changes: 20 additions & 49 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ldaptoolbox_openldap_apt_key_url: "https://ltb-project.org/documentation/_static
ldaptoolbox_openldap_apt_key_id: "3FC3FD92ABA3975D2BEB95A70AC51F926D45BFC5"
ldaptoolbox_openldap_apt_repo_filename: "ltb-project-openldap"
ldaptoolbox_openldap_apt_keyrings_path: /usr/share/keyrings
ldaptoolbox_openldap_apt_repo: "deb [arch=amd64 signed-by=/usr/share/keyrings/ltb-project-openldap.gpg] http://ltb-project.org/debian/openldap25/bullseye bullseye main"
ldaptoolbox_openldap_apt_repo: "deb [arch=amd64 signed-by=/usr/share/keyrings/ltb-project-openldap.gpg] http://ltb-project.org/debian/openldap26/bookworm bookworm main"
ldaptoolbox_openldap_apt_validate_certs: "true"

# Packages
Expand All @@ -35,6 +35,10 @@ ldaptoolbox_openldap_slapd_cli_cmd: /usr/local/openldap/sbin/slapd-cli
# OpenLDAP configuration
################################################################################

# Options
olcAttributeOptions:
- lang-

# Suffix
ldaptoolbox_openldap_suffix: "{{ ldaptoolbox_openldap_suffix }}"

Expand All @@ -51,13 +55,20 @@ ldaptoolbox_openldap_olcTLSProtocolMin: 3.3

# Log level
ldaptoolbox_openldap_olcLogLevel: stats
ldaptoolbox_openldap_olcLogFile: "/var/log/slapd-ltb/slapd.log"
ldaptoolbox_openldap_olcLogFileRotate: "30 1024 24"

# Size limit
ldaptoolbox_openldap_olcSizeLimit: 1000

# Enabled modules
ldaptoolbox_openldap_module_list:
- argon2.la
- pw-pbkdf2.la
- pw-sha2.la
- back_mdb.la
- dynlist.la
- memberof.la
- ppolicy.la
- syncprov.la
- unique.la
Expand Down Expand Up @@ -104,59 +115,19 @@ ldaptoolbox_openldap_database_olcLimits:

# Indexes definition
ldaptoolbox_openldap_database_olcDbIndexes:
- "entryCSN,entryUUID eq"
- "objectClass eq"
- "entryUUID eq"
- "entryCSN eq"
- "cn pres,eq,sub"
- "uid pres,eq,sub"

########################
# Replication directives
########################
- "cn eq,sub"
- "uid pres,eq"
- "givenName pres,eq,sub"
- "l pres,eq"
- "employeeType pres,eq"
- "mail pres,eq,sub"
- "sn pres,eq,sub"

ldaptoolbox_openldap_olcServerID: 1
ldaptoolbox_openldap_syncrepl:
- rid: "001"
provider: "ldap://localhost:389/"
tlscert: "{{ ldaptoolbox_openldap_olcTLSCertificateFile }}"
tlskey: "{{ ldaptoolbox_openldap_olcTLSCertificateKeyFile }}"
tlscacert: "{{ ldaptoolbox_openldap_olcTLSCACertificateFile }}"
tlsreqcert: "demand"
binddn: "uid=syncrepl,ou=accounts,ou=infrastructure,{{ ldaptoolbox_openldap_suffix }}"
password: "{{ ldaptoolbox_openldap_syncrepl_password_vault }}"
searchbase: "{{ ldaptoolbox_openldap_suffix }}"
scope: "sub"
type: "refreshAndPersist"
retry: "5 5 300 +"
- rid: "002"
provider: "ldap://localhost:389/"
tlscert: "{{ ldaptoolbox_openldap_olcTLSCertificateFile }}"
tlskey: "{{ ldaptoolbox_openldap_olcTLSCertificateKeyFile }}"
tlscacert: "{{ ldaptoolbox_openldap_olcTLSCACertificateFile }}"
tlsreqcert: "demand"
binddn: "uid=syncrepl,ou=accounts,ou=infrastructure,{{ ldaptoolbox_openldap_suffix }}"
password: "{{ ldaptoolbox_openldap_syncrepl_password_vault }}"
searchbase: "{{ ldaptoolbox_openldap_suffix }}"
scope: "sub"
type: "refreshAndPersist"
retry: "5 5 300 +"
ldaptoolbox_openldap_overlay_syncprov_olcSpCheckpoint: "100 10"
ldaptoolbox_openldap_overlay_syncprov_olcSpSessionlog: "100"

########################
# Overlays configuration
########################

# Password policy
ldaptoolbox_openldap_overlay_ppolicy_olcPPolicyDefault: "cn=default,ou=ppolicies,{{ ldaptoolbox_openldap_suffix }}"
ldaptoolbox_openldap_overlay_ppolicy_olcPPolicyHashCleartext: "TRUE"
ldaptoolbox_openldap_overlay_ppolicy_olcPPolicyUseLockout: "TRUE"

# Referential integrity
ldaptoolbox_openldap_overlay_refint_olcRefintAttribute: "member"
ldaptoolbox_openldap_overlay_refint_olcRefintNothing: "cn=nothing,{{ ldaptoolbox_openldap_suffix }}"

# Dynamic groups (dynlist)
ldaptoolbox_openldap_overlay_dynlist_olcDlAttrSet: "groupOfURLs memberURL member+memberOf@groupOfNames*"


Loading

0 comments on commit ec41ed7

Please sign in to comment.