Created
February 3, 2016 00:31
-
-
Save afiune/edad1c21a8aac91e4abe to your computer and use it in GitHub Desktop.
Terraform
This file contains hidden or 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
| # | |
| # 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