Skip to content

Instantly share code, notes, and snippets.

@afiune
Created February 3, 2016 00:31
Show Gist options
  • Select an option

  • Save afiune/edad1c21a8aac91e4abe to your computer and use it in GitHub Desktop.

Select an option

Save afiune/edad1c21a8aac91e4abe to your computer and use it in GitHub Desktop.
Terraform
#
# Instances
#
# Setup chef-server
resource "aws_instance" "chef-server" {
ami = "${lookup(var.centos-6-amis, var.aws_default_region)}"
count = "${lookup(var.instance_counts, "chef-server")}"
instance_type = "${lookup(var.instances, "chef-server")}"
subnet_id = "${aws_subnet.terraform-delivery-cluster.id}"
vpc_security_group_ids = ["${aws_security_group.chef-server.id}"]
key_name = "${var.aws_key_pair_name}"
tags {
Name = "${format("chef-server-%02d", count.index + 1)}"
}
root_block_device = {
delete_on_termination = true
}
# Copies all cookbooks that we need to trigger a chef-zero
provisioner "file" {
connection {
user = "${var.aws_ami_user}"
private_key = "${file("${aws_key_pair_name}.pem")}"
}
source = "cookbooks"
destination = "/tmp"
}
provisioner "remote-exec" {
connection {
user = "${var.aws_ami_user}"
private_key = "${file("${aws_key_pair_name}.pem")}"
}
inline = [
"sudo service iptables stop",
"sudo chkconfig iptables off",
"curl -LO https://www.chef.io/chef/install.sh && sudo bash ./install.sh -P chefdk -n && rm install.sh",
"cd /tmp; sudo chef exec chef-client -z -o chef-server-12"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment