-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setups vault integration to test bedel
- Loading branch information
Showing
8 changed files
with
84 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,51 @@ | ||
version: '3.7' | ||
|
||
services: | ||
redis-master: | ||
redis0001: | ||
image: redis:latest | ||
container_name: redis-master | ||
container_name: redis0001 | ||
ports: | ||
- "6379:6379" | ||
volumes: | ||
- ./master:/usr/local/etc/redis:rw | ||
- ./redis0001:/usr/local/etc/redis:rw | ||
command: redis-server /usr/local/etc/redis/redis.conf | ||
|
||
redis-slave1: | ||
redis0002: | ||
image: redis:latest | ||
container_name: redis-slave1 | ||
container_name: redis0002 | ||
volumes: | ||
- ./slave01:/usr/local/etc/redis:rw | ||
- ./redis0002:/usr/local/etc/redis:rw | ||
command: | ||
- "redis-server" | ||
- "/usr/local/etc/redis/redis.conf" | ||
- "--slaveof" | ||
- "redis-master" | ||
- "redis0001" | ||
- "6379" | ||
|
||
|
||
redis-slave2: | ||
redis0003: | ||
image: redis:latest | ||
container_name: redis-slave2 | ||
volumes: | ||
- ./slave02:/usr/local/etc/redis:rw | ||
- ./redis0003:/usr/local/etc/redis:rw | ||
command: | ||
- "redis-server" | ||
- "/usr/local/etc/redis/redis.conf" | ||
- "--slaveof" | ||
- "redis-master" | ||
- "redis0001" | ||
- "6379" | ||
|
||
vault: | ||
image: hashicorp/vault:latest | ||
container_name: vault | ||
ports: | ||
- "8200:8200" | ||
volumes: | ||
- ./vault:/scripts:ro | ||
environment: | ||
VAULT_DEV_ROOT_TOKEN_ID: root | ||
VAULT_DEV_LISTEN_ADDRESS: 0.0.0.0:8200 | ||
VAULT_ADDR: http://0.0.0.0:8200 | ||
cap_add: | ||
- IPC_LOCK | ||
entrypoint: "/scripts/setup.sh" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/sh | ||
|
||
set -x | ||
set -m | ||
|
||
# start dev vault | ||
vault server -dev -dev-root-token-id=$VAULT_DEV_ROOT_TOKEN_ID & | ||
|
||
# Wait for Vault server to be up | ||
echo "Waiting for Vault to start..." | ||
while ! nc -z localhost 8200; do | ||
sleep 1 | ||
done | ||
|
||
echo "Vault started" | ||
|
||
vault login $VAULT_DEV_ROOT_TOKEN_ID | ||
|
||
# Enable database secret engine | ||
vault secrets enable database | ||
|
||
sleep 1 | ||
|
||
instances="redis0001 redis0002 redis0003" | ||
for instance in $instances ; do | ||
vault write "database/config/${instance}" \ | ||
plugin_name="redis-database-plugin" \ | ||
host=$instance \ | ||
port=6379 \ | ||
tls=false \ | ||
username="default" \ | ||
password="bedel-integration-test" \ | ||
allowed_roles="*-${instance}" | ||
|
||
vault write "database/roles/admin-${instance}" \ | ||
db_name=$instance \ | ||
creation_statements='["+@admin"]' \ | ||
default_ttl="30m" \ | ||
max_ttl="1h" | ||
done | ||
|
||
#for i in {1..30} ; do | ||
# vault read database/creds/admin-master | ||
# vault read database/creds/admin-slave01 | ||
# vault read database/creds/admin-slave02 | ||
#done | ||
|
||
echo "Vault configuration complete" | ||
|
||
fg |