1
1
mirror of https://github.com/adammck/terraform-inventory synced 2024-09-26 13:01:01 +02:00

Add Homebrew formula

This commit is contained in:
Adam Mckaig 2015-02-09 16:51:45 -05:00
parent 50e6962e46
commit 3531532d21
2 changed files with 45 additions and 10 deletions

View File

@ -5,14 +5,18 @@ from a [Terraform] [tf] state file. It allows one to spawn a bunch of VMs with
Terraform, then (re-)provision them with Ansible. It's pretty neat.
# Installation
On OSX, install it with Homebrew:
brew install https://raw.github.com/adammck/terraform-inventory/master/homebrew/terraform-inventory.rb
This is only a tiny tool, so it's not in the main Homebrew repo. Feel free to
add it, if you think that would be useful.
## Usage
Just download the OSX binary and run it.
curl -L -O https://github.com/adammck/terraform-inventory/releases/download/v0.2/terraform-inventory
chmod u+x terraform-inventory
./terraform-inventory --list whatever.tfstate
Ansible doesn't (seem to) support calling the inventory script with parameters
(and this tool doesn't support configuration via environment variables yet), so
I like to create a little shell script and call that. Something like:
@ -27,10 +31,10 @@ Then run Ansible with the script as an inventory:
## Development
[Install Terraform] [tfdev] from source, then:
It's just a Go app, so the usual:
git clone https://github.com/adammck/terraform-inventory.git
cd terraform-inventory
go get github.com/adammck/terraform-inventory
cd $GOPATH/adammck/terraform-inventory
go build
@ -43,4 +47,3 @@ MIT.
[ansible]: http://www.ansible.com
[tf]: http://www.terraform.io
[tfdev]: https://github.com/hashicorp/terraform#developing-terraform

View File

@ -0,0 +1,32 @@
class TerraformInventory < Formula
homepage "https://github.com/adammck/terraform-inventory"
head "https://github.com/adammck/terraform-inventory.git"
# Update these when a new version is released
url "https://github.com/adammck/terraform-inventory/archive/0.3.tar.gz"
sha1 "fc4d492e328255b422429e221ff7d31533da96f9"
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
# Move the contents of the repo (which are currently in the buildpath) into
# a go-style subdir, so we can build it without spewing deps everywhere.
app_path = buildpath/"src/github.com/adammck/terraform-inventory"
app_path.install Dir["*"]
# Fetch the deps (into our temporary gopath) and build
cd "src/github.com/adammck/terraform-inventory" do
system "go", "get"
system "go", "build", "-ldflags", "-X main.build_version '#{version}'"
end
# Install the resulting binary
bin.install "bin/terraform-inventory"
end
test do
system "#{bin}/terraform-inventory", "version"
end
end