# Ansible terraform module - passing variables

**URL:** <https://forum.ansible.com/t/ansible-terraform-module-passing-variables/29164>\
**Category:** Ansible Project\
**Created:** [November 30, 2018, 5:03pm UTC](https://forum.ansible.com/t/ansible-terraform-module-passing-variables/29164 "2018-11-30T17:03:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DK1](https://avatars.discourse-cdn.com/v4/letter/d/439d5e/32.png) [@DK1](https://forum.ansible.com/u/DK1)\
**Post date:** [November 30, 2018, 5:03pm UTC](https://forum.ansible.com/t/ansible-terraform-module-passing-variables/29164/1 "2018-11-30T17:03:27Z")

</div>

I’m hitting the following error with the terraform module.  
What am I doing wrong when passing variables? I’ve also tried surrounding the variables in double quotes

- terraform:  
project\_path: ‘{{ role\_path }}/terraform/’  
state: present  
force\_init: true  
variables:  
vsphere\_username: foo  
vsphere\_password: bar  
vsphere\_server: 10.123.45.6  
datacenter\_name: SAN-R720  
datastore\_name: VMFS6\_K8S\_DS001  
network\_name: Dev Network 40.x  
esxi\_hosts: 10.123.45.7  
resource\_pool: cluster1/Resources  
template\_name: centos-vm-tmpl  
vm\_name\_prefix: terra-vm  
vm\_num\_cpus: 2  
vm\_memory: 1024  
vm\_guest\_id: centos64Guest  
vm\_scsi\_type: pvscsi  
vm\_ipv4\_address: [“10.123.45.111”]  
vm\_ipv4\_gateway: 10.123.45.254  
vm\_ipv4\_netmask: 24  
vm\_dns\_domain: [my.domain.com](http://my.domain.com)  
vm\_dns\_server\_list: [  
“10.123.45.253”,  
“10.123.45.22”,  
]  
vm\_dns\_suffix\_list: [  
“[dev.mycompany.com](http://dev.mycompany.com)”,  
“[mycompany.com](http://mycompany.com)”  
]

TASK [create-vms: terraform] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [127.0.0.1]: FAILED! =\> {  
“changed”: false  
}

MSG:

Failed to initialize Terraform modules:

Error: resource ‘data.vsphere\_resource\_pool.resource\_pool’ config: unknown variable referenced: ‘esxi\_hosts’; define it with a ‘variable’ block

Error: resource ‘data.vsphere\_network.network’ config: unknown variable referenced: ‘network\_name’; define it with a ‘variable’ block

Error: resource ‘vsphere\_virtual\_machine.vm’ count: unknown variable referenced: ‘vm\_ipv4\_address’; define it with a ‘variable’ block

Error: output ‘ESXi’: unknown variable referenced: ‘esxi\_hosts’; define it with a ‘variable’ block
