terraform: rewrite ansible_inventory as yaml instead of ini
This commit is contained in:
parent
db640ea6fa
commit
1d2483bb1b
3 changed files with 38 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
||||||
resource "local_file" "ansible_inventory" {
|
resource "local_file" "ansible_inventory" {
|
||||||
content = templatefile("templates/inventory.tmpl",
|
content = templatefile("templates/inventory.yml.tmpl",
|
||||||
{
|
{
|
||||||
dns_gateways = gandi_livedns_record.mongo_gateways.*
|
dns_gateways = gandi_livedns_record.mongo_gateways.*
|
||||||
dns_servers = gandi_livedns_record.mongo_gateways.*
|
dns_servers = gandi_livedns_record.mongo_gateways.*
|
||||||
|
|
37
terraform/templates/inventory.yml.tmpl
Normal file
37
terraform/templates/inventory.yml.tmpl
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
all:
|
||||||
|
children:
|
||||||
|
all_groups:
|
||||||
|
children:
|
||||||
|
role_gateway:
|
||||||
|
hosts:
|
||||||
|
%{ for index, instance in mongo_gateways ~}
|
||||||
|
prod-gateway9:
|
||||||
|
ansible_host: ${instance.network[0].fixed_ip_v4}
|
||||||
|
ansible_user: debian
|
||||||
|
mongo_group_id: ${instance.metadata.mongo_group_id}
|
||||||
|
mongo_groups_count: ${ mongo_groups_count }
|
||||||
|
mongo_replicas_count: ${ mongo_replicas_count }
|
||||||
|
sshwifty_hostname: ${dns_gateways[index].name}.${dns_gateways[index].zone}
|
||||||
|
%{ endfor ~}
|
||||||
|
role_mongo:
|
||||||
|
hosts:
|
||||||
|
%{ for index, instance in mongo_servers ~}
|
||||||
|
${ instance.name }:
|
||||||
|
ansible_host: ${instance.network[0].fixed_ip_v4}
|
||||||
|
ansible_user: debian
|
||||||
|
mongo_group_id: ${instance.metadata.mongo_group_id}
|
||||||
|
mongo_group_index: ${instance.metadata.mongo_group_index}
|
||||||
|
mongo_groups_count: ${ mongo_groups_count }
|
||||||
|
mongo_replicas_count: ${ mongo_replicas_count }
|
||||||
|
%{ endfor ~}
|
||||||
|
stage_development: {}
|
||||||
|
stage_production:
|
||||||
|
hosts:
|
||||||
|
%{ for index, instance in mongo_gateways ~}
|
||||||
|
${ instance.name } : {}
|
||||||
|
%{ endfor ~}
|
||||||
|
%{ for index, instance in mongo_servers ~}
|
||||||
|
${ instance.name } : {}
|
||||||
|
%{ endfor ~}
|
||||||
|
stage_testing: {}
|
||||||
|
ungrouped: {}
|
Loading…
Reference in a new issue