roles/postgresq: add post-setup-postgresql.sh

This commit is contained in:
Haitao Pan 2023-04-12 10:43:24 +08:00
parent c6a046d485
commit 9bc49e5622
5 changed files with 17 additions and 4 deletions

View File

@ -11,3 +11,4 @@
namespace: itsm
domain: onwalk.net
secret: keycloak-tls
db_namespace: database

View File

@ -8,3 +8,4 @@
name: postgresql
vars:
group: master
db_namespace: database

View File

@ -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 DATABASE keycloak;"

View File

@ -1,6 +1,8 @@
#!/bin/bash
export namespace=$1
helm repo add bitnami https://charts.bitnami.com/bitnami || echo true
helm repo up
kubectl create ns database || echo true
helm upgrade --install postgresql bitnami/postgresql -n database
kubectl create ns $namespace || echo true
helm upgrade --install postgresql bitnami/postgresql -n $namespace

View File

@ -1,3 +1,7 @@
- name: Setup PostgreSQL Server
script: setup-postgresql.sh
- name: Install PostgreSQL Server
script: files/setup-postgresql.sh {{ db_namespace }}
when: inventory_hostname in groups[group]
- name: Post Setup PostgreSQL Server
script: files/post-setup-postgresql.sh {{ db_namespace }}
when: inventory_hostname in groups[group]