From ebb666047316573230ace04b470bd61208b5b72d Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 27 Aug 2025 20:49:35 +0200 Subject: [PATCH] Renamed Gitea variables --- roles/web-app-gitea/tasks/01_database.yml | 16 +++++----- roles/web-app-gitea/tasks/cleanup/ldap.yml | 4 +-- roles/web-app-gitea/tasks/cleanup/oidc.yml | 4 +-- roles/web-app-gitea/tasks/main.yml | 6 ++-- roles/web-app-gitea/tasks/setup/ldap.yml | 10 +++---- roles/web-app-gitea/tasks/setup/oidc.yml | 6 ++-- .../templates/docker-compose.yml.j2 | 6 ++-- roles/web-app-gitea/vars/main.yml | 29 ++++++++++--------- 8 files changed, 42 insertions(+), 39 deletions(-) diff --git a/roles/web-app-gitea/tasks/01_database.yml b/roles/web-app-gitea/tasks/01_database.yml index ad538dd8..233e1646 100644 --- a/roles/web-app-gitea/tasks/01_database.yml +++ b/roles/web-app-gitea/tasks/01_database.yml @@ -4,26 +4,26 @@ - name: Patch Gitea DB host in app.ini command: > - docker exec -i --user {{ gitea_user }} {{ gitea_container }} - sed -ri "s|^(HOST\s*=\s*).*$|\1{{ database_host }}:{{ database_port }}|" {{ gitea_config }} + docker exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER }} + sed -ri "s|^(HOST\s*=\s*).*$|\1{{ database_host }}:{{ database_port }}|" {{ GITEA_CONFIG }} notify: docker compose up - name: Patch Gitea DB name in app.ini command: > - docker exec -i --user {{ gitea_user }} {{ gitea_container }} - sed -ri "s|^(NAME\s*=\s*).*$|\1{{ database_name }}|" {{ gitea_config }} + docker exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER }} + sed -ri "s|^(NAME\s*=\s*).*$|\1{{ database_name }}|" {{ GITEA_CONFIG }} notify: docker compose up - name: Patch Gitea DB user in app.ini command: > - docker exec -i --user {{ gitea_user }} {{ gitea_container }} - sed -ri "s|^(USER\s*=\s*).*$|\1{{ database_username }}|" {{ gitea_config }} + docker exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER }} + sed -ri "s|^(USER\s*=\s*).*$|\1{{ database_username }}|" {{ GITEA_CONFIG }} notify: docker compose up - name: Patch Gitea DB password in app.ini command: > - docker exec -i --user {{ gitea_user }} {{ gitea_container }} - sed -ri "s|^(PASSWD\s*=\s*).*$|\1{{ database_password }}|" {{ gitea_config }} + docker exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER }} + sed -ri "s|^(PASSWD\s*=\s*).*$|\1{{ database_password }}|" {{ GITEA_CONFIG }} notify: docker compose up - name: "Flush database patches" diff --git a/roles/web-app-gitea/tasks/cleanup/ldap.yml b/roles/web-app-gitea/tasks/cleanup/ldap.yml index eb35cac4..cc3f5f7b 100644 --- a/roles/web-app-gitea/tasks/cleanup/ldap.yml +++ b/roles/web-app-gitea/tasks/cleanup/ldap.yml @@ -1,6 +1,6 @@ - name: "Lookup existing LDAP auth source ID" shell: | - docker exec -i --user {{ gitea_user }} {{ gitea_container }} \ + docker exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER }} \ gitea admin auth list \ | awk -v name="LDAP ({{ PRIMARY_DOMAIN }})" '$0 ~ name {print $1; exit}' args: @@ -11,7 +11,7 @@ - name: "Delete existing LDAP auth source if present" shell: | - docker exec -i --user {{ gitea_user }} {{ gitea_container }} \ + docker exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER }} \ gitea admin auth delete --id {{ ldap_source_id_raw.stdout }} args: chdir: "{{ docker_compose.directories.instance }}" diff --git a/roles/web-app-gitea/tasks/cleanup/oidc.yml b/roles/web-app-gitea/tasks/cleanup/oidc.yml index 75b49c1b..895603fb 100644 --- a/roles/web-app-gitea/tasks/cleanup/oidc.yml +++ b/roles/web-app-gitea/tasks/cleanup/oidc.yml @@ -1,7 +1,7 @@ - name: "Lookup existing OIDC auth source ID" shell: | - docker exec -i --user {{ gitea_user }} {{ gitea_container }} \ + docker exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER }} \ gitea admin auth list \ | awk -v name="{{ OIDC.BUTTON_TEXT }}" '$0 ~ name {print $1; exit}' args: @@ -12,7 +12,7 @@ - name: "Delete existing OIDC auth source if present" shell: | - docker exec -i --user {{ gitea_user }} {{ gitea_container }} \ + docker exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER }} \ gitea admin auth delete --id {{ oidc_source_id_raw.stdout }} args: chdir: "{{ docker_compose.directories.instance }}" diff --git a/roles/web-app-gitea/tasks/main.yml b/roles/web-app-gitea/tasks/main.yml index 951fd558..ef4396a0 100644 --- a/roles/web-app-gitea/tasks/main.yml +++ b/roles/web-app-gitea/tasks/main.yml @@ -15,7 +15,7 @@ - name: "Run DB migrations inside Gitea container" shell: | - docker exec -i --user {{ gitea_user }} {{ gitea_container }} \ + docker exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER }} \ /app/gitea/gitea migrate args: chdir: "{{ docker_compose.directories.instance }}" @@ -24,13 +24,13 @@ - name: "Create initial admin user" shell: | - docker exec -i --user {{ gitea_user }} {{ gitea_container }} \ + docker exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER }} \ /app/gitea/gitea admin user create \ --admin \ --username "{{ users.administrator.username }}" \ --password "{{ users.administrator.password }}" \ --email "{{ users.administrator.email }}" \ - -c {{ gitea_config }} + -c {{ GITEA_CONFIG }} args: chdir: "{{ docker_compose.directories.instance }}" register: create_admin diff --git a/roles/web-app-gitea/tasks/setup/ldap.yml b/roles/web-app-gitea/tasks/setup/ldap.yml index c809efce..57d11df3 100644 --- a/roles/web-app-gitea/tasks/setup/ldap.yml +++ b/roles/web-app-gitea/tasks/setup/ldap.yml @@ -1,8 +1,8 @@ - name: "Add LDAP Authentication Source" shell: | - docker exec -i --user {{ gitea_user }} {{ gitea_container }} \ + docker exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER }} \ gitea admin auth add-ldap \ - {{ gitea_ldap_auth_args | join(' ') }} + {{ GITEA_LDAP_AUTH_ARGS | join(' ') }} args: chdir: "{{ docker_compose.directories.instance }}" register: ldap_manage @@ -10,7 +10,7 @@ - name: "Lookup existing LDAP auth source ID" shell: | - docker exec -i --user {{ gitea_user }} {{ gitea_container }} \ + docker exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER }} \ gitea admin auth list \ | tail -n +2 \ | grep -F "LDAP ({{ PRIMARY_DOMAIN }})" \ @@ -29,10 +29,10 @@ - name: "Update LDAP Authentication Source" shell: | - docker exec -i --user {{ gitea_user }} {{ gitea_container }} \ + docker exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER }} \ gitea admin auth update-ldap \ --id {{ ldap_source_id }} \ - {{ gitea_ldap_auth_args | join(' ') }} + {{ GITEA_LDAP_AUTH_ARGS | join(' ') }} args: chdir: "{{ docker_compose.directories.instance }}" register: ldap_manage diff --git a/roles/web-app-gitea/tasks/setup/oidc.yml b/roles/web-app-gitea/tasks/setup/oidc.yml index c2b04dec..b7428f84 100644 --- a/roles/web-app-gitea/tasks/setup/oidc.yml +++ b/roles/web-app-gitea/tasks/setup/oidc.yml @@ -1,6 +1,6 @@ - name: "Add Keycloak OIDC Provider" shell: | - docker exec -i --user {{ gitea_user }} {{ gitea_container }} \ + docker exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER }} \ gitea admin auth add-oauth \ --provider openidConnect \ --name "{{ OIDC.BUTTON_TEXT }}" \ @@ -15,7 +15,7 @@ - name: "Lookup existing Keycloak auth source ID" shell: | - docker exec -i --user {{ gitea_user }} {{ gitea_container }} \ + docker exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER }} \ /app/gitea/gitea admin auth list \ | tail -n +2 \ | grep -F "{{ OIDC.BUTTON_TEXT }}" \ @@ -34,7 +34,7 @@ - name: "Update Keycloak OIDC Provider" shell: | - docker exec -i --user {{ gitea_user }} {{ gitea_container }} \ + docker exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER }} \ gitea admin auth update-oauth \ --id {{ oidc_source_id }}\ --provider openidConnect \ diff --git a/roles/web-app-gitea/templates/docker-compose.yml.j2 b/roles/web-app-gitea/templates/docker-compose.yml.j2 index 358542fe..6147c0de 100644 --- a/roles/web-app-gitea/templates/docker-compose.yml.j2 +++ b/roles/web-app-gitea/templates/docker-compose.yml.j2 @@ -2,8 +2,8 @@ application: {% include 'roles/docker-container/templates/base.yml.j2' %} - image: "{{ gitea_image }}:{{ gitea_version }}" - container_name: "{{ gitea_container }}" + image: "{{ GITEA_IMAGE }}:{{ GITEA_VERSION }}" + container_name: "{{ GITEA_CONTAINER }}" ports: - "127.0.0.1:{{ ports.localhost.http[application_id] }}:{{ container_port }}" - "{{ports.public.ssh[application_id]}}:22" @@ -17,6 +17,6 @@ {% include 'roles/docker-compose/templates/volumes.yml.j2' %} data: - name: {{ gitea_volume }} + name: {{ GITEA_VOLUME }} {% include 'roles/docker-compose/templates/networks.yml.j2' %} \ No newline at end of file diff --git a/roles/web-app-gitea/vars/main.yml b/roles/web-app-gitea/vars/main.yml index 4f620287..5b34667e 100644 --- a/roles/web-app-gitea/vars/main.yml +++ b/roles/web-app-gitea/vars/main.yml @@ -1,6 +1,13 @@ -application_id: "web-app-gitea" -database_type: "mariadb" -gitea_ldap_auth_args: +# General +application_id: "web-app-gitea" +database_type: "mariadb" + +# Docker +container_port: "{{ applications | get_app_conf(application_id, 'docker.services.gitea.port') }}" +docker_compose_flush_handlers: true + +# Gitea +GITEA_LDAP_AUTH_ARGS: - '--name "LDAP ({{ PRIMARY_DOMAIN }})"' - '--host "{{ ldap.server.domain }}"' - '--port {{ ldap.server.port }}' @@ -15,13 +22,9 @@ gitea_ldap_auth_args: - '--email-attribute "{{ ldap.user.attributes.mail }}"' - '--public-ssh-key-attribute "{{ ldap.user.attributes.ssh_public_key }}"' - '--synchronize-users' -gitea_version: "{{ applications | get_app_conf(application_id, 'docker.services.gitea.version', True) }}" -gitea_image: "{{ applications | get_app_conf(application_id, 'docker.services.gitea.image', True) }}" -gitea_container: "{{ applications | get_app_conf(application_id, 'docker.services.gitea.name', True) }}" -gitea_volume: "{{ applications | get_app_conf(application_id, 'docker.volumes.data', True) }}" -gitea_user: "git" -gitea_config: "/data/gitea/conf/app.ini" - -container_port: "{{ applications | get_app_conf(application_id, 'docker.services.gitea.port', True) }}" - -docker_compose_flush_handlers: true \ No newline at end of file +GITEA_VERSION: "{{ applications | get_app_conf(application_id, 'docker.services.gitea.version') }}" +GITEA_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.gitea.image') }}" +GITEA_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.gitea.name') }}" +GITEA_VOLUME: "{{ applications | get_app_conf(application_id, 'docker.volumes.data') }}" +GITEA_USER: "git" +GITEA_CONFIG: "/data/gitea/conf/app.ini"