-
Notifications
You must be signed in to change notification settings - Fork 4
/
ansible.tf
59 lines (46 loc) · 1.13 KB
/
ansible.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
resource "null_resource" "setup_ansible" {
provisioner "local-exec" {
command = <<-EOT
python -m venv .venv
.venv/bin/pip install ansible
.venv/bin/ansible-galaxy collection install cloud.terraform
EOT
}
provisioner "local-exec" {
when = destroy
command = "rm -r .venv .tmp/root_token_*.txt || true"
}
}
resource "ansible_group" "consul_servers" {
name = "consul_servers"
}
resource "ansible_host" "consul_server" {
for_each = local.consul_servers
name = each.key
groups = [ansible_group.consul_servers.name]
variables = {
ansible_host = each.value
}
}
resource "ansible_group" "vault_servers" {
name = "vault_servers"
}
resource "ansible_host" "vault_server" {
for_each = local.vault_servers
name = each.key
groups = [ansible_group.vault_servers.name]
variables = {
ansible_host = each.value
}
}
resource "ansible_group" "nomad_servers" {
name = "nomad_servers"
}
resource "ansible_host" "nomad_server" {
for_each = local.nomad_servers
name = each.key
groups = [ansible_group.nomad_servers.name]
variables = {
ansible_host = each.value
}
}