Skip to content
main.yml 2.77 KiB
Newer Older
nimrod's avatar
nimrod committed
---
# tasks file for ansible-openldap
nimrod's avatar
nimrod committed
  debconf:
nimrod's avatar
nimrod committed
    question: '{{ item.question }}'
    vtype: '{{ item.vtype }}'
    value: '{{ item.value }}'
  with_items:
    - question: shared/organization
      vtype: string
      value: '{{ openldap_organization }}'
nimrod's avatar
nimrod committed
    - question: slapd/domain
      vtype: string
nimrod's avatar
nimrod committed
    - question: slapd/password1
      vtype: password
nimrod's avatar
nimrod committed
    - question: slapd/password2
      vtype: password
- name: apt install
nimrod's avatar
nimrod committed
  apt:
    name: '{{ item }}'
    state: present
    update_cache: yes
    cache_valid_time: 3600
  with_items:
    - ldap-utils
    - slapd
    - gnutls-bin
- name: Allow slapd to access the TLS key
  user:
    name: openldap
    groups: ssl-cert
    state: present
  notify:
    - Restart OpenLDAP

nimrod's avatar
nimrod committed
- name: Set default ldap client settings
  lineinfile:
    dest: /etc/ldap/ldap.conf
    line: 'URI    ldapi:///'
    regexp: '^URI'
nimrod's avatar
nimrod committed
    state: present

- name: Allow anonymous read access to chsh and chfn
  ldap_attr:
    dn: 'olcDatabase={1}{{ slapd_backend }},cn=config'
    values: '{1}to attrs=loginShell,gecos by dn="cn=admin,{{ openldap_basedn }}" write by self write by * read'
    state: present

- name: Configure olcTLS attributes (first time, can fail)
  ignore_errors: yes
  with_dict:
    olcTLSCACertificateFile: '{{ openldap_tls_ca_cert }}'
    olcTLSCertificateFile: '{{ openldap_tls_cert }}'
    olcTLSCertificateKeyFile: '{{ openldap_tls_key }}'
    olcTLSCipherSuite: '+AES-128-GCM:+AES-256-GCM:+AES-128-CBC:+AES-256-CBC:+ECDHE-RSA:+DHE-RSA:+AEAD:+SHA1:+SHA256:+SHA384'
  ldap_attr:
    dn: 'cn=config'
    name: '{{ item.key }}'
    values: '{{ item.value }}'
- name: Configure olcTLS attributes
  with_dict:
    olcTLSCACertificateFile: '{{ openldap_tls_ca_cert }}'
    olcTLSCertificateFile: '{{ openldap_tls_cert }}'
    olcTLSCertificateKeyFile: '{{ openldap_tls_key }}'
    olcTLSCipherSuite: '+AES-128-GCM:+AES-256-GCM:+AES-128-CBC:+AES-256-CBC:+ECDHE-RSA:+DHE-RSA:+AEAD:+SHA1:+SHA256:+SHA384'
    name: '{{ item.key }}'
    values: '{{ item.value }}'
nimrod's avatar
nimrod committed
- name: Add backup cron job
    dest: /etc/cron.daily/slapd
    owner: root
    group: root
    mode: '0755'
- name: Set slapd binds
  lineinfile:
    dest: /etc/default/slapd
    line: SLAPD_SERVICES="ldap:/// ldapi:/// ldaps:///"
    regexp: '^SLAPD_SERVICES='
    state: present
  notify:
    - Restart OpenLDAP

nimrod's avatar
nimrod committed
- name: Allow LDAPS port
  ufw:
    rule: allow
nimrod's avatar
nimrod committed
    port: ldaps
    proto: tcp