terraform-inventory
terraform-inventory copied to clipboard
Error reading tfstate file: 0.12 format error: <nil>; pre-0.12 format error: <nil> (nil error means no content/modules found in the respective format)
I updated to tf .12.6 and terraform inventory .9, but I'm getting errors that the tfstate is not current. I'm not sure why, because this is a whole new rollout started from scratch with no lingering .11 to my knowledge.
vagrant@openfirehawkserverdev:/vagrant$ /vagrant/ansible/inventory/terraform-inventory --list
Error reading tfstate file: 0.12 format error: <nil>; pre-0.12 format error: <nil> (nil error means no content/modules found in the respective format)
vagrant@openfirehawkserverdev:/vagrant$ /vagrant/ansible/inventory/terraform-inventory --version
/vagrant/ansible/inventory/terraform-inventory version 0.9
vagrant@openfirehawkserverdev:/vagrant$ terraform --version
Terraform v0.12.6
+ provider.aws v2.24.0
+ provider.null v2.1.2
+ provider.random v2.2.0
I updated to tf .12.6 and terraform inventory .9, but I'm getting errors that the tfstate is not current. I'm not sure why, because this is a whole new rollout started from scratch with no lingering .11 to my knowledge.
vagrant@openfirehawkserverdev:/vagrant$ /vagrant/ansible/inventory/terraform-inventory --list Error reading tfstate file: 0.12 format error: <nil>; pre-0.12 format error: <nil> (nil error means no content/modules found in the respective format) vagrant@openfirehawkserverdev:/vagrant$ /vagrant/ansible/inventory/terraform-inventory --version /vagrant/ansible/inventory/terraform-inventory version 0.9 vagrant@openfirehawkserverdev:/vagrant$ terraform --version Terraform v0.12.6 + provider.aws v2.24.0 + provider.null v2.1.2 + provider.random v2.2.0
Getting the same issue but using provider.vsphere
You can try terraform-inventory --list ./
; that worked for me.
#114 see PR for more details
You can try
terraform-inventory --list ./
; that worked for me.
Indeed, but as you cannot use arguments with ansible, you cannot call it from the --inventory-file option. Or am I doing something wrong?
TF_STATE=/path/to/terraform.tfstate ansible-playbook --inventory-file=/path/to/terraform-inventory test.yml
[WARNING]: * Failed to parse /path/to/terraform-inventory with script plugin: Inventory script (/path/to/terraform-inventory) had an execution error: Error reading
tfstate file: 0.12 format error: <nil>; pre-0.12 format error: <nil> (nil error means no content/modules found in the respective format)
You can try
terraform-inventory --list ./
; that worked for me.Indeed, but as you cannot use arguments with ansible, you cannot call it from the --inventory-file option. Or am I doing something wrong?
TF_STATE=/path/to/terraform.tfstate ansible-playbook --inventory-file=/path/to/terraform-inventory test.yml [WARNING]: * Failed to parse /path/to/terraform-inventory with script plugin: Inventory script (/path/to/terraform-inventory) had an execution error: Error reading tfstate file: 0.12 format error: <nil>; pre-0.12 format error: <nil> (nil error means no content/modules found in the respective format)
ok, works if TF_STATE=./
any plan to fix this without forcing the user to add the TF_STATE variable or the ./ at the end of the command? thank you
Does not works even with ./
+1 Same result here.
Terraform v0.12.25 provider.openstack v1.28.0
Working inventory:
ansible/inventory/a_terraform.sh:
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TERRAFORM_INVENTORY=`which terraform-inventory`
TF_STATE="$CURRENT_DIR/../../terraform" # <<== relative path to dir with .tfstate
"$TERRAFORM_INVENTORY" "$@" "$TF_STATE"