#####################################
### someone's ansible provisioner ###
#####################################
# Part of: https://git.somenet.org/root/pub/somesible.git
# 2017-2026 by someone <someone@somenet.org>
#
---
- name: install openldap-server
  apt:
    pkg:
    - ldap-server
    - ldap-utils
    - ldapvi
    state: present
    policy_rc_d: 101
  tags: "online"
  ignore_errors: "{{ignore_online_errors | bool}}"


- name: copy slapd.conf
  copy:
    src: "{{item}}"
    dest: "/etc/ldap/slapd.conf"
    mode: 0640
    owner: "openldap"
    group: "openldap"
  with_first_found:
    - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/slapd.conf"
    - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/slapd.conf"
    - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/slapd.conf"
    - "default/slapd.conf"
  notify: restart slapd.service


- name: symlink /etc/ldap/slapd.d to /dev/null
  file:
    path: "/etc/ldap/slapd.d"
    state: absent


- name: enable and start slapd.service
  include_role: name="base/systemd/enable-and-start"
  vars:
    service_name: slapd.service
