Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion ansible/inventory/offline/99-static
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,19 @@

[postgresql:vars]
postgresql_network_interface = enp1s0

repmgr_node_config:
postgresql1: # Maps to postgresql_rw group
node_id: 1
priority: 150
role: primary
postgresql2: # Maps to first postgresql_ro
node_id: 2
priority: 100
role: standby
postgresql3: # Maps to second postgresql_ro
node_id: 3
priority: 50
role: standby

[elasticsearch:vars]
# elasticsearch_network_interface = enp1s0
Expand Down
15 changes: 2 additions & 13 deletions ansible/inventory/offline/group_vars/postgresql/postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,8 @@ repmgr_namespace: "{{ wire_namespace | default('default') }}"
wire_pg_secret_name: "wire-postgresql-external-secret"

# Node configuration for repmgr
repmgr_node_config:
postgresql1: # Maps to postgresql_rw group
node_id: 1
priority: 150
role: primary
postgresql2: # Maps to first postgresql_ro
node_id: 2
priority: 100
role: standby
postgresql3: # Maps to second postgresql_ro
node_id: 3
priority: 50
role: standby
# NOTE: repmgr_node_config is defined in the inventory file ansible/inventory/offline/99-static, ansible/inventory/offline/staging.yml and terraform/examples/wire-server-deploy-offline-hetzner/outputs.tf
# to allow environment-specific node mappings. Do not define here.

# repmgr settings
# repmgrd monitoring and reconnection configuration
Expand Down
13 changes: 13 additions & 0 deletions ansible/inventory/offline/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ postgresql:
vars:
wire_dbname: wire-server
postgresql_network_interface: enp1s0
repmgr_node_config:
datanode1: # Maps to postgresql_rw group
node_id: 1
priority: 150
role: primary
datanode2: # Maps to first postgresql_ro
node_id: 2
priority: 100
role: standby
datanode3: # Maps to second postgresql_ro
node_id: 3
priority: 50
role: standby

postgresql_rw:
hosts:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changed: remove repmgr_node_config from group_vars and put with node inventory
17 changes: 9 additions & 8 deletions offline/cd_staging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ fi
echo ""
echo "Infrastructure ready! Proceeding with application deployment..."

# Common SSH options for all ssh and scp commands
SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectionAttempts=10 -o ConnectTimeout=15 -o ServerAliveInterval=15 -o ServerAliveCountMax=4 -o TCPKeepAlive=yes"

# Continue with the rest of the original cd.sh logic
adminhost=$(terraform output -raw adminhost)
ssh_private_key=$(terraform output ssh_private_key)
Expand All @@ -118,14 +121,12 @@ echo "Running ansible playbook setup_nodes.yml via adminhost ($adminhost)..."
ansible-playbook -i inventory.yml setup_nodes.yml --private-key "ssh_private_key"

# user demo needs to exist
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectionAttempts=10 \
"demo@$adminhost" wget -q "https://s3-eu-west-1.amazonaws.com/public.wire.com/artifacts/${ARTIFACT}.tgz"
ssh $SSH_OPTS "demo@$adminhost" wget -q "https://s3-eu-west-1.amazonaws.com/public.wire.com/artifacts/${ARTIFACT}.tgz"

ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectionAttempts=10 \
"demo@$adminhost" tar xzf "$ARTIFACT.tgz"
ssh $SSH_OPTS "demo@$adminhost" tar xzf "$ARTIFACT.tgz"

# override for ingress-nginx-controller values for hetzner environment $TF_DIR/setup_nodes.yml
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectionAttempts=10 "$VALUES_DIR/ingress-nginx-controller/hetzner-ci.example.yaml" "demo@$adminhost:./values/ingress-nginx-controller/prod-values.example.yaml"
scp $SSH_OPTS "$VALUES_DIR/ingress-nginx-controller/hetzner-ci.example.yaml" "demo@$adminhost:./values/ingress-nginx-controller/prod-values.example.yaml"

# Source and target files
SOURCE="inventory.yml"
Expand Down Expand Up @@ -173,12 +174,12 @@ yq eval -i ".all.vars.ansible_ssh_private_key_file = \"ssh/ssh_private_key\"" "$

echo "created secondary inventory file $TARGET successfully"

scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectionAttempts=10 "$TARGET" "demo@$adminhost":./ansible/inventory/offline/inventory.yml
scp $SSH_OPTS "$TARGET" "demo@$adminhost":./ansible/inventory/offline/inventory.yml

ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectionAttempts=10 "demo@$adminhost" cat ./ansible/inventory/offline/inventory.yml || true
ssh $SSH_OPTS "demo@$adminhost" cat ./ansible/inventory/offline/inventory.yml || true

# NOTE: Agent is forwarded; so that the adminhost can provision the other boxes
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectionAttempts=10 -A "demo@$adminhost" ./bin/offline-deploy.sh
ssh $SSH_OPTS -A "demo@$adminhost" ./bin/offline-deploy.sh

echo ""
echo "Wire offline deployment completed successfully!"
Expand Down
14 changes: 13 additions & 1 deletion offline/postgresql-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,19 @@ postgresql3 ansible_host=192.168.122.206

[postgresql:vars]
postgresql_network_interface = enp1s0

repmgr_node_config:
postgresql1: # Maps to postgresql_rw group
node_id: 1
priority: 150
role: primary
postgresql2: # Maps to first postgresql_ro
node_id: 2
priority: 100
role: standby
postgresql3: # Maps to second postgresql_ro
node_id: 3
priority: 50
role: standby

# All PostgreSQL nodes
[postgresql]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@ output "static-inventory" {
vars = {
wire_dbname = "wire-server"
postgresql_network_interface = "enp7s0"
repmgr_node_config = {
postgresql1 = {
node_id = 1
priority = 150
role = "primary"
}
postgresql2 = {
node_id = 2
priority = 100
role = "standby"
}
postgresql3 = {
node_id = 3
priority = 50
role = "standby"
}
}
}
}
postgresql_rw = {
Expand Down