리소스 변경

This commit is contained in:
ByeonJungHun
2023-11-20 16:44:44 +09:00
parent 4aa10aad33
commit 970022b3b2
8 changed files with 62 additions and 14 deletions

View File

@@ -0,0 +1,4 @@
---
cmoa_namespace: imxc
pg_version:
- 3.5.5

View File

@@ -0,0 +1,7 @@
KEYCLOAK_HOST=http://10.10.43.210:31082
ADMIN_USER_OLD_PASSWORD="cmoaA13!#"
ADMIN_USER_NEW_PASSWORD=admin
TOKEN=$(curl -s -X POST -H 'Content-Type: application/x-www-form-urlencoded' -d "username=admin&password=$ADMIN_USER_OLD_PASSWORD&client_id=admin-cli&grant_type=password" "$KEYCLOAK_HOST/auth/realms/master/exem/openid-connect/token" | jq -r ".access_token" ;)
curl -s -X PUT -H "Authorization: Bearer $TOKEN" -H "Content-type: application/json;charset=UTF-8" -H 'Accept: application/json' "$KEYCLOAK_HOST/auth/admin/realms/exem/users/admin/reset-password" -d "{\"type\":\"password\",\"value\":\"$ADMIN_USER_NEW_PASSWORD\",\"temporary\":false}"

View File

@@ -0,0 +1,37 @@
---
- name: 1. Get a list of all pods from the namespace
shell: kubectl -n "{{ cmoa_namespace }}" get pods --no-headers -o custom-columns=":metadata.name" |grep postgres
register: pod_list
when: kubernetes_role == 'master'
- debug:
msg: "{{ pod_list.stdout_lines }}"
when: kubernetes_role == 'master'
- name: 2. Copy psql file in postgres
kubernetes.core.k8s_cp:
namespace: "{{ cmoa_namespace }}"
pod: "{{ pod_list.stdout }}"
remote_path: /tmp/postgres_patch_{{ item }}.psql
local_path: "{{ role_path }}/files/pg-patch/postgres_patch_{{ item }}.psql"
with_items: "{{ pg_version }}"
when: kubernetes_role == 'master'
- name: 3. Execute a command in postgres
kubernetes.core.k8s_exec:
namespace: "{{ cmoa_namespace }}"
pod: "{{ pod_list.stdout }}"
command: bash -c "PGPASSWORD='eorbahrhkswp' && /usr/bin/psql -h 'localhost' -U 'admin' -d 'postgresdb' -f /tmp/postgres_patch_{{ item }}.psql"
register: execute_register
with_items: "{{ pg_version }}"
when: kubernetes_role == 'master'
- debug:
msg: |
______ _ _ _ _____ ___ ___ _____ ___
| ___ \| | | | | | / __ \| \/ || _ | / _ \
| |_/ /| | ___ __ _ ___ ___ _ __ ___ ___ | |_ __ _ _ __ | |_ | / \/| . . || | | |/ /_\ \
| __/ | | / _ \ / _` |/ __| / _ \ | '__| / _ \/ __|| __| / _` || '__|| __| | | | |\/| || | | || _ |
| | | || __/| (_| |\__ \| __/ | | | __/\__ \| |_ | (_| || | | |_ | \__/\| | | |\ \_/ /| | | |
\_| |_| \___| \__,_||___/ \___| |_| \___||___/ \__| \__,_||_| \__| \____/\_| |_/ \___/ \_| |_/
when: kubernetes_role == 'master'