Commit 35f9b963 authored by nimrod's avatar nimrod
Browse files

Move TLS certificate handling and initial firewall handling each to a seperate...

Move TLS certificate handling and initial firewall handling each to a seperate file, preparing to have them shared between roles or a to be a depended role.
parent 05568413
Loading
Loading
Loading
Loading
+7 −36
Changes for tasks/main.yml: 7 added lines, 36 removed lines.
Original line number Diff line number Diff line
---
# tasks file for ansible-ldap

- name: Set TLS key and certificate
  set_fact:
    internal_tls_key: '/etc/ssl/private/{{ (tls_key|default("ssl-cert-snakeoil.key")).split(".")[:-1]|join(".") }}.key'
    internal_tls_cert: '/etc/ssl/certs/{{ (tls_cert|default("ssl-cert-snakeoil.pem")).split(".")[:-1]|join(".") }}.pem'
- include: firewall.yml

- include: certs.yml
  notify:
    - Restart OpenLDAP
    - Restart Apache

- name: Preconfigure packages
  debconf:
@@ -41,35 +43,10 @@
    update_cache: yes
    cache_valid_time: 3600
  with_items:
    - ufw
    - ldap-utils
    - slapd
    - phpldapadmin
    - gnutls-bin
    - ssl-cert

- name: Copy TLS certificate and key
  when: tls_cert is defined and tls_key is defined
  copy:
    src: '{{ item.src }}'
    dest: '{{ item.dest }}'
    owner: root
    group: ssl-cert
    mode: '{{ item.mode }}'
  register: ldap_tls_copy
  with_items:
    - src: '{{ tls_key }}'
      dest: '{{ internal_tls_key }}'
      mode: '0640'
    - src: '{{ tls_cert }}'
      dest: '/usr/local/share/ca-certificates/{{ tls_cert.split(".")[:-1]|join(".") }}.crt'
      mode: '0644'

- name: Update certificate authority store
  command: /usr/sbin/update-ca-certificates
  when: ldap_tls_copy.changed
  notify:
    - Restart OpenLDAP

- name: Allow OpenLDAP access to the TLS key
  user:
@@ -79,21 +56,15 @@
  notify:
    - Restart OpenLDAP

- name: Configure UFW
- name: Allow LDAPS, HTTPS
  ufw:
    rule: limit
    port: '{{ item }}'
    proto: tcp
  with_items:
    - 22
    - 443
    - 636

- name: Configure UFW default policy
  ufw:
    policy: reject
    state: enabled

- name: Set slapd binds
  lineinfile:
    dest: /etc/default/slapd