Commit 47cce61b authored by nimrod's avatar nimrod
Browse files

Seperate phpLDAPadmin to a different tasks file, make the role a little more structured.

parent 05a28ef3
Loading
Loading
Loading
Loading
+7 −41
Changes for tasks/main.yml: 7 added lines, 41 removed lines.
Original line number Diff line number Diff line
@@ -8,9 +8,9 @@
    - Restart OpenLDAP
    - Restart Apache

- name: Preconfigure packages
- name: Preseed slapd
  debconf:
    name: '{{ item.name }}'
    name: slapd
    question: '{{ item.question }}'
    vtype: '{{ item.vtype }}'
    value: '{{ item.value }}'
@@ -18,23 +18,15 @@
    - question: shared/organization
      vtype: string
      value: '{{ organization }}'
      name: slapd
    - question: slapd/domain
      vtype: string
      value: '{{ domain }}'
      name: slapd
    - question: slapd/password1
      vtype: password
      value: '{{ password }}'
      name: slapd
    - question: slapd/password2
      vtype: password
      value: '{{ password }}'
      name: slapd
    - name: phpldapadmin
      question: phpldapadmin/ldap-basedn
      vtype: string
      value: '{{ basedn }}'

- name: apt install
  apt:
@@ -45,7 +37,6 @@
  with_items:
    - ldap-utils
    - slapd
    - phpldapadmin
    - gnutls-bin

- name: Allow slapd to access the TLS key
@@ -56,14 +47,11 @@
  notify:
    - Restart OpenLDAP

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

- name: Set slapd binds
  lineinfile:
@@ -95,36 +83,12 @@
    mode: '0644'
  register: ldaps_template

- name: Configure LDAPS
- name: Apply LDAPS Configuration
  when: ldaps_template.changed
  command: '/usr/bin/ldapmodify -Y EXTERNAL -H ldapi:/// -f /root/ldaps.ldif -D "cn=admin,{{ basedn }}"'
  notify:
    - Restart OpenLDAP

- name: Enable mod-ssl on Apache
  apache2_module:
    name: ssl
    state: present
  notify:
    - Restart Apache

- name: Disable default Apache site
  file:
    path: /etc/apache2/sites-enabled/000-default.conf
    state: absent
  notify:
    - Restart Apache

- name: Add phpLDAPadmin Apache site
  template:
    src: phpmyadmin.conf.j2
    dest: /etc/apache2/sites-enabled/phpmyadmin.conf
    owner: root
    group: root
    mode: '0644'
  notify:
    - Restart Apache

- name: Add backup cron job
  cron:
    name: OpenLDAP daily backup
@@ -132,3 +96,5 @@
    job: 'ldapsearch -L -Y EXTERNAL -H ldapi:/// -D "cn=admin,{{ basedn }}" > /var/backups/{{ basedn }}.ldif 2>/dev/null'
    state: present
    user: root

- include: phpldapadmin.yml
+45
Changes for tasks/phpldapadmin.yml: 45 added lines, 0 removed lines.
Original line number Diff line number Diff line
---

- name: Preseed phpLDAPadmin
  debconf:
    name: phpldapadmin
    question: phpldapadmin/ldap-basedn
    vtype: string
    value: '{{ basedn }}'

- name: apt install phpldapadmin
  apt:
    name: phpldapadmin
    state: present
    update_cache: yes
    cache_valid_time: 3600

- name: Enable mod-ssl in Apache
  apache2_module:
    name: ssl
    state: present
  notify:
    - Restart Apache

- name: Disable default Apache site
  file:
    path: /etc/apache2/sites-enabled/000-default.conf
    state: absent
  notify:
    - Restart Apache

- name: Add phpLDAPadmin Apache site
  template:
    src: phpmyadmin.conf.j2
    dest: /etc/apache2/sites-enabled/phpmyadmin.conf
    owner: root
    group: root
    mode: '0644'
  notify:
    - Restart Apache

- name: Allow HTTPS port
  ufw:
    rule: limit
    port: https
    proto: tcp