Created
August 14, 2015 04:25
-
-
Save yakneens/b9a2bd8823d8bd0f2993 to your computer and use it in GitHub Desktop.
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" { | |
access_key = "${var.access_key}" | |
secret_key = "${var.secret_key}" | |
region="${var.aws_region}" | |
} | |
resource "aws_security_group" "default" { | |
name = "salt_master_sg" | |
description = "Security group for the Salt Master Node" | |
# SSH access from anywhere | |
ingress { | |
from_port = 22 | |
to_port = 22 | |
protocol = "tcp" | |
cidr_blocks = ["0.0.0.0/0"] | |
} | |
# HTTP access from anywhere | |
ingress { | |
from_port = 80 | |
to_port = 80 | |
protocol = "tcp" | |
cidr_blocks = ["0.0.0.0/0"] | |
} | |
} | |
resource "aws_instance" "salt_master" { | |
ami = "${lookup(var.aws_amis, var.aws_region)}" | |
instance_type = "t1.micro" | |
security_groups = ["${aws_security_group.default.name}"] | |
connection { | |
user = "ubuntu" | |
key_file = "${var.key_path}" | |
} | |
key_name = "${var.key_name}" | |
tags = { | |
Name = "salt-master" | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
"sudo add-apt-repository ppa:saltstack/salt -y", | |
"sudo apt-get update --assume-yes" | |
] | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
"sudo apt-get install salt-common -y", | |
"sudo apt-get install salt-master -y", | |
"sudo apt-get install salt-minion -y", | |
"sudo apt-get install salt-syndic -y", | |
"sudo echo 'master: ${self.private_ip}' >> /etc/salt/minion", | |
"sudo apt-get install python-pip -y", | |
"sudo apt-get install python-git -y", | |
"sudo salt-master -d", | |
"sudo salt-minion -d" | |
] | |
} | |
provisioner "local-exec" { | |
command = "export TF_VAR_salt_master_ip=${self.public_ip}" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment