Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/bin/bash
##
# Compiling terraform-provisioner-ansible for Terraform 0.7.13 for Ubuntu Trusty
#
# $ mkdir terraform-trusty64
# $ cd terraform-trusty64/
# $ vagrant init ubuntu/trusty64
# $ vagrant up
# $ vagrant ssh
## Then run this script
sudo apt-get -y update
sudo apt-get install -y unzip git
mkdir $HOME/opt
cd $HOME/opt
wget -c https://storage.googleapis.com/golang/go1.7.3.linux-amd64.tar.gz
tar zxvf go1.7.3*gz
mkdir -p $HOME/work
echo 'export GOPATH=$HOME/work' >> $HOME/.bashrc
echo 'export GOROOT=$HOME/opt/go' >> $HOME/.bashrc
echo 'export PATH=$HOME/opt/go/bin:$PATH' >> $HOME/.bashrc
. $HOME/.bashrc
go env | grep GOPATH
go env | grep GOROOT
cd $GOPATH
mkdir {src,pkg,bin}
cd src/
git clone https://github.com/jonmorehouse/terraform-provisioner-ansible
cd terraform-provisioner-ansible/
go get -v
### Use tag v0.7.13 for plugin to work.
cd ~/work/src/github.com/hashicorp/terraform
git checkout v0.7.13
## Start rebuilding 0.7.13 version of terraform-provisioner. Goto hash w/o fixes yet.
cd $GOPATH/src/terraform-provisioner-ansible/
git checkout 5bfee6931ea36f53bb70fc5c013072be7f55c922
sed -i '/"apt-get update",/a "apt-get install -y libffi-dev libssl-dev",' provisioner.go
go build
mkdir $HOME/bin
cp terraform-provisioner-ansible $HOME/bin
## Configure terraform and provisioner
cd $HOME/bin
wget https://releases.hashicorp.com/terraform/0.7.13/terraform_0.7.13_linux_amd64.zip
unzip terraform_0.7.13_linux_amd64.zip
echo 'export PATH=$HOME/bin:$PATH' >> $HOME/.bashrc
export PATH=$HOME/bin:$PATH
cat <<EOF > $HOME/.terraformrc
provisioners {
ansible = "/home/vagrant/bin/terraform-provisioner-ansible"
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment