Skip to content

Instantly share code, notes, and snippets.

@MattSurabian
Last active December 14, 2015 17:22
Show Gist options
  • Save MattSurabian/dcd7dc31b976844c4df4 to your computer and use it in GitHub Desktop.
Save MattSurabian/dcd7dc31b976844c4df4 to your computer and use it in GitHub Desktop.
terraform ansible provisioning hack uses environment variables:DEBIAN_FRONTEND=noninteractive, AWS_PRIV_KEY=one line using \n, ANSIBLE_HOST_KEY_CHECKING=false, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY
provider "aws" {
region = "us-east-1"
}
resource "aws_instance" "terraform-test" {
ami = "ami-408c7f28"
instance_type = "t1.micro"
key_name = "atlas-testing"
security_groups = ["terraform-testing"]
}
resource "null_resource" "Provision" {
provisioner "local-exec" {
command = <<EOF
sudo apt-get -y update
sudo apt-get -y install python-dev python-pip
sudo pip install ansible
echo $AWS_PRIV_KEY > priv.key
chmod 400 priv.key
ansible-playbook --private-key=priv.key -u ubuntu -i ${aws_instance.terraform-test.public_ip}, ansible/deploy.yml
EOF
}
}
@tkellen
Copy link

tkellen commented Sep 30, 2015

nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment