radekg / terraform-provisioner-ansible

Ansible with Terraform 0.14.x
Apache License 2.0
572 stars 100 forks source link

Generate schema for use in editors such as Jetbrains IntelliJ #134

Closed benosman closed 3 years ago

benosman commented 4 years ago

I use IntelliJ IDEA along with the HCL plugin to edit terraform files.

It's helpful to have full syntax support for this ansible provisioner, especially as there is a plethora of options available. Other editors support these kind of files, which should be placed in the ~/.terraform.d/schemas directory.

Now terraform 0.12 contains a command (terraform providers schema) to generate schema for installed providers, but it does not include provisioners.

I found a gist for a golang file that creates a schema for a provider, so I adjusted it to make it work for ansible-provisioner.

I had trouble simply creating a generic tool for provisioners, as since the resource_provisioner file is in the root of the directory tree it is not importable.

So, after moving that into the ansible subfolder, I managed to get it working. Here is the resultant schema and the code I used: https://gist.github.com/benosman/1c7c6826ec45dfc8292f090056d63ef4

It would be cool if you could find a way to incorporate the generation of the schema into your build process so it gets automatically generated and placed into the repo in order to reflect any future changes to the schema.

radekg commented 4 years ago

Thank you for the tip. I'll have a look at it.

bizmate commented 4 years ago

it might not be related but i am getting error

Error: Failed to instantiate provisioner "ansible" to obtain schema: unknown provisioner "ansible"

Is this related or your request is just an enhancement for intelliJ?