From a3ea6f89cca06a008bfa1054a296baa888926465 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Thu, 11 May 2023 16:56:16 +0800 Subject: [PATCH] roles/gitlab: update --- .../setup-k3s-with-existed-vhost.yml | 9 ++- playbook/jobs/init_gitlab | 29 +++------- playbook/jobs/init_harbor | 3 +- playbook/roles/gitlab/files/setup.sh | 57 ++++++++++++++++++- playbook/roles/gitlab/tasks/main.yml | 45 +++++++-------- playbook/roles/postgresql/files/post-setup.sh | 2 + playbook/roles/secret-manger/tasks/main.yml | 18 ++++-- 7 files changed, 109 insertions(+), 54 deletions(-) diff --git a/.github/workflows/setup-k3s-with-existed-vhost.yml b/.github/workflows/setup-k3s-with-existed-vhost.yml index c5b0c01d..5e40b9cf 100644 --- a/.github/workflows/setup-k3s-with-existed-vhost.yml +++ b/.github/workflows/setup-k3s-with-existed-vhost.yml @@ -13,6 +13,8 @@ env: ALI_SK: ${{ secrets.ALI_SK }} SSH_PUBLIC_KEY: ${{ secrets.SSH_PUBLIC_KEY }} SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }} + OIDC_CLIENT_TOKEN: ${{ secrets.OIDC_CLIENT_TOKEN }} OIDC_ADMIN_PASSWORD: ${{ secrets.OIDC_ADMIN_PASSWORD }} defaults: @@ -42,7 +44,7 @@ jobs: mkdir -pv hosts/ cat > hosts/inventory << EOF [master] - mirrors.onwalk.net ansible_host=43.206.90.100 + mirrors.onwalk.net ansible_host=20.18.50.198 [all:vars] ansible_port=22 @@ -53,11 +55,12 @@ jobs: ali_sk=$ALI_SK dns_ak=$DNS_AK dns_sk=$DNS_SK - ingress_ip=43.206.90.100 + ingress_ip=20.18.50.198 admin_password=$OIDC_ADMIN_PASSWORD EOF ansible-playbook -i hosts/inventory jobs/init_k3s_cluster -D - ansible-playbook -i hosts/inventory jobs/init_chatwithgpt -D + ansible-playbook -i hosts/inventory jobs/init_gitlab -D + #ansible-playbook -i hosts/inventory jobs/init_chatwithgpt -D #ansible-playbook -i hosts/inventory jobs/init_harbor -D #ansible-playbook -i hosts/inventory jobs/init_keycloak -D #ansible-playbook -i hosts/inventory jobs/init_cert_manager -D diff --git a/playbook/jobs/init_gitlab b/playbook/jobs/init_gitlab index 1a7794f1..ac2a72a5 100644 --- a/playbook/jobs/init_gitlab +++ b/playbook/jobs/init_gitlab @@ -1,37 +1,26 @@ -- name: setup openldap +- name: setup gitlab hosts: all user: root become: yes gather_facts: yes tasks: - include_role: - name: keycloak + name: gitlab vars: group: master namespace: gitlab domain: onwalk.net auto_issuance: true - generic: - - name: gitlab-sso-secret - value: "provider=/tmp/provider.yaml" + update_secret: true + oidc_issuer_url: 'https://keycloak.onwalk.net/realms/cloud-sso' + oidc_client_id: 'gitlab-oidc' + oidc_client_token: {{ OIDC_CLIENT_TOKEN }} + oidc_client_redirect_uri: 'https://gitlab.onwalk.net/users/auth/openid_connect/callback' tls: - secret_name: gitlab-tls - keyfile: /etc/ssl/onwalk.net.key + keyfile: /etc/sl/onwalk.net.key certfile: /etc.ssl/onwalk.net.pem secret: - secret_name: gitlab-smtp-secret key: password - value: "{{ stmp_password }}" - namespace: {{ namespace }} - object_bucket: {{ object_bucket }} - gitlab_secret: 'gitlab-tls' - gitlab_stmp_secret: 'gitlab-smtp-secret' - smtp_port: {{ smtp_port }} - smtp_domain: {{ smtp_domain }} - smtp_address: {{ smtp_address }} - smtp_username: {{ smtp_username }} - smtp_emailfrom: {{ smtp_emailfrom }} - smtp_display_name: {{ smtp_display_name }} - oidc_client_id: {{ oidc_client_id }} - oidc_issuer_url: {{ oidc_issuer_url }} - oidc_client_token: {{ oidc_client_token }} + value: "{{ SMTP_PASSWORD }}" diff --git a/playbook/jobs/init_harbor b/playbook/jobs/init_harbor index 8cf20d3f..33c3c5b0 100644 --- a/playbook/jobs/init_harbor +++ b/playbook/jobs/init_harbor @@ -10,8 +10,9 @@ group: master namespace: harbor domain: onwalk.net - auto_issuance: false db_namespace: database + auto_issuance: true + update_secret: true storage_type: oss tls: - secret_name: harbor-tls diff --git a/playbook/roles/gitlab/files/setup.sh b/playbook/roles/gitlab/files/setup.sh index 01004fec..e5f1515b 100644 --- a/playbook/roles/gitlab/files/setup.sh +++ b/playbook/roles/gitlab/files/setup.sh @@ -1,9 +1,27 @@ #!/bin/bash +check_empty() { + if [ -z "$1" ]; then + echo "$2" + exit 1 + fi +} + +check_empty "$1" "Please provide a domain name as the first argument" +check_empty "$2" "Please provide a namespace as the second argument" +check_empty "$3" "Please provide a GitLab secret as the third argument" +check_empty "$4" "Please provide a GitLab database secret as the fourth argument" +check_empty "$5" "Please provide a GitLab SSO secret as the fifth argument" +check_empty "$6" "Please provide a GitLab SMTP secret as the sixth argument" +check_empty "$7" "Please provide a GitLab Redis secret as the seventh argument" + domain=$1 namespace=$2 gitlab_secret=$3 -gitlab_sso_secret=$4 +gitlab_db_secret=$4 +gitlab_sso_secret=$5 +gitlab_smtp_secret=$6 +gitlab_redis_secret=$7 cat > gitlab-values.yaml <