TASK [common : debug] **********************************************************
fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'server_name' is undefined\n\nThe error appears to have been in '/tmp/ansible/roles/common/tasks/main.yml': line 1, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- debug: var=\"{{ server_name }}\"\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with_items:\n - {{ foo }}\n\nShould be written as:\n\n with_items:\n - \"{{ foo }}\"\n"}
Problem
A play expects the Terraform Ansible provisioner to pass
extra_vars
but the play fails because the variable is undefined.Steps to Reproduce
Terraform configuration snippet
Command run on instance
In
roles/common/tasks/main.yml
Output
Versions
Workaround
The non-idiomatic workaround appears to be replacing https://github.com/jonmorehouse/terraform-provisioner-ansible/blob/master/ansible-local.py#L113 with
Perhaps this is related or I am simply misunderstanding the issue.