If Terraform configuration consists of one (or more?) DigitalOcean droplets, terraform.py exists with error in case user_data key is missing in *.tfstate file. I haven't checked if this is a regression introduced in a recent version of Terraform.
$ ./dynamic-inventory/terraform.py --list
Traceback (most recent call last):
File "./dynamic-inventory/terraform.py", line 658, in <module>
main()
File "./dynamic-inventory/terraform.py", line 643, in main
output = query_list(hosts)
File "./dynamic-inventory/terraform.py", line 585, in query_list
for name, attrs, hostgroups in hosts:
File "./dynamic-inventory/terraform.py", line 67, in iterhosts
yield parser(resource, module_name)
File "./dynamic-inventory/terraform.py", line 83, in inner
name, attrs, groups = func(*args, **kwargs)
File "./dynamic-inventory/terraform.py", line 153, in digitalocean_host
'metadata': json.loads(raw_attrs['user_data']),
KeyError: u'user_data'
I found a fix that works for me, but could possibly break things for other people. Honestly I don't have time nor appropriate knowledges to deeply test this, so I'm just posting my patch, in case it is helpful to somebody.
If Terraform configuration consists of one (or more?) DigitalOcean droplets,
terraform.py
exists with error in caseuser_data
key is missing in*.tfstate
file. I haven't checked if this is a regression introduced in a recent version of Terraform.Terraform and Dynamic Inventory script versions
Traceback
Terraform
*.tfstate
file contentsProposed fix
I found a fix that works for me, but could possibly break things for other people. Honestly I don't have time nor appropriate knowledges to deeply test this, so I'm just posting my patch, in case it is helpful to somebody.