From d224105693ffc41d2ed3fae95f4b2025ec08657f Mon Sep 17 00:00:00 2001 From: Sam Calder-Mason Date: Thu, 17 Oct 2024 13:40:52 +1000 Subject: [PATCH] chore: Update ClickHouse password handling in config files --- .../etc/clickhouse-server/config.d/config.xml | 3 +-- .../docker-entrypoint-initdb.d/init-db.sh | 10 ++++------ .../etc/clickhouse-server/users.d/users.xml | 1 - .../etc/clickhouse-server/config.d/config.xml | 3 +-- .../docker-entrypoint-initdb.d/init-db.sh | 10 ++++------ .../etc/clickhouse-server/users.d/users.xml | 1 - docker-compose.yml | 5 +---- 7 files changed, 11 insertions(+), 22 deletions(-) diff --git a/deploy/local/docker-compose/clickhouse/clickhouse-01/etc/clickhouse-server/config.d/config.xml b/deploy/local/docker-compose/clickhouse/clickhouse-01/etc/clickhouse-server/config.d/config.xml index 215ad5e5..52f555cb 100644 --- a/deploy/local/docker-compose/clickhouse/clickhouse-01/etc/clickhouse-server/config.d/config.xml +++ b/deploy/local/docker-compose/clickhouse/clickhouse-01/etc/clickhouse-server/config.d/config.xml @@ -20,18 +20,17 @@ + supersecret xatu-clickhouse-01 9000 - xatu-clickhouse-02 9000 - diff --git a/deploy/local/docker-compose/clickhouse/clickhouse-01/etc/clickhouse-server/docker-entrypoint-initdb.d/init-db.sh b/deploy/local/docker-compose/clickhouse/clickhouse-01/etc/clickhouse-server/docker-entrypoint-initdb.d/init-db.sh index fcd8d46d..72b0244d 100755 --- a/deploy/local/docker-compose/clickhouse/clickhouse-01/etc/clickhouse-server/docker-entrypoint-initdb.d/init-db.sh +++ b/deploy/local/docker-compose/clickhouse/clickhouse-01/etc/clickhouse-server/docker-entrypoint-initdb.d/init-db.sh @@ -11,7 +11,7 @@ cat <> /etc/clickhouse-server/users.d/default.xml ::/0 - ${CLICKHOUSE_PASSWORD} + $([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "${CLICKHOUSE_PASSWORD}") default @@ -22,24 +22,22 @@ cat <> /etc/clickhouse-server/users.d/default.xml EOT cat <> /etc/clickhouse-server/config.d/users.xml - - xatu-clickhouse-01 - $([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "${CLICKHOUSE_PASSWORD}") + $([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "${CLICKHOUSE_PASSWORD}") xatu-clickhouse-02 - $([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "${CLICKHOUSE_PASSWORD}") + $([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "${CLICKHOUSE_PASSWORD}") - + EOT \ No newline at end of file diff --git a/deploy/local/docker-compose/clickhouse/clickhouse-01/etc/clickhouse-server/users.d/users.xml b/deploy/local/docker-compose/clickhouse/clickhouse-01/etc/clickhouse-server/users.d/users.xml index 86641f3c..31f5dbc0 100644 --- a/deploy/local/docker-compose/clickhouse/clickhouse-01/etc/clickhouse-server/users.d/users.xml +++ b/deploy/local/docker-compose/clickhouse/clickhouse-01/etc/clickhouse-server/users.d/users.xml @@ -23,7 +23,6 @@ ::/0 default - 1 1 1 diff --git a/deploy/local/docker-compose/clickhouse/clickhouse-02/etc/clickhouse-server/config.d/config.xml b/deploy/local/docker-compose/clickhouse/clickhouse-02/etc/clickhouse-server/config.d/config.xml index 35e61c2a..3a9915f1 100644 --- a/deploy/local/docker-compose/clickhouse/clickhouse-02/etc/clickhouse-server/config.d/config.xml +++ b/deploy/local/docker-compose/clickhouse/clickhouse-02/etc/clickhouse-server/config.d/config.xml @@ -20,18 +20,17 @@ + supersecret xatu-clickhouse-01 9000 - xatu-clickhouse-02 9000 - diff --git a/deploy/local/docker-compose/clickhouse/clickhouse-02/etc/clickhouse-server/docker-entrypoint-initdb.d/init-db.sh b/deploy/local/docker-compose/clickhouse/clickhouse-02/etc/clickhouse-server/docker-entrypoint-initdb.d/init-db.sh index 391fa9b4..adba0b29 100755 --- a/deploy/local/docker-compose/clickhouse/clickhouse-02/etc/clickhouse-server/docker-entrypoint-initdb.d/init-db.sh +++ b/deploy/local/docker-compose/clickhouse/clickhouse-02/etc/clickhouse-server/docker-entrypoint-initdb.d/init-db.sh @@ -21,26 +21,24 @@ cat <> /etc/clickhouse-server/users.d/default.xml EOT cat <> /etc/clickhouse-server/config.d/users.xml - - - + xatu-clickhouse-01 - $([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "${CLICKHOUSE_PASSWORD}") + $([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "${CLICKHOUSE_PASSWORD}") xatu-clickhouse-02 - $([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "${CLICKHOUSE_PASSWORD}") + $([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "${CLICKHOUSE_PASSWORD}") - + EOT diff --git a/deploy/local/docker-compose/clickhouse/clickhouse-02/etc/clickhouse-server/users.d/users.xml b/deploy/local/docker-compose/clickhouse/clickhouse-02/etc/clickhouse-server/users.d/users.xml index 0b0675d5..31f5dbc0 100644 --- a/deploy/local/docker-compose/clickhouse/clickhouse-02/etc/clickhouse-server/users.d/users.xml +++ b/deploy/local/docker-compose/clickhouse/clickhouse-02/etc/clickhouse-server/users.d/users.xml @@ -22,7 +22,6 @@ ::/0 - default 1 1 diff --git a/docker-compose.yml b/docker-compose.yml index b1470928..32f9d076 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -485,12 +485,9 @@ services: "-path", "/migrations", "-database", - "${CLICKHOUSE_PASSWORD:+clickhouse://xatu-clickhouse-01:9000?username=${CLICKHOUSE_USER}&password=${CLICKHOUSE_PASSWORD}&database=default&x-multi-statement=true}${CLICKHOUSE_PASSWORD:-clickhouse://xatu-clickhouse-01:9000?username=${CLICKHOUSE_USER}&database=default&x-multi-statement=true}", + "clickhouse://xatu-clickhouse-01:9000?username=${CLICKHOUSE_USER:-default}&database=default&x-multi-statement=true", "up", ] - environment: - CLICKHOUSE_USER: ${CLICKHOUSE_USER:-default} - CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD} depends_on: xatu-clickhouse-01: condition: service_healthy