examples/ansible-postgres/create_vms.sh

22 lines
657 B
Bash
Executable File

#!/bin/bash
set -e
export FORMAT=YAML
mkdir -p tmp
detee-cli vm deploy --location US --hostname postgres-writer --public-ip \
--distro ubuntu --memory 2000 --vcpus 2 --disk 15 > tmp/writer.yaml &&
echo "Postgres writer created in the US" &
detee-cli vm deploy --location Canada --hostname postgres-reader --public-ip \
--distro ubuntu --memory 2000 --vcpus 2 --disk 15 > tmp/reader.yaml &&
echo "Postgres reader created in Canada" &
wait
echo "
[master]
master_host ansible_host=$(cat tmp/writer.yaml | grep ip | awk '{ print $2 }')
[replica]
replica_host ansible_host=$(cat tmp/reader.yaml | grep ip | awk '{ print $2 }')
" > tmp/inventory.ini