From ea097560e63210293c3576d463d913fe886a3ce2 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Fri, 12 May 2023 18:58:31 +0800 Subject: [PATCH] roles/gitlab: add gitlab-pre-install.sh --- .../setup-k3s-with-existed-vhost.yml | 8 +- .../roles/gitlab/files/gitlab-pre-install.sh | 5 + .../gitlab/files/setup-with-external-db.sh | 118 ------------------ playbook/roles/gitlab/files/setup.sh | 34 ++--- playbook/roles/gitlab/tasks/main.yml | 16 ++- playbook/roles/postgresql/files/post-setup.sh | 2 +- playbook/roles/postgresql/tasks/main.yml | 4 - 7 files changed, 37 insertions(+), 150 deletions(-) create mode 100755 playbook/roles/gitlab/files/gitlab-pre-install.sh delete mode 100644 playbook/roles/gitlab/files/setup-with-external-db.sh diff --git a/.github/workflows/setup-k3s-with-existed-vhost.yml b/.github/workflows/setup-k3s-with-existed-vhost.yml index f045c387..eef38249 100644 --- a/.github/workflows/setup-k3s-with-existed-vhost.yml +++ b/.github/workflows/setup-k3s-with-existed-vhost.yml @@ -46,7 +46,7 @@ jobs: mkdir -pv hosts/ cat > hosts/inventory << EOF [master] - gitlab.onwalk.net ansible_host=20.222.214.219 + common-gitlab.apollo-ev.com ansible_host=161.189.79.201 [all:vars] ansible_port=8022 @@ -55,7 +55,7 @@ jobs: ansible_host_key_checking=False dns_ak=$DNS_AK dns_sk=$DNS_SK - ingress_ip=20.222.214.219 + ingress_ip=161.189.79.201 smtp_password=$SMTP_PASSWORD gitlab_odic_client_token=$GITLAB_OIDC_CLIENT_TOKEN EOF @@ -89,7 +89,7 @@ jobs: mkdir -pv hosts/ cat > hosts/inventory << EOF [master] - common-artifact.apollo-ev.com ansible_host=52.83.75.244 + common-gitlab.apollo-ev.com ansible_host=20.222.214.219 [all:vars] ansible_port=22 @@ -100,7 +100,7 @@ jobs: ali_sk=$ALI_SK dns_ak=$DNS_AK dns_sk=$DNS_SK - ingress_ip=10.1.1.206 + ingress_ip=20.222.214.219 harbor_admin_password=$HARBOR_ADMIN_PASSWORD harbor_odic_client_token=$HARBOR_OIDC_CLIENT_TOKEN EOF diff --git a/playbook/roles/gitlab/files/gitlab-pre-install.sh b/playbook/roles/gitlab/files/gitlab-pre-install.sh new file mode 100755 index 00000000..b10cd1f9 --- /dev/null +++ b/playbook/roles/gitlab/files/gitlab-pre-install.sh @@ -0,0 +1,5 @@ +#!/bin/bash +export namespace=$1 +export POSTGRES_PASSWORD=`kubectl get secret --namespace $namespace postgresql -o jsonpath="{.data.postgres-password}" | base64 -d` + +kubectl run postgresql-client --rm --tty -i --restart='Never' --namespace $namespace --image docker.io/bitnami/postgresql:15.2.0-debian-11-r11 --env="PGPASSWORD=$POSTGRES_PASSWORD" --command -- psql --host postgresql -U postgres -d postgres -p 5432 -w -c "CREATE EXTENSION IF NOT EXISTS pg_trgm; CREATE EXTENSION IF NOT EXISTS btree_gist; CREATE DATABASE gitlabhq_production OWNER gitlab;" || echo true diff --git a/playbook/roles/gitlab/files/setup-with-external-db.sh b/playbook/roles/gitlab/files/setup-with-external-db.sh deleted file mode 100644 index 811dc1e7..00000000 --- a/playbook/roles/gitlab/files/setup-with-external-db.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/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_db_secret=$4 -gitlab_sso_secret=$5 -gitlab_smtp_secret=$6 -gitlab_redis_secret=$7 - -cat > gitlab-values.yaml < gitlab-values.yaml <