Last active
December 14, 2015 17:22
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice!