Hello,
I was using terraform 0.14.9 and ansible 2.10.15 to create ressources.
it’s working well !
I install the last terraform version (1.0.9) and it seems that there is an issue with the terraform module inside ansible & the “terraform validate” part.
Here my ansible code to launch terraform (work perfectly with terraform 0.14.x).
- name: Apply Terraform for OS creation
terraform:
binary_path: "/usr/bin/terraform"
project_path: "{{ playbook_dir }}/roles/os/terraform"
force_init: yes
variables_file: "{{ playbook_dir }}/vars/os/{{ reg }}/common.tfvars"
variables:
week_number: "{{ week_number }}"
environment:
AWS_ACCESS_KEY_ID: "{{ AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "{{ AWS_SECRET_ACCESS_KEY }}"
when: ope == "create"
With terraform 1.0.9, i have this issue now :
fatal: [localhost]: FAILED! => {"changed": false, **"cmd": “/usr/bin/terraform validate -var week_number=43 -var-file /home/test-user/test-Terraform/vars/os/paris/common.tfvars”
"msg":
- Error: Failed to parse command-line flags flag provided but not defined: -var
- Error: Too many command line arguments Expected at most one positional argument. For more help on using this command, run: terraform validate -help, "rc": 1, "stderr": Failed to parse command-line flags flag provided but not defined: -var
It seems that the error is coming from the “terraform validate” that dont take “-var” or “-var-file” as parameter since 0.15.x release, but ansible still try to apply it.
Is there a way to bypass/correct this evolution ?
Thanks for your help.
Antoine.