nbering/terraform-provider-ansible

Installation instructions are unclear and broken

danielporto opened this issue ยท 19 comments

The installation instructions are unclear,
for the sake of simplicity, please let people know that it suffices to copy the binary (in releases) to
the .terraform/plugins/*/ where * is the system where terraform is installed.

Moreover, the name of the release doesn't match the terraform naming standards for plugins.
instead of terraform-provider-ansible-v0.0.1
must be terraform-provider-ansible_v0.0.1
terraform recognize the name of the module after the "terraform-provider-" and delimits it with "_".
Without it, the module cannot be found and terraform command fails.

I'm starting with Terraform and spent quite some time figuring it out.
Thanks for the great work.

Apologies for the issue. I closed issue #2 because I've updated the build script, but haven't produced updated release archives, yet.

I'm working on a CI pipeline to do that part for me. Should have a new release this weekend, but no promises as yet.

The broken-ness should be fixed in v0.0.2.

Is there anything you think I can do with the documentation to help smooth the installation process?

I'm trying to make it work with google cloud platform and I missed some examples.
I also got a bit confused with the build process and stuff. But I can do better than complaint :-)
I will pull down the rep and fix it. ;-) Thanks!

Yes, I find Go-lang in general to be a bit confusing to build, though it has improved even just since I started this project last summer. I might try to tackle developer documentation at some point... but I'm hoping I can just point to the build instructions for another Terraform provider. No sense in re-writing the documentation for the wheel.

@nbering Are you looking for clear instructions on how to build this provider? If so, I can write those up.

Thanks!
I was building a dockerfile to pack the dependencies. But I guess the terraform-inventory is in your src dir and I couldn't compile. I will definitely appreciate that too.
I manage to make it work with GCP and I'm just finishing up some minor adjustments :D

The succinct instructions would be something like:

  1. Make sure you have Go installed. Personally I use gimme to install it:
$ sudo wget -O /usr/local/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme
$ sudo chmod +x /usr/local/bin/gimme
$ gimme 1.9 (or 1.10 which was just released)
# copy the output to your `.bashrc` and source `.bashrc`.
  1. Compile:
$ go get github.com/nbering/terraform-provider-ansible
$ cd $GOPATH/src/github.com/nbering/terraform-provider-ansible
$ make
$ cp $GOPATH/bin/terraform-provider-ansible /path/to/where/terraform/is (or one of the directories mentioned here https://www.terraform.io/docs/plugins/basics.html#installing-a-plugin)

Let me know how the above works and what needs clarified. I'm in the unfortunate position of having assumed knowledge when it comes to this ๐Ÿ˜„

I have no idea how to build and package this into a Docker image, though -- not much experience there.

I compile in CI with nothing more than the standard golang image with a few tweaks to install gox for convenient cross-compilation and the zip debian package to compress the binaries. Those extras are included in my release build script which is checked-in.

I probably don't even need gox, but I was working from the Terraform core build script which also uses gox.

Given that I run in CI from the repo and an image I don't even use in development, everything should be there for a successful build. For the terraform-inventory script, I kept that in a separate repo just because they can easily version independently for the most part, and the installation process is different for each part.

@jtopjian Funny... I never really thought to use go get for my own project, but then the repo was created on my machine. ๐Ÿ˜†

I probably don't even need gox

I believe you can do cross-compiling with go natively, but gox is a great tool to simplify the process.

Using the instructions from @jtopjian above, I'm getting the following failure when building this plugin:

$ go get github.com/nbering/terraform-provider-ansible
# github.com/nbering/terraform-provider-ansible/vendor/github.com/hashicorp/terraform/config
go/src/github.com/nbering/terraform-provider-ansible/vendor/github.com/hashicorp/terraform/config/testing.go:9: t.Helper undefined (type *testing.T has no field or method Helper)

I'm not familiar with Go, so not sure how to proceed.

To answer my own point above, in my particular case I had too old a version of Go installed. If it's possible for the source to require a minimum Go version, that would be helpful.

Terraform core recommends Go 1.6+
https://github.com/hashicorp/terraform#dependencies

Most of the implementation for this project comes from there, so that should be a good guideline.

The 1.6+ note is about the minimum Go version that will use the vendor directory. A little higher up there's:

If you wish to work on Terraform itself or any of its built-in providers, you'll first need Go installed on your machine (version 1.9+ is required).

IMO the 1.6 note should be removed... It's not possible to compile Terraform with 1.6. The error shown above (t.Helper) is specific to 1.9.

Indeed. I was struggling with 1.8 today. Upgrading to 1.10 got me moving again.

That's an interesting note. You're welcome to make a PR against the readme, or I'll updated it when I get a chance.

@nbering Do you mean a PR to add compile instructions to this repo's readme? I can certainly do that :)

@jtopjian provided a very nice breakdown for build and installation instructions. I'm going to call this closed. Please open new issues as a separate ticket, even if it's related. I'd like to break documentation issues into smaller units to make them easier for anyone to come in a pick up.