2024-04-03 23:00:58 +02:00
|
|
|
|
|
|
|
---
|
2024-04-03 23:20:59 +02:00
|
|
|
- name: Ensure LDAP config is set up
|
2024-04-03 23:00:58 +02:00
|
|
|
ansible.builtin.command: |
|
|
|
|
forgejo admin auth add-ldap \
|
|
|
|
--config "/etc/gitea/gitea.ini" \
|
|
|
|
--name "lldap" \
|
|
|
|
--security-protocol "unencrypted" \
|
|
|
|
--host "ldap.mgrote.net" \
|
|
|
|
--port "3890" \
|
|
|
|
--bind-dn "uid=ladmin,ou=people,dc=mgrote,dc=net" \
|
|
|
|
--bind-password GEHEIM \
|
|
|
|
--user-search-base "ou=people,dc=mgrote,dc=net" \
|
|
|
|
--user-filter "(&(memberof=cn=gitea,ou=groups,dc=mgrote,dc=net)(|(uid=%[1]s)(mail=%[1]s)))" \
|
|
|
|
--username-attribute "uid" \
|
|
|
|
--email-attribute "mail" \
|
|
|
|
--firstname-attribute "givenName" \
|
|
|
|
--surname-attribute "sn" \
|
|
|
|
--avatar-attribute "jpegPhoto" \
|
|
|
|
--synchronize-users
|
2024-04-03 23:20:59 +02:00
|
|
|
register: setup
|
2024-04-03 23:00:58 +02:00
|
|
|
ignore_errors: true
|
2024-04-03 23:20:59 +02:00
|
|
|
failed_when: 'not "Command error: login source already exists [name: lldap]" in setup.stderr' # fail Task wenn LDAP schon konfiguriert ist
|
2024-04-03 23:03:37 +02:00
|
|
|
become_user: gitea
|
2024-04-03 23:20:59 +02:00
|
|
|
changed_when: "setup.rc == 0" # chnaged nur wenn Task rc 0 hat, sollte nur beim ersten lauf vorkommen; ungetestet
|
2024-04-03 23:00:58 +02:00
|
|
|
|
2024-04-03 23:07:25 +02:00
|
|
|
- name: debug
|
|
|
|
ansible.builtin.debug:
|
2024-04-03 23:20:59 +02:00
|
|
|
msg: "{{ setup }}"
|
2024-04-03 23:00:58 +02:00
|
|
|
|
|
|
|
- name: Modify LDAP config
|
2024-04-03 23:06:38 +02:00
|
|
|
ansible.builtin.command: |
|
|
|
|
forgejo admin auth update-ldap \
|
|
|
|
--config "/etc/gitea/gitea.ini" \
|
|
|
|
--id "1" \
|
|
|
|
--security-protocol "unencrypted" \
|
|
|
|
--host "ldap.mgrote.net" \
|
|
|
|
--port "3890" \
|
|
|
|
--bind-dn "uid=ladmin,ou=people,dc=mgrote,dc=net" \
|
|
|
|
--bind-password GEHEIM \
|
|
|
|
--user-search-base "ou=people,dc=mgrote,dc=net" \
|
|
|
|
--user-filter "(&(memberof=cn=gitea,ou=groups,dc=mgrote,dc=net)(|(uid=%[1]s)(mail=%[1]s)))" \
|
|
|
|
--username-attribute "uid" \
|
|
|
|
--email-attribute "mail" \
|
2024-04-03 23:21:19 +02:00
|
|
|
--firstname-attribute "givennName" \
|
2024-04-03 23:06:38 +02:00
|
|
|
--surname-attribute "sn" \
|
|
|
|
--avatar-attribute "jpegPhoto" \
|
|
|
|
--synchronize-users
|
2024-04-03 23:20:59 +02:00
|
|
|
when: '"Command error: login source already exists [name: lldap]" in setup.stderr' # führe nur aus wenn erster Task fehlgeschlagen ist
|
2024-04-03 23:03:37 +02:00
|
|
|
become_user: gitea
|
2024-04-03 23:17:26 +02:00
|
|
|
register: zwei
|
2024-04-03 23:20:59 +02:00
|
|
|
changed_when: "setup.stdout | length > 0" # changed wenn stdout nciht lerr ist
|
2024-04-03 23:17:26 +02:00
|
|
|
|
|
|
|
- name: debug
|
|
|
|
ansible.builtin.debug:
|
|
|
|
msg: "{{ zwei }}"
|
2024-04-03 23:00:58 +02:00
|
|
|
|
|
|
|
...
|