diff --git a/.gitignore b/.gitignore index 546008c..1887328 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ terraform.tfvars *.swp* .chef logfiles +etcd_configs diff --git a/CHANGELOG.md b/CHANGELOG.md index 587aca5..af9bf52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ tf_hachef CHANGELOG This file is used to list changes made in each version of the tf_hachef Terraform plan. +v0.2.9 (2016-10-29) +------------------- +- Added ETCD tunable variables and implementation +- Update `private_key` for `connection` to use `${file()}` interpolation + v0.2.8 (2016-10-28) ------------------- - Updated repo structure to prepare for multiple providers and plans per provider feature set. diff --git a/providers/aws/route53_ssl/README.md b/providers/aws/route53_ssl/README.md index 5bfe196..fcd7324 100644 --- a/providers/aws/route53_ssl/README.md +++ b/providers/aws/route53_ssl/README.md @@ -645,6 +645,24 @@ these defaults and necessary inputs are defined, for your convenience in integer 180 + + etcd_path + + Path to configure ETCD settings + `/opt/chef-backend/service/etcd/env` + + + etcd_settings + + Map of settings for ETCD configuration. Key is setting name, value is the value + ETCD_HEARTBEAT_INTERVAL = 600
ETCD_ELECTION_TIMEOUT = 6000
ETCD_SNAPSHOT_COUNT = 5000 + + + etcd_restart_cmd + + Command issued to restart ETCD service + sudo chef-backend-ctl restart etcd + diff --git a/providers/aws/route53_ssl/etcd_configs/.gitkeep b/providers/aws/route53_ssl/etcd_configs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/providers/aws/route53_ssl/files/etcd_template.bash.tpl b/providers/aws/route53_ssl/files/etcd_template.bash.tpl new file mode 100644 index 0000000..842cc90 --- /dev/null +++ b/providers/aws/route53_ssl/files/etcd_template.bash.tpl @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +[[ -f ${path}/${file} ]] && sudo mv ${path}/${file} ${path}/${file}.bak +echo ${input} | sudo tee -a ${path}/${file} diff --git a/providers/aws/route53_ssl/main.tf b/providers/aws/route53_ssl/main.tf index 8e3cabd..f0992c6 100644 --- a/providers/aws/route53_ssl/main.tf +++ b/providers/aws/route53_ssl/main.tf @@ -248,7 +248,7 @@ resource "aws_instance" "chef-backends" { connection { host = "${self.public_ip}" user = "${var.ami_user[var.os]}" - private_key = "${var.instance_keys["key_file"]}" + private_key = "${file("${var.instance_keys["key_file"]}")}" } # Setup provisioner "remote-exec" { @@ -302,7 +302,7 @@ resource "null_resource" "establish_leader" { connection { host = "${aws_instance.chef-backends.0.public_ip}" user = "${var.ami_user[var.os]}" - private_key = "${var.instance_keys["key_file"]}" + private_key = "${file("${var.instance_keys["key_file"]}")}" } provisioner "remote-exec" { inline = [ @@ -335,7 +335,7 @@ resource "null_resource" "follow_leader" { connection { host = "${element(aws_instance.chef-backends.*.public_ip, count.index + 1)}" user = "${var.ami_user[var.os]}" - private_key = "${var.instance_keys["key_file"]}" + private_key = "${file("${var.instance_keys["key_file"]}")}" } provisioner "file" { source = ".chef/chef-backend-secrets.json" @@ -358,6 +358,59 @@ resource "null_resource" "follow_leader" { command = "rm -f /tmp/configuring.${sha256(element(aws_instance.chef-backends.*.id, count.index + 1))}" } } +data "template_file" "etcd_settings" { + count = "${length(var.etcd_settings)}" + template = "${file("${path.module}/files/etcd_template.bash.tpl")}" + vars { + path = "${var.etcd_path}" + file = "${element(keys(var.etcd_settings), count.index)}" + input = "${element(values(var.etcd_settings), count.index)}" + } +} +resource "null_resource" "etcd_files" { + count = "${length(var.etcd_settings)}" + provisioner "local-exec" { + command = <<-EOC + mkdir -p etcd_configs + [ -f etcd_configs/etcd_config.${count.index}.bash ] && rm -f etcd_configs/etcd_config.${count.index}.bash + tee etcd_configs/etcd_config.${count.index}.bash <