I haven't used the terraform module. but have just had a look at the
Ansible doc for it, and it describes a "variables" parameter as "a group of
key-values to override template variables or those in variables files."
Seems that this format in ansible would work to pass that parameter:
- terraform:
[...]
variables:
plain_var: "string value"
list_var: [ "list_element1", "list_element_2" ]
map_var:
one_thing: "blah"
otherthing: "bloo"
[...]
Note that "variables" is the literal name of the attribute; it is literally
the word "variables".
However, I suspect that "plain_var", "list_var" etc need to be variable
names that Terraform expects to see, and the contents have to be forms that
Terraform expects.
I can see several ways this might not be working:
- you have a syntax error in your Ansible code; this would cause an
error message from Ansible, and Terraform would not be called at all.
- you are not using the "variables" attribute, and are trying to pass
the variable directly as an attribute to the terraform module. This
would cause some kind of "unrecognised attribute" error in Ansible, and
Terraform would not be called at all.
- you are using the "variables" attribute, but passing a variable name
in it that Terraform doesn't know about; this would cause some kind of
error in Terraform
- you are using the "variables" attribute and you are using a variable
name known to Terraform, but the contents of the variable you are passing
are in some way incomplete or defective. This would cause some kind of
error in Terraform.
It would be helpful to see the actual code you are trying and the actual
errors produced when you do.
Regards, K.
On Mon, Dec 24, 2018 at 7:07 AM Stephen Nesbitt <[email protected]>
wrote:
> All:
>
> I am using the terraform module and have a terraform plan that contains a
> list type variable. (Ansible 2.7.2)
>
> It may be my lack of deep knowledge of YAML, but every attempt I've tried,
> results in a validation error.
>
> My suspicion is that terraform expects the list to be passed in a certain
> format. This is based on the terraform docs
> <https://www.terraform.io/docs/configuration/variables.html> which show
> that one can pass a list in as environment variable with the format:
>
> $ TF_VAR_somelist='["ami-abc123", "ami-bcd234"]' terraform plan
>
>
> But I have been utterly unable to figure out how to pass this format from
> Ansible (i.e. yaml) to Terraform.
>
> Does anyone know how I can get this to work without resorting to an
> environment variable.
>
> Thx,
>
> -steve
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/3944fde6-c611-41ff-8f95-aa21ecf461c0%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/3944fde6-c611-41ff-8f95-aa21ecf461c0%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
Karl Auer
Email : [email protected]
Website: http://2pisoftware.com
GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RdCk1G-rbWVQMHYjKbiQQ8bPtf2YHUHYLR9tTxNrMBeg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.