aboutsummaryrefslogtreecommitdiff
path: root/roles/openldap/tasks/schema.yml
blob: 4d714323b61de24c1ddf8db36f55e439259714fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
- name: search for entry
  community.general.ldap_search:
    dn: 'cn=schema,cn=config'
    filter: '(&(objectClass=olcSchemaConfig)(cn={*}{{ item["cn"] }}))'
    scope: children
  become: yes
  register: schemareg

- name: Check results
  assert:
    that:
      - schemareg['failed'] == false
      - schemareg['results'] | length <= 1
    fail_msg: "More than one occurance of {{ item['cn'] }}! clean them out."

- name: "Install schema: create entry"
  community.general.ldap_entry:
    dn: 'cn={{ item["cn"] }},cn=schema,cn=config'
    state: present
    objectClass: olcSchemaConfig
  become: yes
  when: schemareg['results'] | length == 0

- name: "Install schema: set attributes"
  community.general.ldap_attrs:
    dn: '{{ item["cn"] }},cn=schema,cn=config'
    state: present
    attributes:
      objectClass: olcSchemaConfig
      olcAttributeTypes: '{{ item["olcAttributeTypes"] }}'
      olcObjectClasses: '{{ item["olcObjectClasses"] }}'
  become: yes
  when: schemareg['results'] | length == 0

- name: Update schema
  community.general.ldap_attrs:
    dn: '{{ schemareg["results"][0]["dn"] }}'
    state: exact
    attributes:
      objectClass: olcSchemaConfig
      olcAttributeTypes: '{{ item["olcAttributeTypes"] }}'
      olcObjectClasses: '{{ item["olcObjectClasses"] }}'
  become: yes
  when: schemareg['results'] | length > 0