Skip to content

Commit

Permalink
chore: Update ClickHouse password handling in config files
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Oct 17, 2024
1 parent 6e9781c commit d224105
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@
</distributed_ddl>
<remote_servers>
<cluster_2S_1R>
<secret>supersecret</secret>
<shard>
<replica>
<host>xatu-clickhouse-01</host>
<port>9000</port>
<password from_env="CLICKHOUSE_PASSWORD" replace="replace"></password>
</replica>
</shard>
<shard>
<replica>
<host>xatu-clickhouse-02</host>
<port>9000</port>
<password from_env="CLICKHOUSE_PASSWORD" replace="replace"></password>
</replica>
</shard>
</cluster_2S_1R>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cat <<EOT >> /etc/clickhouse-server/users.d/default.xml
<networks>
<ip>::/0</ip>
</networks>
<password>${CLICKHOUSE_PASSWORD}</password>
$([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "<password>${CLICKHOUSE_PASSWORD}</password>")
<quota>default</quota>
</${CLICKHOUSE_USER}>
<readonly>
Expand All @@ -22,24 +22,22 @@ cat <<EOT >> /etc/clickhouse-server/users.d/default.xml
EOT

cat <<EOT >> /etc/clickhouse-server/config.d/users.xml
<yandex>
<clickhouse replace="true">
<remote_servers>
<cluster_2S_1R>
<shard>
<replica>
<host>xatu-clickhouse-01</host>
$([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "<password>${CLICKHOUSE_PASSWORD}</password>")
$([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "<password replace=\"true\">${CLICKHOUSE_PASSWORD}</password>")
</replica>
</shard>
<shard>
<replica>
<host>xatu-clickhouse-02</host>
$([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "<password>${CLICKHOUSE_PASSWORD}</password>")
$([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "<password replace=\"true\">${CLICKHOUSE_PASSWORD}</password>")
</replica>
</shard>
</cluster_2S_1R>
</remote_servers>
</yandex>
</clickhouse>
EOT
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<ip>::/0</ip>
</networks>
<quota>default</quota>
<password from_env="CLICKHOUSE_PASSWORD" replace="replace"></password>
<access_management>1</access_management>
<named_collection_control>1</named_collection_control>
<show_named_collections>1</show_named_collections>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@
</distributed_ddl>
<remote_servers>
<cluster_2S_1R>
<secret>supersecret</secret>
<shard>
<replica>
<host>xatu-clickhouse-01</host>
<port>9000</port>
<password from_env="CLICKHOUSE_PASSWORD" replace="replace"></password>
</replica>
</shard>
<shard>
<replica>
<host>xatu-clickhouse-02</host>
<port>9000</port>
<password from_env="CLICKHOUSE_PASSWORD" replace="replace"></password>
</replica>
</shard>
</cluster_2S_1R>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,24 @@ cat <<EOT >> /etc/clickhouse-server/users.d/default.xml
EOT

cat <<EOT >> /etc/clickhouse-server/config.d/users.xml
<yandex>
<clickhouse replace="true">
<clickhouse>
<remote_servers>
<cluster_2S_1R>
<shard>
<replica>
<host>xatu-clickhouse-01</host>
$([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "<password>${CLICKHOUSE_PASSWORD}</password>")
$([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "<password replace=\"true\">${CLICKHOUSE_PASSWORD}</password>")
</replica>
</shard>
<shard>
<replica>
<host>xatu-clickhouse-02</host>
$([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "<password>${CLICKHOUSE_PASSWORD}</password>")
$([ -n "${CLICKHOUSE_PASSWORD}" ] && echo "<password replace=\"true\">${CLICKHOUSE_PASSWORD}</password>")
</replica>
</shard>
</cluster_2S_1R>
</remote_servers>
</yandex>
</clickhouse>
EOT


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<networks>
<ip>::/0</ip>
</networks>
<password from_env="CLICKHOUSE_PASSWORD" replace="replace"></password>
<quota>default</quota>
<access_management>1</access_management>
<named_collection_control>1</named_collection_control>
Expand Down
5 changes: 1 addition & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d224105

Please sign in to comment.