-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
packer files for load balancer #36
Closed
Closed
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
1c81800
Commit for packer files and scripts for terraform
wallies 2ef44d0
Merge branch 'consul-integration' into package-image-lb
wallies 558d26b
Making the instances small for testing
wallies ec4fe29
Merge branch 'master' of github.com:Capgemini/keto into package-image-lb
wallies 0ec3512
Merge branch 'master' of github.com:Capgemini/Apollo into 7-package-i…
wallies 465430e
Consul & consul template files and scripts
wallies b4b7cd0
Setup consul and haproxy when loadbalancer boots
wallies 54a44b2
Fix errors in scripts with variables
wallies 819a1f2
Fix loadbalancer script and error in slave script
wallies 46fca2b
Wercker fix to build virtualbox instead of amazon
wallies 6c18921
Fix error in names of wercker file
wallies 6ed16c5
Try fixing virtualbox on wercker
wallies 8cb124f
Fix virtiualbox on wercker
wallies 854b712
Fix virtiualbox on wercker
wallies d978244
Fix virtiualbox on wercker
wallies f519bf7
Fix virtiualbox on wercker
wallies 6457e67
Fix virtiualbox on wercker
wallies 8177de5
Fix virtiualbox on wercker
wallies f10619d
merge master and fix errors in 0.4.0
wallies 415d2a9
Fix error in build
wallies 59b873a
Merge master
wallies 4aecd13
Add missing bits to packer
wallies File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ | |
*.tfplan | ||
packer_cache | ||
packer/build | ||
*.pem | ||
.wercker |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{ | ||
"variables": { | ||
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}", | ||
"aws_secret_key": "{{env `AWS_ACCESS_KEY`}}", | ||
"mesos_version": "0.22.0-1.0.ubuntu1404", | ||
"marathon_version": "0.8.1-1.0.171.ubuntu1404", | ||
"consul_version": "0.5.0", | ||
"consul_template_version": "0.7.0", | ||
"weave_version": "latest_release", | ||
"build_version": "{{ timestamp }}" | ||
}, | ||
"builders": [{ | ||
"type": "amazon-ebs", | ||
"ami_name": "lb-ubuntu-14.04_amd64_{{user `build_version`}}", | ||
"ami_description": "Ubuntu 14.04 LTS, Docker, Consul {{user `consul_version`}}, Consul Template {{user `consul_template_version`}} and Weave {{user `weave_version`}}.", | ||
"access_key": "{{user `aws_access_key`}}", | ||
"secret_key": "{{user `aws_secret_key`}}", | ||
"region": "eu-west-1", | ||
"source_ami": "ami-394ecc4e", | ||
"instance_type": "m1.medium", | ||
"ami_groups": "all", | ||
"ssh_username": "ubuntu", | ||
"ssh_timeout": "10m", | ||
"ami_regions": ["eu-west-1"] | ||
}], | ||
"provisioners": [ | ||
{ | ||
"type": "file", | ||
"source": "scripts/common/templates", | ||
"destination": "/tmp" | ||
}, | ||
{ | ||
"type": "file", | ||
"source": "scripts/ubuntu/upstart", | ||
"destination": "/tmp" | ||
}, | ||
{ | ||
"type": "file", | ||
"source": "scripts/ubuntu/upstart/consul.conf", | ||
"destination": "/tmp/consul.conf" | ||
}, | ||
{ | ||
"type": "shell", | ||
"environment_vars": [ | ||
"CONSUL_VERSION={{user `consul_version`}}", | ||
"CONSUL_TEMPLATE_VERSION={{user `consul_template_version`}}", | ||
"WEAVE_VERSION={{user `weave_version`}}", | ||
"MESOS_VERSION={{user `mesos_version`}}", | ||
"MARATHON_VERSION={{user `marathon_version`}}" | ||
], | ||
"scripts": [ | ||
"scripts/ubuntu/base.sh", | ||
"scripts/common/sshd.sh", | ||
"scripts/ubuntu/install_docker.sh", | ||
"scripts/ubuntu/install_mesos.sh", | ||
"scripts/ubuntu/install_marathon.sh", | ||
"scripts/common/install_consul.sh", | ||
"scripts/common/install_consul_template.sh", | ||
"scripts/ubuntu/install_haproxy.sh", | ||
"scripts/ubuntu/install_dnsmasq.sh", | ||
"scripts/common/install_weave.sh" | ||
], | ||
"execute_command": "{{ .Vars }} sudo -E -S bash -c '{{ .Path }}'" | ||
}, | ||
{ | ||
"type": "file", | ||
"source": "tests", | ||
"destination": "/tmp" | ||
}, | ||
{ | ||
"type": "shell", | ||
"script": "scripts/common/serverspec.sh", | ||
"execute_command": "{{ .Vars }} sudo -E -S bash -c '{{ .Path }}'" | ||
} | ||
], | ||
"push": { | ||
"name": "capgemini/lb-ubuntu-14-04" | ||
}, | ||
"post-processors": [{ | ||
"type": "atlas", | ||
"artifact": "capgemini/lb_ubuntu-14.04_amd64", | ||
"artifact_type": "aws.ami", | ||
"metadata": { | ||
"created_at": "{{timestamp}}" | ||
} | ||
}] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{ | ||
"variables": { | ||
"ssh_name": "vagrant", | ||
"ssh_pass": "vagrant", | ||
"hostname": "ubuntu", | ||
"mesos_version": "0.22.0-1.0.ubuntu1404", | ||
"marathon_version": "0.8.1-1.0.171.ubuntu1404", | ||
"consul_version": "0.5.0", | ||
"consul_template_version": "0.7.0", | ||
"weave_version": "latest_release", | ||
"build_version": "{{ timestamp }}" | ||
}, | ||
"builders": [{ | ||
"type": "virtualbox-iso", | ||
"guest_os_type": "Ubuntu_64", | ||
"headless": true, | ||
"vm_name": "lb_ubuntu-14.04_amd64_virtualbox_{{user `build_version`}}", | ||
"disk_size": 40960, | ||
"vboxmanage": [ | ||
[ "modifyvm", "{{.Name}}", "--memory", "2048" ], | ||
[ "modifyvm", "{{.Name}}", "--cpus", "2" ] | ||
], | ||
"iso_url": "http://releases.ubuntu.com/14.04.2/ubuntu-14.04.2-server-amd64.iso", | ||
"iso_checksum": "83aabd8dcf1e8f469f3c72fff2375195", | ||
"iso_checksum_type": "md5", | ||
"http_directory" : "./http/ubuntu-14.04", | ||
"http_port_min" : 9001, | ||
"http_port_max" : 9001, | ||
"boot_command" : [ | ||
"<esc><esc><enter><wait>", | ||
"/install/vmlinuz noapic ", | ||
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ", | ||
"debian-installer=en_US auto locale=en_US kbd-chooser/method=us ", | ||
"hostname={{user `hostname`}} ", | ||
"fb=false debconf/frontend=noninteractive ", | ||
"keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ", | ||
"keyboard-configuration/variant=USA console-setup/ask_detect=false ", | ||
"initrd=/install/initrd.gz -- <enter>" | ||
], | ||
"ssh_username": "{{user `ssh_name`}}", | ||
"ssh_password": "{{user `ssh_pass`}}", | ||
"ssh_wait_timeout": "60m", | ||
"shutdown_command": "echo '{{user `ssh_pass`}}' | sudo -S shutdown -P now", | ||
"output_directory": "build/ubuntu-14.04_amd64_virtualbox", | ||
"format": "ova" | ||
}], | ||
"provisioners": [ | ||
{ | ||
"type": "file", | ||
"source": "scripts/common/templates", | ||
"destination": "/tmp" | ||
}, | ||
{ | ||
"type": "file", | ||
"source": "scripts/ubuntu/upstart", | ||
"destination": "/tmp" | ||
}, | ||
{ | ||
"type": "file", | ||
"source": "scripts/ubuntu/upstart/consul.conf", | ||
"destination": "/tmp/consul.conf" | ||
}, | ||
{ | ||
"type": "shell", | ||
"environment_vars": [ | ||
"CONSUL_VERSION={{user `consul_version`}}", | ||
"CONSUL_TEMPLATE_VERSION={{user `consul_template_version`}}", | ||
"WEAVE_VERSION={{user `weave_version`}}", | ||
"MESOS_VERSION={{user `mesos_version`}}", | ||
"MARATHON_VERSION={{user `marathon_version`}}" | ||
], | ||
"scripts": [ | ||
"scripts/ubuntu/base.sh", | ||
"scripts/ubuntu/virtualbox/install-dkms.sh", | ||
"scripts/common/virtualbox/install_vbox_guest_additions.sh", | ||
"scripts/common/virtualbox/sudoers.sh", | ||
"scripts/common/virtualbox/vagrant_ssh.sh", | ||
"scripts/common/sshd.sh", | ||
"scripts/ubuntu/install_docker.sh", | ||
"scripts/ubuntu/install_mesos.sh", | ||
"scripts/ubuntu/install_marathon.sh", | ||
"scripts/common/install_consul.sh", | ||
"scripts/common/install_consul_template.sh", | ||
"scripts/ubuntu/install_haproxy.sh", | ||
"scripts/ubuntu/install_dnsmasq.sh", | ||
"scripts/common/install_weave.sh" | ||
], | ||
"execute_command": "echo '{{user `ssh_pass`}}' | {{ .Vars }} sudo -E -S bash -c '{{ .Path }}'" | ||
} | ||
], | ||
"post-processors": [{ | ||
"type": "vagrant", | ||
"output": "build/ubuntu-14.04_amd64_{{.Provider}}/lb_ubuntu-14.04_amd64_{{.Provider}}_{{user `build_version`}}.box", | ||
"keep_input_artifact": true | ||
}] | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# install consul template | ||
wget https://github.com/hashicorp/consul-template/releases/download/v${CONSUL_TEMPLATE_VERSION}/consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64.tar.gz | ||
tar xzf consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64.tar.gz | ||
sudo mv consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64/consul-template /usr/bin | ||
sudo rmdir consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64 | ||
|
||
# consul template upstart for haproxy | ||
sudo cp /tmp/upstart/consul_template.conf /etc/init/consul_template.conf |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
global | ||
maxconn 4 | ||
log 127.0.0.1 local0 notice | ||
user haproxy | ||
group haproxy | ||
|
||
defaults | ||
log global | ||
retries 2 | ||
timeout connect 3000 | ||
timeout server 5000 | ||
timeout client 5000 | ||
|
||
listen stats *:1936 | ||
mode http | ||
stats enable | ||
stats uri /haproxy?stats | ||
stats hide-version |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
global | ||
chroot /var/lib/haproxy | ||
daemon | ||
group root | ||
log 127.0.0.1 local0 | ||
maxconn 8000 | ||
pidfile /var/run/haproxy.pid | ||
stats socket /var/lib/haproxy/stats | ||
user root | ||
# Descrease the size of the rewrite buffer so that | ||
# there is more room to handle large (>8K) headers. See the HAProxy | ||
# manual around tune.bufsize and tune.maxrewrite. | ||
tune.maxrewrite 4096 | ||
|
||
|
||
defaults | ||
log global | ||
retries 2 | ||
timeout connect 3000 | ||
timeout server 5000 | ||
timeout client 5000 | ||
|
||
defaults | ||
log global | ||
maxconn 8000 | ||
option redispatch | ||
option http-server-close | ||
retries 3 | ||
stats enable | ||
timeout http-request 10s | ||
timeout queue 1m | ||
timeout connect 10s | ||
timeout client 1m | ||
timeout server 1m | ||
timeout check 10s | ||
option forwardfor except 127.0.0.1 | ||
mode http | ||
|
||
listen stats *:1936 | ||
mode http | ||
stats enable | ||
stats uri /haproxy?stats | ||
stats hide-version | ||
|
||
frontend inbound | ||
bind :80 name http |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# install HAproxy | ||
sudo apt-get install -y haproxy | ||
sudo chmod a+w /etc/rsyslog.conf | ||
echo '$ModLoad imudp' >> /etc/rsyslog.conf | ||
echo '$UDPServerAddress 127.0.0.1' >> /etc/rsyslog.conf | ||
echo '$UDPServerRun 514' >> /etc/rsyslog.conf | ||
sudo service rsyslog restart | ||
sup cp /tmp/templates/haproxy.cfg /etc/haproxy/haproxy.cfg | ||
|
||
# eve upstart | ||
sudo cp /tmp/upstart/haproxy.conf /etc/init/haproxy.conf | ||
|
||
# consul config | ||
echo '{"service": {"name": "haproxy", "tags": ["haproxy"]}}' > /etc/consul.d/haproxy.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
description "Consul Template" | ||
|
||
start on vagrant-ready or runlevel [2345] | ||
stop on runlevel [!2345] | ||
|
||
respawn | ||
|
||
console log | ||
|
||
script | ||
exec /usr/bin/consul-template \ | ||
-consul 127.0.0.1:8500 \ | ||
-template "/tmp/templates/haproxy.ctmpl:/etc/haproxy/haproxy.cfg:service haproxy restart" >> /var/log/ctemplate.log 2>&1 | ||
end script |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
description "Haproxy upstart script" | ||
|
||
start on startup | ||
|
||
env PID_PATH=/var/run/haproxy.pid | ||
env BIN_PATH=/usr/sbin/haproxy | ||
env CONF_PATH=/etc/haproxy/haproxy.cfg | ||
|
||
script | ||
exec /bin/bash <<EOF | ||
$BIN_PATH -f $CONF_PATH -D -p $PID_PATH | ||
|
||
trap "$BIN_PATH -f $CONF_PATH -p $PID_PATH -sf \\\$(cat $PID_PATH)" SIGHUP | ||
trap "kill -TERM \\\$(cat $PID_PATH) && exit 0" SIGTERM SIGINT | ||
|
||
while true; do # Iterate to keep job running. | ||
sleep 1 # Don't sleep to long as signals will not be handled during sleep. | ||
done | ||
EOF | ||
end script |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* Loabalancer server */ | ||
resource "atlas_artifact" "loadbalancer" { | ||
name = "${var.atlas_artifact.loadbalancer}" | ||
type = "aws.ami" | ||
} | ||
|
||
resource "aws_instance" "loadbalancer" { | ||
instance_type = "${var.instance_type.loadbalancer}" | ||
ami = "${atlas_artifact.loadbalancer.metadata_full.region-eu-west-1}" | ||
count = "${var.loadbalancer}" | ||
key_name = "${var.key_name}" | ||
source_dest_check = false | ||
subnet_id = "${aws_subnet.public.id}" | ||
security_groups = ["${aws_security_group.default.id}", "${aws_security_group.loadbalancer.id}"] | ||
depends_on = ["aws_internet_gateway.public"] | ||
tags = { | ||
Name = "capgemini-mesos-loadbalancer" | ||
} | ||
connection { | ||
user = "ubuntu" | ||
key_file = "${var.key_file}" | ||
host = "${aws_instance.loadbalancer.public_ip}" | ||
script_path = "/tmp/${self.id}.sh" | ||
} | ||
provisioner "file" { | ||
source = "${path.module}/scripts/common.sh" | ||
destination = "/tmp/${self.id}-00common.sh" | ||
} | ||
provisioner "file" { | ||
source = "${path.module}/scripts/setup-loadbalancer.sh" | ||
destination = "/tmp/${self.id}-01setup-loadbalancer.sh" | ||
} | ||
provisioner "remote-exec" { | ||
inline = [ | ||
"echo main ${self.private_ip} ${self.private_dns} ${var.atlas_token} ${var.atlas_infrastructure} | cat /tmp/${self.id}-*.sh - | bash" | ||
] | ||
} | ||
} | ||
|
||
resource "aws_eip" "loadbalancer" { | ||
instance = "${aws_instance.loadbalancer.id}" | ||
vpc = true | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
output "nat.ip" { | ||
value = "${aws_eip.nat.public_ip}" | ||
} | ||
|
||
output "loadbalancer.ip" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for the true IP address we need to use |
||
value = "${aws_eip.loadbalancer.public_ip}" | ||
} | ||
|
||
output "master.0.ip" { | ||
value = "${aws_instance.mesos-master.0.private_ip}" | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some indentation oddities in this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling (loadbalancer)