Skip to content

Commit bffe7a3

Browse files
defines default variables and create 3 playbooks, each overloading some variables
1 parent 5552973 commit bffe7a3

File tree

10 files changed

+321
-107
lines changed

10 files changed

+321
-107
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
sudo pip3 install ansible
2121
ansible --version
2222
printf '[defaults]\nroles_path=../' >ansible.cfg
23-
ansible-playbook tests/test.yml -i tests/inventory --syntax-check --vault-password-file .vault_pass
23+
ansible-playbook tests/standalone.yml -i tests/inventory --syntax-check --vault-password-file .vault_pass

README.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,45 @@ Requirements
1212
Role Variables
1313
--------------
1414

15-
You'll need to store the hash value for you admin password. You'll get it like this:
15+
You'll need to store the hash value for you admin passwords. You'll get it like this:
1616

1717
```
1818
/usr/local/openldap/sbin/slappasswd -o module-path="/usr/local/openldap/libexec/openldap" -o module-load="argon2" -h "{ARGON2}" -s "password"
1919
```
2020

21-
Dependencies
22-
------------
21+
Store the passwords in the vault file in: `tests/credentials-vault.yml`
22+
23+
24+
Playbook examples
25+
-----------------
2326

27+
You should:
28+
* either deploy your role
29+
* or use a configuration file for setting the role path, for example:
2430

25-
Example Playbook
26-
----------------
31+
ansible.cfg
32+
```
33+
[defaults]
34+
roles_path=../
35+
```
2736

28-
See `tests/test.yml`
37+
See `tests/standalone.yml`
2938

3039
Run playbook with:
3140

3241
```
33-
ansible-playbook tests/test.yml -i tests/inventory --ask-vault-pass
42+
ansible-playbook tests/standalone.yml -i tests/inventory --ask-vault-pass
3443
```
3544

45+
or:
46+
47+
```
48+
ansible-playbook tests/standalone.yml -i tests/inventory --vault-password-file .vault_pass
49+
```
50+
51+
If you need a two-nodes multimaster example, give a look at `tests/multimaster1.yml` and `tests/multimaster2.yml`
52+
53+
3654
License
3755
-------
3856

defaults/main.yml

Lines changed: 122 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
# defaults file for ansible-role-ldaptoolbox-openldap
2+
################################################################################
3+
# Defaults variables for OpenLDAP role
4+
################################################################################
35

4-
# Common configuration
5-
# --------------------
66

7-
# APT configuration
7+
# apt package repository
88
ldaptoolbox_openldap_apt_key_url: "https://ltb-project.org/documentation/_static/RPM-GPG-KEY-LTB-project"
99
ldaptoolbox_openldap_apt_key_id: "3FC3FD92ABA3975D2BEB95A70AC51F926D45BFC5"
1010
ldaptoolbox_openldap_apt_repo_filename: "ltb-project-openldap"
@@ -17,7 +17,7 @@ ldaptoolbox_openldap_packages_base: openldap-ltb, openldap-ltb-contrib-overlays,
1717
ldaptoolbox_openldap_packages_dependencies: libcrack2, curl
1818
ldaptoolbox_openldap_packages_state: present
1919

20-
# Configuration
20+
# Filesystem
2121
ldaptoolbox_openldap_configuration_backup_dir: /var/backups/openldap
2222
ldaptoolbox_openldap_configuration_timestamp_cmd: 'date +%Y%m%d%H%M%S'
2323
ldaptoolbox_openldap_configuration_timestamp: '00000000000000'
@@ -27,8 +27,32 @@ ldaptoolbox_openldap_configuration_group: ldap
2727
ldaptoolbox_openldap_configuration_mode: 0600
2828
ldaptoolbox_openldap_sslgroup: ssl-cert
2929

30+
# OpenLDAP LTB CLI command path
3031
ldaptoolbox_openldap_slapd_cli_cmd: /usr/local/openldap/sbin/slapd-cli
3132

33+
34+
35+
# OpenLDAP configuration
36+
################################################################################
37+
38+
# Suffix
39+
ldaptoolbox_openldap_suffix: "{{ ldaptoolbox_openldap_suffix }}"
40+
41+
# Custom schemas
42+
ldaptoolbox_openldap_custom_schema_srcdir: ""
43+
ldaptoolbox_openldap_custom_schema_list: []
44+
ldaptoolbox_openldap_schema_dir: /usr/local/openldap/etc/openldap/schema
45+
46+
# Certificates
47+
ldaptoolbox_openldap_olcTLSCACertificateFile: /etc/ssl/certs/ca-certificates.crt
48+
ldaptoolbox_openldap_olcTLSCertificateFile: /etc/ssl/certs/ssl-cert-snakeoil.pem
49+
ldaptoolbox_openldap_olcTLSCertificateKeyFile: /etc/ssl/private/ssl-cert-snakeoil.key
50+
ldaptoolbox_openldap_olcTLSProtocolMin: 3.3
51+
52+
# Log level
53+
ldaptoolbox_openldap_olcLogLevel: stats
54+
55+
# Enabled modules
3256
ldaptoolbox_openldap_module_list:
3357
- argon2.la
3458
- pw-pbkdf2.la
@@ -39,11 +63,100 @@ ldaptoolbox_openldap_module_list:
3963
- unique.la
4064
- refint.la
4165

42-
ldaptoolbox_openldap_custom_schema_srcdir: ""
43-
ldaptoolbox_openldap_custom_schema_list: []
44-
ldaptoolbox_openldap_schema_dir: /usr/local/openldap/etc/openldap/schema
4566

46-
ldaptoolbox_openldap_suffix: "dc=my-domain,dc=com"
67+
##################
68+
# Database options
69+
##################
70+
71+
# config database
72+
ldaptoolbox_openldap_config_olcRootDN: cn=admin,cn=config
73+
ldaptoolbox_openldap_config_olcRootPW_hash: "{{ ldaptoolbox_openldap_config_olcRootPW_hash_vault }}"
74+
75+
# main database
76+
ldaptoolbox_openldap_database_olcRootDN: "cn=admin,{{ ldaptoolbox_openldap_suffix }}"
77+
ldaptoolbox_openldap_database_olcRootPW_hash: "{{ ldaptoolbox_openldap_database_olcRootPW_hash_vault }}"
78+
ldaptoolbox_openldap_database_olcDbMaxSize: "4294967296"
4779

80+
# monitor database
81+
ldaptoolbox_openldap_monitor_olcRootDN: "cn=monitor"
82+
ldaptoolbox_openldap_monitor_olcRootPW_hash: "{{ ldaptoolbox_openldap_monitor_olcRootPW_hash_vault }}"
83+
84+
85+
86+
##########################
87+
# General OpenLDAP options
88+
##########################
89+
90+
ldaptoolbox_openldap_olcSaslHost: 127.0.0.1
91+
ldaptoolbox_openldap_olcSortVals: member
4892
ldaptoolbox_olcPasswordHash: "{ARGON2}"
4993

94+
# Access rights
95+
ldaptoolbox_openldap_access_list:
96+
- to * by dn.exact=gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth manage by * break
97+
- to dn.base="" by * read
98+
- to dn.base="cn=Subschema" by * read
99+
- to * by self write by users read by anonymous auth
100+
101+
# Limits
102+
ldaptoolbox_openldap_database_olcLimits:
103+
- dn.base="uid=syncrepl,ou=accounts,ou=infrastructure,{{ ldaptoolbox_openldap_suffix }}" size=unlimited time=unlimited
104+
105+
# Indexes definition
106+
ldaptoolbox_openldap_database_olcDbIndexes:
107+
- "objectClass eq"
108+
- "entryUUID eq"
109+
- "entryCSN eq"
110+
- "cn pres,eq,sub"
111+
- "uid pres,eq,sub"
112+
113+
########################
114+
# Replication directives
115+
########################
116+
117+
ldaptoolbox_openldap_olcServerID: 1
118+
ldaptoolbox_openldap_syncrepl:
119+
- rid: "001"
120+
provider: "ldap://localhost:389/"
121+
tlscert: "{{ ldaptoolbox_openldap_olcTLSCertificateFile }}"
122+
tlskey: "{{ ldaptoolbox_openldap_olcTLSCertificateKeyFile }}"
123+
tlscacert: "{{ ldaptoolbox_openldap_olcTLSCACertificateFile }}"
124+
tlsreqcert: "demand"
125+
binddn: "uid=syncrepl,ou=accounts,ou=infrastructure,{{ ldaptoolbox_openldap_suffix }}"
126+
password: "{{ ldaptoolbox_openldap_syncrepl_password_vault }}"
127+
searchbase: "{{ ldaptoolbox_openldap_suffix }}"
128+
scope: "sub"
129+
type: "refreshAndPersist"
130+
retry: "5 5 300 +"
131+
- rid: "002"
132+
provider: "ldap://localhost:389/"
133+
tlscert: "{{ ldaptoolbox_openldap_olcTLSCertificateFile }}"
134+
tlskey: "{{ ldaptoolbox_openldap_olcTLSCertificateKeyFile }}"
135+
tlscacert: "{{ ldaptoolbox_openldap_olcTLSCACertificateFile }}"
136+
tlsreqcert: "demand"
137+
binddn: "uid=syncrepl,ou=accounts,ou=infrastructure,{{ ldaptoolbox_openldap_suffix }}"
138+
password: "{{ ldaptoolbox_openldap_syncrepl_password_vault }}"
139+
searchbase: "{{ ldaptoolbox_openldap_suffix }}"
140+
scope: "sub"
141+
type: "refreshAndPersist"
142+
retry: "5 5 300 +"
143+
ldaptoolbox_openldap_overlay_syncprov_olcSpCheckpoint: "100 10"
144+
ldaptoolbox_openldap_overlay_syncprov_olcSpSessionlog: "100"
145+
146+
########################
147+
# Overlays configuration
148+
########################
149+
150+
# Password policy
151+
ldaptoolbox_openldap_overlay_ppolicy_olcPPolicyDefault: "cn=default,ou=ppolicies,{{ ldaptoolbox_openldap_suffix }}"
152+
ldaptoolbox_openldap_overlay_ppolicy_olcPPolicyHashCleartext: "TRUE"
153+
ldaptoolbox_openldap_overlay_ppolicy_olcPPolicyUseLockout: "TRUE"
154+
155+
# Referential integrity
156+
ldaptoolbox_openldap_overlay_refint_olcRefintAttribute: "member"
157+
ldaptoolbox_openldap_overlay_refint_olcRefintNothing: "cn=nothing,{{ ldaptoolbox_openldap_suffix }}"
158+
159+
# Dynamic groups (dynlist)
160+
ldaptoolbox_openldap_overlay_dynlist_olcDlAttrSet: "groupOfURLs memberURL member+memberOf@groupOfNames*"
161+
162+

tasks/main.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,27 @@
2424
state: present
2525
when: ldaptoolbox_openldap_olcTLSCertificateFile is defined
2626

27+
- name: Ensure correct file ownership, group and permissions for CA
28+
ansible.builtin.file:
29+
path: "{{ ldaptoolbox_openldap_olcTLSCACertificateFile }}"
30+
owner: "root"
31+
group: "root"
32+
mode: "644"
33+
34+
- name: Ensure correct file ownership, group and permissions for certificate
35+
ansible.builtin.file:
36+
path: "{{ ldaptoolbox_openldap_olcTLSCertificateFile }}"
37+
owner: "root"
38+
group: "root"
39+
mode: "644"
40+
41+
- name: Ensure correct file ownership, group and permissions for key
42+
ansible.builtin.file:
43+
path: "{{ ldaptoolbox_openldap_olcTLSCertificateKeyFile }}"
44+
owner: "root"
45+
group: "{{ ldaptoolbox_openldap_sslgroup }}"
46+
mode: "640"
47+
2748
# Configuration
2849
# -------------
2950

templates/var/backups/openldap/config.ldif

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ olcPidFile: /usr/local/openldap/var/run/slapd.pid
2222
olcReadOnly: FALSE
2323
olcSaslHost: {{ ldaptoolbox_openldap_olcSaslHost }}
2424
olcSaslSecProps: none
25-
olcServerID: 1
25+
olcServerID: {{ ldaptoolbox_openldap_olcServerID }}
2626
olcSockbufMaxIncoming: 262143
2727
olcSockbufMaxIncomingAuth: 16777215
2828
olcThreads: 16

tests/host_vars/localhost.yml

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)