Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
seb4itik committed Jul 28, 2024
1 parent f8706e7 commit 8dfdff2
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 39 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ you should prefix each item with `{N}`.

- Write tests (but problem between *Docker* and *systemd*).
- Other platforms (Redhat, ...).

- Optimisation: set_fact (all modules, all schemas, all suffixes...)
- Idempotency in attributes (for replacing "state: exact")

## License

Expand Down
16 changes: 16 additions & 0 deletions tasks/configure-monitor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- name: Enable/disable monitor backend
community.general.ldap_entry:
dn: "olcDatabase=Monitor,cn=config"
objectClass: "olcMonitorConfig"
attributes:
olcDatabase: "Monitor"
state: "{{ slapd_monitor | ternary('present', 'absent') }}"

# Because community.general.ldap_entry doesn't update existing LDAP records.
- name: Configure monitor backend
when: "slapd_monitor"
community.general.ldap_attrs:
dn: "olcDatabase=Monitor,cn=config"
attributes:
olcAccess: '{0}to dn.subtree="cn=Monitor" by dn.base="{{ slapd_monitor_admin | mandatory }}" read by * none'
state: "exact"
20 changes: 20 additions & 0 deletions tasks/install-slapd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- name: Install pre-required packages
ansible.builtin.apt:
name:
- "debconf-utils"
- "ssl-cert"

# This backend will be deleted by "Delete backends" task
- name: Pre-configure slapd dummy.domain.to.delete with debconf
ansible.builtin.debconf:
name: "slapd"
question: "slapd/domain"
value: "dummy.domain.to.delete"
vtype: "string"

- name: Install required packages
ansible.builtin.apt:
name:
- "slapd"
- "schema2ldif"
- "python3-ldap"
44 changes: 6 additions & 38 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,20 @@
---
- name: Install pre-required packages
ansible.builtin.apt:
name:
- "debconf-utils"
- "ssl-cert"

# This backend will be deleted by "Delete backends" task
- name: Pre-configure slapd dummy.domain.to.delete with debconf
ansible.builtin.debconf:
name: "slapd"
question: "slapd/domain"
value: "dummy.domain.to.delete"
vtype: "string"

- name: Install required packages
ansible.builtin.apt:
name:
- "slapd"
- "schema2ldif"
- "python3-ldap"
- name: Install slapd
ansible.builtin.include_tasks: "install-slapd.yml"

- name: Configure SSL
ansible.builtin.include_tasks: "configure-ssl.yml"

- name: Configure monitor backend
ansible.builtin.include_tasks: "configure-monitor.yml"

- name: Add schemas
ansible.builtin.include_tasks: "add-schemas.yml"

- name: Add modules
ansible.builtin.include_tasks: "add-modules.yml"

- name: Enable/disable monitor backend
community.general.ldap_entry:
dn: "olcDatabase=Monitor,cn=config"
objectClass: "olcMonitorConfig"
attributes:
olcDatabase: "Monitor"
state: "{{ slapd_monitor | ternary('present', 'absent') }}"

# Because community.general.ldap_entry doesn't update existing LDAP records.
- name: Configure monitor backend
when: "slapd_monitor"
community.general.ldap_attrs:
dn: "olcDatabase=Monitor,cn=config"
attributes:
olcAccess: '{0}to dn.subtree="cn=Monitor" by dn.base="{{ slapd_monitor_admin | mandatory }}" read by * none'
state: "exact"

- name: Root OLC configuration
- name: Configuration - Root OLC
community.general.ldap_attrs:
dn: "cn=config"
attributes: "{{ slapd_config_olc }}"
Expand Down

0 comments on commit 8dfdff2

Please sign in to comment.