diff --git a/OLDAP-Anpassung/README.md b/OLDAP-Anpassung/README.md new file mode 100644 index 0000000..e7fa032 --- /dev/null +++ b/OLDAP-Anpassung/README.md @@ -0,0 +1,34 @@ +# LDAP-OU-Struktur für heim.lan + +Das Playbook legt unter `dc=heim,dc=lan` die acht OUs main, cert, backup, +iot, service, proxy, dmz und storage an. Jede erhält die Unter-OUs +Computers, Groups und Users. Dies ist eine an AD angelehnte OU-Struktur +für OpenLDAP, keine Einrichtung von Active-Directory-Domänen. + +Bestehende Einträge werden nicht verschoben oder gelöscht. + +## Voraussetzungen + +- Ansible auf dem Control Node und SSH-Zugriff als root auf 9.99.30.14. +- Der Basis-DN `dc=heim,dc=lan` besteht bereits. +- Der LDAP-LXC bietet den lokalen LDAP-Socket `ldapi:///` an. +- Der LDAP-Administrator heißt `cn=admin,dc=heim,dc=lan`. + Falls abweichend, `ldap_bind_dn` im Playbook anpassen. + +## Ausführen auf dem Ansible Control Node + +Diesen Ordner auf den Control Node kopieren und dort in den Ordner wechseln. +Anschließend: + +```bash +ansible-galaxy collection install community.general +ansible -i inventory.ini ldap -m ping +ansible-playbook -i inventory.ini ldap-ous.yml +``` + +Das LDAP-Admin-Passwort wird verdeckt abgefragt und nicht in diesen Dateien +gespeichert. Es kann vom SSH-Root-Passwort abweichen. +Das Playbook installiert python3-ldap auf dem LXC und legt die 32 OUs an, +soweit sie noch fehlen. Die Verbindung zum LDAP-Socket erfolgt auf dem LXC. + +Das Playbook wurde beim Speichern nicht auf dem Server ausgeführt. diff --git a/OLDAP-Anpassung/inventory.ini b/OLDAP-Anpassung/inventory.ini new file mode 100644 index 0000000..fbf536e --- /dev/null +++ b/OLDAP-Anpassung/inventory.ini @@ -0,0 +1,2 @@ +[ldap] +ldap01 ansible_host=9.99.30.14 ansible_user=root ansible_python_interpreter=/usr/bin/python3 diff --git a/OLDAP-Anpassung/ldap-ous.yml b/OLDAP-Anpassung/ldap-ous.yml new file mode 100644 index 0000000..8195172 --- /dev/null +++ b/OLDAP-Anpassung/ldap-ous.yml @@ -0,0 +1,63 @@ +--- +- name: OU-Struktur auf TurnKey LDAP einrichten + hosts: ldap + gather_facts: false + + vars: + ldap_base_dn: "dc=heim,dc=lan" + ldap_bind_dn: "cn=admin,{{ ldap_base_dn }}" + ldap_bereiche: + - main + - cert + - backup + - iot + - service + - proxy + - dmz + - storage + ldap_unterous: + - Computers + - Groups + - Users + + vars_prompt: + - name: ldap_admin_password + prompt: "Passwort des LDAP-Administrators" + private: true + + module_defaults: + community.general.ldap_entry: + server_uri: "ldapi:///" + bind_dn: "{{ ldap_bind_dn }}" + bind_pw: "{{ ldap_admin_password }}" + state: present + + tasks: + - name: Python-LDAP auf dem LDAP-LXC installieren + ansible.builtin.apt: + name: python3-ldap + state: present + update_cache: true + cache_valid_time: 3600 + + - name: Bereichs-OUs anlegen + community.general.ldap_entry: + dn: "ou={{ item }},{{ ldap_base_dn }}" + objectClass: + - top + - organizationalUnit + attributes: + ou: "{{ item }}" + loop: "{{ ldap_bereiche }}" + + - name: Unter-OUs in jedem Bereich anlegen + community.general.ldap_entry: + dn: "ou={{ item.1 }},ou={{ item.0 }},{{ ldap_base_dn }}" + objectClass: + - top + - organizationalUnit + attributes: + ou: "{{ item.1 }}" + loop: "{{ ldap_bereiche | product(ldap_unterous) | list }}" + loop_control: + label: "{{ item.0 }}/{{ item.1 }}"