fd8772f442
This change started out as a quick update to RHEL 7 support (aka systemd), in the process I realized most of the other platforms could use an update. While trying to cleanup there I discovered I was repeating of bunch of information that might be better maintained in one place - as a result: * consolidated server.sh and install.sh * removed upstart-join.conf in a favor of join flag in the consul start * removed platform specific folders and increased complexity of install.sh to include handling the differences * updated and extracted consul version * added a consistent ip_table.sh file to open ports on firewalls * updating consul service management configurations to enable proper restarting behavior for each platform * the configuration naming convention is <distro_origin>_file_name * added platform to the security group name so you can easily launch multpile platforms at once * fixes #1304
75 lines
1.8 KiB
HCL
75 lines
1.8 KiB
HCL
resource "aws_instance" "server" {
|
|
ami = "${lookup(var.ami, concat(var.region, "-", var.platform))}"
|
|
instance_type = "${var.instance_type}"
|
|
key_name = "${var.key_name}"
|
|
count = "${var.servers}"
|
|
security_groups = ["${aws_security_group.consul.name}"]
|
|
|
|
connection {
|
|
user = "${lookup(var.user, var.platform)}"
|
|
key_file = "${var.key_path}"
|
|
}
|
|
|
|
#Instance tags
|
|
tags {
|
|
Name = "${var.tagName}-${count.index}"
|
|
}
|
|
|
|
provisioner "file" {
|
|
source = "${path.module}/scripts/${lookup(var.service_conf, var.platform)}"
|
|
destination = "/tmp/${lookup(var.service_conf_dest, var.platform)}"
|
|
}
|
|
|
|
|
|
provisioner "remote-exec" {
|
|
inline = [
|
|
"echo ${var.servers} > /tmp/consul-server-count",
|
|
"echo ${aws_instance.server.0.private_dns} > /tmp/consul-server-addr",
|
|
]
|
|
}
|
|
|
|
provisioner "remote-exec" {
|
|
scripts = [
|
|
"${path.module}/scripts/install.sh",
|
|
"${path.module}/scripts/service.sh",
|
|
"${path.module}/scripts/ip_tables.sh",
|
|
]
|
|
}
|
|
}
|
|
|
|
resource "aws_security_group" "consul" {
|
|
name = "consul_${var.platform}"
|
|
description = "Consul internal traffic + maintenance."
|
|
|
|
// These are for internal traffic
|
|
ingress {
|
|
from_port = 0
|
|
to_port = 65535
|
|
protocol = "tcp"
|
|
self = true
|
|
}
|
|
|
|
ingress {
|
|
from_port = 0
|
|
to_port = 65535
|
|
protocol = "udp"
|
|
self = true
|
|
}
|
|
|
|
// These are for maintenance
|
|
ingress {
|
|
from_port = 22
|
|
to_port = 22
|
|
protocol = "tcp"
|
|
cidr_blocks = ["0.0.0.0/0"]
|
|
}
|
|
|
|
// This is for outbound internet access
|
|
egress {
|
|
from_port = 0
|
|
to_port = 0
|
|
protocol = "-1"
|
|
cidr_blocks = ["0.0.0.0/0"]
|
|
}
|
|
}
|