From fd3743f293783c9ec17fae7fd18d58b988b6fe9f Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Fri, 25 Jun 2021 15:54:49 +0000 Subject: [PATCH] Add LDAP client tools --- ldap/tasks/main.yml | 22 ++++++++++++++++++++++ ldap/templates/ldap.conf.j2 | 6 ++++++ ldap/templates/ldaprc.j2 | 3 +++ 3 files changed, 31 insertions(+) create mode 100644 ldap/tasks/main.yml create mode 100644 ldap/templates/ldap.conf.j2 create mode 100644 ldap/templates/ldaprc.j2 diff --git a/ldap/tasks/main.yml b/ldap/tasks/main.yml new file mode 100644 index 0000000..b45dcdb --- /dev/null +++ b/ldap/tasks/main.yml @@ -0,0 +1,22 @@ +--- + +- name: install packages + package: + name: openldap-clients + state: installed + +- name: configure ldap client + template: + dest: /etc/openldap/ldap.conf + src: ldap.conf.j2 + mode: 0644 + owner: root + group: "{{ ansible_wheel }}" + +- name: authenticate to ldap with host certs when running as root + template: + dest: /root/.ldaprc + src: ldaprc.j2 + mode: 0600 + owner: root + group: "{{ ansible_wheel }}" diff --git a/ldap/templates/ldap.conf.j2 b/ldap/templates/ldap.conf.j2 new file mode 100644 index 0000000..a1ef17c --- /dev/null +++ b/ldap/templates/ldap.conf.j2 @@ -0,0 +1,6 @@ + +BASE {{ ldap_basedn }} +URI {% for item in ldap_server %}ldaps://{{ item }} {% endfor %} + +TLS_CACERT {{ tls_bundle }} +TLS_REQCERT demand diff --git a/ldap/templates/ldaprc.j2 b/ldap/templates/ldaprc.j2 new file mode 100644 index 0000000..51c1b56 --- /dev/null +++ b/ldap/templates/ldaprc.j2 @@ -0,0 +1,3 @@ +TLS_KEY {{ tls_private }}/{{ inventory_hostname }}.key +TLS_CERT {{ tls_certs }}/{{ inventory_hostname }}.crt +SASL_MECH external