diff --git a/roles/web-app-gitea/tasks/cleanup/ldap.yml b/roles/web-app-gitea/tasks/cleanup/ldap.yml index a69f938cce..8efaa8c5d3 100644 --- a/roles/web-app-gitea/tasks/cleanup/ldap.yml +++ b/roles/web-app-gitea/tasks/cleanup/ldap.yml @@ -1,17 +1,19 @@ --- - name: "🔍 Lookup existing LDAP auth source ID" - shell: | - container exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER_ADDRESS }} \ + shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec -i --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} \ gitea admin auth list \ | awk -v name="LDAP ({{ SOFTWARE_NAME }})" '$0 ~ name {print $1; exit}' + delegate_to: "{{ GITEA_HOST_NODE }}" register: ldap_source_id_raw failed_when: false changed_when: false - name: "🗑️ Delete existing LDAP auth source if present" - shell: | - container exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER_ADDRESS }} \ + shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec -i --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} \ gitea admin auth delete --id {{ ldap_source_id_raw.stdout }} + delegate_to: "{{ GITEA_HOST_NODE }}" when: ldap_source_id_raw.stdout != "" register: ldap_delete failed_when: ldap_delete.rc != 0 diff --git a/roles/web-app-gitea/tasks/cleanup/oidc.yml b/roles/web-app-gitea/tasks/cleanup/oidc.yml index 9c8de2ccc9..812eb7b1fd 100644 --- a/roles/web-app-gitea/tasks/cleanup/oidc.yml +++ b/roles/web-app-gitea/tasks/cleanup/oidc.yml @@ -1,17 +1,19 @@ --- - name: "🔍 Lookup existing OIDC auth source ID" - shell: | - container exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER_ADDRESS }} \ + shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec -i --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} \ gitea admin auth list \ | awk -v name="{{ OIDC.BUTTON_TEXT }}" '$0 ~ name {print $1; exit}' + delegate_to: "{{ GITEA_HOST_NODE }}" register: oidc_source_id_raw failed_when: false changed_when: false - name: "🗑️ Delete existing OIDC auth source if present" - shell: | - container exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER_ADDRESS }} \ + shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec -i --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} \ gitea admin auth delete --id {{ oidc_source_id_raw.stdout }} + delegate_to: "{{ GITEA_HOST_NODE }}" when: oidc_source_id_raw.stdout != "" register: oidc_delete failed_when: oidc_delete.rc != 0 diff --git a/roles/web-app-gitea/tasks/setup/ldap.yml b/roles/web-app-gitea/tasks/setup/ldap.yml index daae8fdd14..2ee7bb1639 100644 --- a/roles/web-app-gitea/tasks/setup/ldap.yml +++ b/roles/web-app-gitea/tasks/setup/ldap.yml @@ -1,19 +1,21 @@ --- - name: "➕ Add LDAP Authentication Source" - shell: | - container exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER_ADDRESS }} \ + shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec -i --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} \ gitea admin auth add-ldap \ {{ GITEA_LDAP_AUTH_ARGS | join(' ') }} + delegate_to: "{{ GITEA_HOST_NODE }}" register: ldap_manage failed_when: ldap_manage.rc != 0 and not (ldap_manage.stderr | gitea_auth_noop) - name: "🔍 Lookup existing LDAP auth source ID" - shell: | - container exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER_ADDRESS }} \ + shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec -i --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} \ gitea admin auth list \ | tail -n +2 \ | grep -F "LDAP ({{ DOMAIN_PRIMARY }})" \ | awk '{print $1; exit}' + delegate_to: "{{ GITEA_HOST_NODE }}" register: ldap_source_id_raw failed_when: - ldap_source_id_raw.rc != 0 @@ -25,10 +27,11 @@ ldap_source_id: "{{ ldap_source_id_raw.stdout }}" - name: "🔄 Update LDAP Authentication Source" - shell: | - container exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER_ADDRESS }} \ + shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec -i --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} \ gitea admin auth update-ldap \ --id {{ ldap_source_id }} \ {{ GITEA_LDAP_AUTH_ARGS | join(' ') }} + delegate_to: "{{ GITEA_HOST_NODE }}" register: ldap_manage failed_when: ldap_manage.rc != 0 diff --git a/roles/web-app-gitea/tasks/setup/oidc.yml b/roles/web-app-gitea/tasks/setup/oidc.yml index cd9e7b693f..76d6d49aa8 100644 --- a/roles/web-app-gitea/tasks/setup/oidc.yml +++ b/roles/web-app-gitea/tasks/setup/oidc.yml @@ -1,7 +1,7 @@ --- - name: "➕ Add Keycloak OIDC Provider" - shell: | - container exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER_ADDRESS }} \ + shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec -i --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} \ gitea admin auth add-oauth \ --provider openidConnect \ --name "{{ OIDC.BUTTON_TEXT }}" \ @@ -9,16 +9,18 @@ --secret "{{ OIDC.CLIENT.SECRET }}" \ --auto-discover-url "{{ OIDC.CLIENT.DISCOVERY_DOCUMENT }}" \ --scopes "openid profile email" + delegate_to: "{{ GITEA_HOST_NODE }}" register: oidc_manage failed_when: oidc_manage.rc != 0 and not (oidc_manage.stderr | gitea_auth_noop) - name: "🔍 Lookup existing Keycloak auth source ID" - shell: | - container exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER_ADDRESS }} \ + shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec -i --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} \ /app/gitea/gitea admin auth list \ | tail -n +2 \ | grep -F "{{ OIDC.BUTTON_TEXT }}" \ | awk '{print $1; exit}' + delegate_to: "{{ GITEA_HOST_NODE }}" register: oidc_source_id_raw failed_when: - oidc_source_id_raw.rc != 0 @@ -30,8 +32,8 @@ oidc_source_id: "{{ oidc_source_id_raw.stdout }}" - name: "🔄 Update Keycloak OIDC Provider" - shell: | - container exec -i --user {{ GITEA_USER }} {{ GITEA_CONTAINER_ADDRESS }} \ + shell: | # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node + container exec -i --user {{ GITEA_USER }} {{ GITEA_LOCAL_CID | quote }} \ gitea admin auth update-oauth \ --id {{ oidc_source_id }}\ --provider openidConnect \ @@ -40,5 +42,6 @@ --secret "{{ OIDC.CLIENT.SECRET }}" \ --auto-discover-url "{{ OIDC.CLIENT.DISCOVERY_DOCUMENT }}" \ --scopes "openid profile email" + delegate_to: "{{ GITEA_HOST_NODE }}" register: oidc_manage failed_when: oidc_manage.rc != 0