-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inventory.yml.tftpl
default template for edb-ansible and related te…
…mplating changes (#70) Templates can now be passed in through the CLI with `--user-templates` or `ET_USER_TEMPLATES` as a list of template files or a directory with template files. Users can still make use of the infrastructure file to specify templates paths but they will be copied over to the projects template directory and removed from the final terraform variables file as it is unused within terraform. All templates will be rendered if they are within the projects `template` directory, if it ends with the `.tftpl` extension. Preferably, templates should not cause an infrastructure configuration to fail if is provided as a sample or a default. `inventory.yml.tftpl` has been added as an example which works with `edb-ansible`. To better work alongside ansible, additional outputs were passed through with our machines so they could be added to the inventory file, including `ansible_user` and `ansible_ssh_private_key_file`. Fixes: AWS/Azure/Gcloud - `setup_volume.sh` script updated to handle dropping of `/dev/` from device name when checking with nvme cli tools.
- Loading branch information
Showing
25 changed files
with
606 additions
and
61 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
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,2 +1,4 @@ | ||
__version__ = "1.3.0" | ||
__project_name__ = 'edb-terraform' | ||
from pathlib import Path | ||
__dot_project__ = f'{Path.home()}/.{__project_name__}' |
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
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
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
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
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,217 @@ | ||
# Original filename: inventory.yml.tftpl | ||
# This inventory file is meant to be used alongside edb-ansible: https://github.com/EnterpriseDB/edb-ansible | ||
# and relies on tags set within the infrastructure file to properly generate. | ||
# Sample infrastructure file for this template can be found under infrastructure-examples/aws-edb-ra-3.yml | ||
# | ||
# As a sample template, it will not cause terraform CLI and so it might be invalid. | ||
# To fail upon errors, remove any try() function. | ||
--- | ||
all: | ||
children: | ||
# PEM servers: tags.type.pem_server | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "pem_server" && tonumber(try(values.tags.index, -1)) == 0 } ~} | ||
pemserver: | ||
hosts: | ||
%{ if lower(try(values.tags.reference_architecture, "")) == "edb-always-on" ~} | ||
pemserver${ 1 + tonumber(try(values.tags.index, -2)) }: | ||
%{ else ~} | ||
pemserver${ 1 + tonumber(values.tags.index) }.${ values.tags.cluster_name }.internal: | ||
%{ endif ~} | ||
ansible_host: ${ values.public_ip } | ||
private_ip: ${ values.private_ip } | ||
ansible_user: ${ values.operating_system.ssh_user } | ||
ansible_ssh_private_key_file: ${ values.operating_system.ssh_private_key_file } | ||
%{ endfor ~} | ||
|
||
# Barman servers: tags.type.barman_server | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "barman_server" && tonumber(try(values.tags.index, -1)) == 0 } ~} | ||
barmanserver: | ||
hosts: | ||
%{ endfor ~} | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "barman_server"} ~} | ||
%{ if lower(try(values.tags.reference_architecture, "")) == "edb-always-on" ~} | ||
barmandc${ 1 + tonumber(try(values.tags.index -2)) }: | ||
%{ else ~} | ||
barmanserver${ 1 + tonumber(try(values.tags.index, "")) }.${ values.tags.cluster_name }.internal: | ||
%{ endif ~} | ||
ansible_host: ${ values.public_ip } | ||
private_ip: ${ values.private_ip } | ||
ansible_user: ${ values.operating_system.ssh_user } | ||
ansible_ssh_private_key_file: ${ values.operating_system.ssh_private_key_file } | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "pem_server" && tonumber(try(values.tags.index, -1)) == 0 } ~} | ||
pem_agent: true | ||
pem_server_private_ip: ${ values.private_ip } | ||
%{ endfor ~} | ||
%{ endfor ~} | ||
|
||
# Postgres servers: tags.type.postgres_server | ||
%{ for key,values in { for key,values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "postgres_server" && tonumber(try(values.tags.index, -1)) == 0 } ~} | ||
primary: | ||
hosts: | ||
%{ if lower(try(values.tags.pg_type, "")) == "epas" ~} | ||
epas${ 1 + tonumber(values.tags.index) }.${ values.tags.cluster_name }.internal: | ||
%{ else ~} | ||
pgsql${ 1 + tonumber(values.tags.index) }.${ values.tags.cluster_name }.internal: | ||
%{ endif ~} | ||
ansible_host: ${ values.public_ip } | ||
private_ip: ${ values.private_ip } | ||
ansible_user: ${ values.operating_system.ssh_user } | ||
ansible_ssh_private_key_file: ${ values.operating_system.ssh_private_key_file } | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "barman_server" && tonumber(try(values.tags.index, -1)) == 0} ~} | ||
barman: true | ||
barman_server_private_ip: ${ values.private_ip } | ||
barman_backup_method: postgres | ||
%{ endfor ~} | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "dbt2_client" } ~} | ||
%{ if tonumber(try(values.tags.index, -1)) == 0 ~} | ||
dbt2: true | ||
%{ endif ~} | ||
dbt2_client_private_ip${ 1 + tonumber(try(values.tags.index, -2)) }: ${ values.private_ip } | ||
%{ endfor ~} | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "hammerdb_server" && tonumber(try(values.tags.index, -1)) == 0 } ~} | ||
hammerdb: true | ||
hammerdb_server_private_ip: ${ values.private_ip } | ||
%{ endfor ~} | ||
%{ if tobool(try(values.tags.pooler_local, false)) && lower(try(values.tags.pg_pooler, "")) == "pgbouncer" ~} | ||
pgbouncer: true | ||
%{ endif ~} | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "pem_server" && tonumber(try(values.tags.index, -1)) == 0 } ~} | ||
pem_agent: true | ||
pem_server_private_ip: ${ values.private_ip } | ||
%{ endfor ~} | ||
standby: | ||
hosts: | ||
%{ endfor ~} | ||
%{ for key,values in { for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "postgres_server" && tonumber(try(values.tags.index, 0)) != 0 } ~} | ||
%{ if lower(try(values.tags.pg_type, "")) == "epas" ~} | ||
epas${ 1 + tonumber(values.tags.index) }.${ values.tags.cluster_name }.internal: | ||
%{ else ~} | ||
pgsql${ 1 + tonumber(values.tags.index) }.${ values.tags.cluster_name }.internal: | ||
%{ endif ~} | ||
ansible_host: ${ values.public_ip } | ||
private_ip: ${ values.private_ip } | ||
ansible_user: ${ values.operating_system.ssh_user } | ||
ansible_ssh_private_key_file: ${ values.operating_system.ssh_private_key_file } | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "barman_server" && tonumber(try(values.tags.index, -1)) == 0} ~} | ||
barman: true | ||
barman_server_private_ip: ${ values.private_ip } | ||
barman_backup_method: postgres | ||
%{ endfor ~} | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "dbt2_client" } ~} | ||
dbt2_client_private_ip${ 1 + tonumber(try(values.tags.index, -2)) }: ${ values.private_ip } | ||
%{ endfor ~} | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "hammerdb_server" && tonumber(try(values.tags.index, -1)) == 0} ~} | ||
hammerdb: true | ||
hammerdb_server_private_ip: ${ values.private_ip } | ||
%{ endfor ~} | ||
%{ if tobool(try(values.tags.pooler_local, false)) && lower(try(values.tags.pg_pooler, "")) == "pgbouncer" ~} | ||
pgbouncer: true | ||
%{ endif ~} | ||
replication_type: ${ values.tags.replication_type } | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "postgres_server" && tonumber(try(values.tags.index, -1)) == 0 } ~} | ||
upstream_node_private_ip: ${ values.private_ip } | ||
%{ endfor ~} | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "pem_server" && tonumber(try(values.tags.index, -1)) == 0 } ~} | ||
pem_agent: true | ||
pem_server_private_ip: ${ values.private_ip } | ||
%{ endfor ~} | ||
%{ endfor ~} | ||
|
||
# BDR servers: tags.type.bdr_server | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "bdr_server" && tonumber(try(values.tags.index, -1)) == 0 } ~} | ||
primary: | ||
hosts: | ||
%{ endfor ~} | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "bdr_server" } ~} | ||
%{ if lower(try(values.tags.pg_type, "")) == "epas" ~} | ||
epas${ 1 + tonumber(try(values.tags.index, -2)) ~}: | ||
%{ else ~} | ||
pgsql${ 1 + tonumber(try(values.tags.index, -2)) ~}: | ||
%{ endif ~} | ||
ansible_host: ${ values.public_ip } | ||
private_ip: ${ values.private_ip } | ||
ansible_user: ${ values.operating_system.ssh_user } | ||
ansible_ssh_private_key_file: ${ values.operating_system.ssh_private_key_file } | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "pem_server" && tonumber(try(values.tags.index), -1) == 0 } ~} | ||
pem_agent: true | ||
pem_server_private_ip: ${ values.private_ip } | ||
%{ endfor ~} | ||
%{ endfor ~} | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "bdr_witness_server" } ~} | ||
%{ if lower(try(values.tags.pg_type, "")) == "epas" ~} | ||
epas${ 1 + tonumber(try(values.tags.index, -2)) + length([ for key, values in servers.machines: key if lower(try(values.tags.type, "")) == "bdr_server"]) }: | ||
%{ else ~} | ||
pgsql${ 1 + tonumber(try(values.tags.index,-2)) + length([ for key, values in servers.machines: key if lower(try(values.tags.type, "")) == "bdr_server"]) }: | ||
%{ endif ~} | ||
ansible_host: ${ values.public_ip } | ||
private_ip: ${ values.private_ip } | ||
ansible_user: ${ values.operating_system.ssh_user } | ||
ansible_ssh_private_key_file: ${ values.operating_system.ssh_private_key_file } | ||
%{ for key, values in { for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "pem_server" && tonumber(try(values.tags.index), -1) == 0 } ~} | ||
pem_agent: true | ||
pem_server_private_ip: ${ values.private_ip } | ||
%{ endfor ~} | ||
%{ endfor ~} | ||
|
||
# Pool connection servers: tags.type.pooler_server | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "pooler_server" && tonumber(try(values.tags.index, -1)) == 0 } ~} | ||
${ values.tags.pooler_type }: | ||
hosts: | ||
%{ endfor ~} | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "pooler_server" } ~} | ||
%{ if length([ for key, values in servers.machines: key if lower(try(values.tags.type, "")) == "bdr_server"]) > 0 ~} | ||
pgbouncer${ 1 + tonumber(try(values.tags.index, -2)) }: | ||
%{ else ~} | ||
${ lower(try(values.tags.pooler_type, "")) }-${ 1 + tonumber(try(values.tags.index, -2)) }.${ values.tags.cluster_name }.internal: | ||
%{ endif ~} | ||
ansible_host: ${ values.public_ip } | ||
private_ip: ${ values.private_ip } | ||
ansible_user: ${ values.operating_system.ssh_user } | ||
ansible_ssh_private_key_file: ${ values.operating_system.ssh_private_key_file } | ||
%{ for key,values in { for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "postgres_server" && tonumber(try(values.tags.index, -1)) == 0 } ~} | ||
primary_private_ip: ${ values.private_ip } | ||
%{ endfor ~} | ||
%{ for key, values in {for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "pem_server" && tonumber(try(values.tags.index, -1)) == 0 } ~} | ||
pem_agent: true | ||
pem_server_private_ip: ${ values.private_ip } | ||
%{ endfor ~} | ||
%{ endfor ~} | ||
|
||
# DBT2 servers: tags.type.dbt2_client | ||
%{ for key, values in { for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "dbt2_client" && tonumber(try(values.tags.index, -1)) == 0 } ~} | ||
dbt2_client: | ||
hosts: | ||
%{ endfor ~} | ||
%{ for key, values in { for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "dbt2_client" } ~} | ||
dbt2_client${ 1 + tonumber(try(values.tags.index, -2)) }.${ values.tags.cluster_name }.internal: | ||
ansible_host: ${ values.public_ip } | ||
private_ip: ${ values.private_ip } | ||
ansible_user: ${ values.operating_system.ssh_user } | ||
ansible_ssh_private_key_file: ${ values.operating_system.ssh_private_key_file } | ||
%{ endfor ~} | ||
|
||
# DBT2 servers: tags.type.dbt2_driver | ||
%{ for key, values in { for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "dbt2_driver" && tonumber(try(values.tags.index, -1)) == 0 } ~} | ||
dbt2_driver: | ||
hosts: | ||
%{ endfor ~} | ||
%{ for key, values in { for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "dbt2_driver" } ~} | ||
dbt2_driver${ 1 + tonumber(try(values.tags.index, -2)) }.${ values.tags.cluster_name }.internal: | ||
ansible_host: ${ values.public_ip } | ||
private_ip: ${ values.private_ip } | ||
ansible_user: ${ values.operating_system.ssh_user } | ||
ansible_ssh_private_key_file: ${ values.operating_system.ssh_private_key_file } | ||
%{ endfor ~} | ||
|
||
# HammerDB servers: tags.type.hammerdb_server | ||
%{ for key, values in { for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "hammerdb_server" && tonumber(try(values.tags.index, -1)) == 0 } ~} | ||
hammerdbserver: | ||
hosts: | ||
%{ endfor ~} | ||
%{ for key, values in { for key, values in servers.machines: key=>values if lower(try(values.tags.type, "")) == "hammerdb_server" } ~} | ||
hammerdbserver${ 1 + tonumber(try(values.tags.index, -2)) }.${ values.tags.cluster_name }.internal: | ||
ansible_host: ${ values.public_ip } | ||
private_ip: ${ values.private_ip } | ||
ansible_user: ${ values.operating_system.ssh_user } | ||
ansible_ssh_private_key_file: ${ values.operating_system.ssh_private_key_file } | ||
%{ endfor ~} |
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
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
Oops, something went wrong.