homeserver/roles/mgrote_gitea_setup/tasks/main.yml

55 lines
2.2 KiB
YAML
Raw Normal View History

2024-04-03 23:00:58 +02:00
---
2024-04-03 23:27:23 +02:00
# die Variablen kommen aus
# - https://docs.gitea.com/administration/command-line
# - https://github.com/lldap/lldap/blob/main/example_configs/gitea.md
# und
# den jeweiligen group/host-Vars!
2024-04-03 23:20:59 +02:00
- name: Ensure LDAP config is set up
2024-04-03 23:23:35 +02:00
no_log: true
become_user: gitea
2024-04-03 23:00:58 +02:00
ansible.builtin.command: |
forgejo admin auth add-ldap \
2024-04-03 23:27:23 +02:00
--config "{{ gitea_configuration_path }}/gitea.ini" \
2024-04-03 23:00:58 +02:00
--name "lldap" \
--security-protocol "unencrypted" \
2024-04-03 23:27:23 +02:00
--host "{{ ldap_host }}" \
2024-04-03 23:00:58 +02:00
--port "3890" \
--bind-dn "uid=ladmin,ou=people,dc=mgrote,dc=net" \
2024-04-03 23:27:23 +02:00
--bind-password "{{ ldap_bind_pass }}" \
2024-04-03 23:00:58 +02:00
--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
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
- name: Modify LDAP config
2024-04-03 23:23:35 +02:00
no_log: true
become_user: gitea
2024-04-03 23:06:38 +02:00
ansible.builtin.command: |
forgejo admin auth update-ldap \
2024-04-03 23:27:23 +02:00
--config "{{ gitea_configuration_path }}/gitea.ini" \
2024-04-03 23:06:38 +02:00
--id "1" \
--security-protocol "unencrypted" \
2024-04-03 23:27:23 +02:00
--host "{{ ldap_host }}" \
2024-04-03 23:06:38 +02:00
--port "3890" \
--bind-dn "uid=ladmin,ou=people,dc=mgrote,dc=net" \
2024-04-03 23:27:23 +02:00
--bind-password "{{ ldap_bind_pass }}" \
2024-04-03 23:06:38 +02:00
--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:22:45 +02:00
changed_when: false # keine idee wie ich changed feststellen kann
2024-04-03 23:00:58 +02:00
...