forked from ansible/terraform-provider-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
43 lines (35 loc) · 903 Bytes
/
main.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
terraform {
required_providers {
ansible = {
version = "~> 1.1.0"
source = "ansible/ansible"
}
}
}
resource "ansible_vault" "secrets" {
vault_file = "vault.yml"
vault_password_file = "/path/to/file"
}
locals {
decoded_vault_yaml = yamldecode(ansible_vault.secrets.yaml)
}
resource "ansible_host" "host" {
name = "somehost"
groups = ["somegroup"]
variables = {
greetings = "from host!"
some = "variable"
yaml_hello = local.decoded_vault_yaml.hello
yaml_number = local.decoded_vault_yaml.a_number
# using jsonencode() here is needed to stringify
# a list that looks like: [ element_1, element_2, ..., element_N ]
yaml_list = jsonencode(local.decoded_vault_yaml.a_list)
}
}
resource "ansible_group" "group" {
name = "somegroup"
children = ["somechild"]
variables = {
hello = "from group!"
}
}