|
| 1 | +# -*- mode: ruby -*- |
| 2 | +# vi: set ft=ruby : |
| 3 | + |
| 4 | +Vagrant.configure(2) do |config| |
| 5 | + |
| 6 | + config.vm.box = "ubuntu/trusty64" |
| 7 | + config.vm.network "private_network", ip: "10.10.10.10" |
| 8 | + config.vm.hostname = "marathon-consul" |
| 9 | + config.vm.provider "virtualbox" do |vb| |
| 10 | + vb.name = "marathon-consul" |
| 11 | + end |
| 12 | + config.vm.post_up_message = """ |
| 13 | +
|
| 14 | + * Mesos: http://10.10.10.10:5050 |
| 15 | + * Marathon: http://10.10.10.10:8080 |
| 16 | + * Consul: http://10.10.10.10:8500 |
| 17 | +
|
| 18 | + """ |
| 19 | + |
| 20 | + config.vm.provision "shell", inline: <<-SHELL |
| 21 | +
|
| 22 | + curl -s https://bintray.com/user/downloadSubjectPublicKey?username=allegro | sudo apt-key add - |
| 23 | + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E56151BF |
| 24 | +
|
| 25 | + DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]') |
| 26 | + CODENAME=$(lsb_release -cs) |
| 27 | + echo "deb http://repos.mesosphere.io/${DISTRO} ${CODENAME} main" | \ |
| 28 | + sudo tee /etc/apt/sources.list.d/mesosphere.list |
| 29 | + echo "deb http://dl.bintray.com/v1/content/allegro/deb /" | \ |
| 30 | + sudo tee /etc/apt/sources.list.d/marathon-consul.list |
| 31 | + sudo add-apt-repository ppa:webupd8team/java |
| 32 | + sudo apt-get -y update |
| 33 | +
|
| 34 | + echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections |
| 35 | + sudo apt-get -qy install oracle-java8-set-default |
| 36 | +
|
| 37 | + sudo apt-get -qy install curl unzip zookeeper mesos marathon marathon-consul |
| 38 | +
|
| 39 | + echo "10.10.10.10" > /etc/mesos-slave/hostname |
| 40 | + mkdir -p /etc/marathon/conf |
| 41 | + echo "http_callback" > /etc/marathon/conf/event_subscriber |
| 42 | + echo "http://10.10.10.10:4000/events" > /etc/marathon/conf/http_endpoints |
| 43 | +
|
| 44 | + mkdir -p /usr/share/consul |
| 45 | + mkdir -p /etc/consul.d/server |
| 46 | + mkdir -p /var/consul |
| 47 | + CONSUL_VERSION=0.6.1 |
| 48 | + curl -OLs https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip |
| 49 | + unzip -o consul_${CONSUL_VERSION}_linux_amd64.zip -d /usr/local/bin && rm consul_${CONSUL_VERSION}_linux_amd64.zip |
| 50 | + curl -OLs https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_web_ui.zip |
| 51 | + unzip -o consul_${CONSUL_VERSION}_web_ui.zip -d /usr/share/consul/ui && rm consul_${CONSUL_VERSION}_web_ui.zip |
| 52 | +
|
| 53 | +cat > /etc/consul.d/server/config.json <<EOF |
| 54 | +{ |
| 55 | + "bootstrap": true, |
| 56 | + "server": true, |
| 57 | + "datacenter": "dc1", |
| 58 | + "data_dir": "/var/consul", |
| 59 | + "advertise_addr": "10.10.10.10", |
| 60 | + "client_addr": "10.10.10.10", |
| 61 | + "log_level": "INFO", |
| 62 | + "enable_syslog": true, |
| 63 | + "ui_dir": "/usr/share/consul/ui" |
| 64 | +} |
| 65 | +EOF |
| 66 | +
|
| 67 | +cat > /etc/init/consul.conf <<EOF |
| 68 | +description "Consul server process" |
| 69 | +
|
| 70 | +start on (local-filesystems and net-device-up IFACE=eth0) |
| 71 | +stop on runlevel [!12345] |
| 72 | +
|
| 73 | +respawn |
| 74 | +
|
| 75 | +exec consul agent -config-dir /etc/consul.d/server |
| 76 | +EOF |
| 77 | +
|
| 78 | + service zookeeper restart |
| 79 | + service mesos-slave restart |
| 80 | + service mesos-master restart |
| 81 | + service marathon restart |
| 82 | + service consul restart |
| 83 | + service marathon-consul restart |
| 84 | +
|
| 85 | + SHELL |
| 86 | +end |
0 commit comments