Add/modify files for minimally-functional setup

Added and modified files to create a minimally functional setup.
README.md is still not up-to-date. Additional optimizations are
possible.
This commit is contained in:
Scott Lowe 2015-04-16 12:49:38 -06:00
parent 0149f75400
commit 43c10c1785
7 changed files with 108 additions and 14 deletions

View file

@ -43,13 +43,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end
# Configure VMs based on Ubuntu box
if srv.vm.box == "slowe/ubuntu-trusty-x64"
# Enable default synced folder
# Enable default synced folder (needed for provisioning)
srv.vm.synced_folder ".", "/vagrant"
# Copy files into the VM
srv.vm.provision "file", source: "server.json", destination: "/home/vagrant/config.json"
srv.vm.provision "file", source: "consul.conf", destination: "/home/vagrant/consul.conf"
# Run final provisioning script
srv.vm.provision "shell", path: "consul.sh"
# Note that default shared folder is needed for script to work
srv.vm.provision "shell", path: "provision.sh", privileged: true
end
# Configure VMs with RAM and CPUs per settings in servers.yml
srv.vm.provider :vmware_fusion do |vmw|

View file

@ -0,0 +1,12 @@
# Override file for etcd Upstart script
# Environment variables
env ETCD_INITIAL_CLUSTER="etcd-01=http://192.168.101.101:2380,etcd-02=http://192.168.101.102:2380,etcd-03=http://192.168.101.103:2380"
env ETCD_INITIAL_CLUSTER_STATE="new"
env ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
env ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.101.101:2380"
env ETCD_DATA_DIR="/var/etcd"
env ETCD_LISTEN_PEER_URLS="http://192.168.101.101:2380"
env ETCD_LISTEN_CLIENT_URLS="http://192.168.101.101:2379,http://127.0.0.1:2379"
env ETCD_ADVERTISE_CLIENT_URLS="http://192.168.101.101:2379"
env ETCD_NAME="etcd-01"

View file

@ -0,0 +1,12 @@
# Override file for etcd Upstart script
# Environment variables
env ETCD_INITIAL_CLUSTER="etcd-01=http://192.168.101.101:2380,etcd-02=http://192.168.101.102:2380,etcd-03=http://192.168.101.103:2380"
env ETCD_INITIAL_CLUSTER_STATE="new"
env ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
env ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.101.102:2380"
env ETCD_DATA_DIR="/var/etcd"
env ETCD_LISTEN_PEER_URLS="http://192.168.101.102:2380"
env ETCD_LISTEN_CLIENT_URLS="http://192.168.101.102:2379,http://127.0.0.1:2379"
env ETCD_ADVERTISE_CLIENT_URLS="http://192.168.101.102:2379"
env ETCD_NAME="etcd-02"

View file

@ -0,0 +1,12 @@
# Override file for etcd Upstart script
# Environment variables
env ETCD_INITIAL_CLUSTER="etcd-01=http://192.168.101.101:2380,etcd-02=http://192.168.101.102:2380,etcd-03=http://192.168.101.103:2380"
env ETCD_INITIAL_CLUSTER_STATE="new"
env ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
env ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.101.103:2380"
env ETCD_DATA_DIR="/var/etcd"
env ETCD_LISTEN_PEER_URLS="http://192.168.101.103:2380"
env ETCD_LISTEN_CLIENT_URLS="http://192.168.101.103:2379,http://127.0.0.1:2379"
env ETCD_ADVERTISE_CLIENT_URLS="http://192.168.101.103:2379"
env ETCD_NAME="etcd-03"

View file

@ -0,0 +1,19 @@
description "etcd 2.0 distributed key-value store"
author "Scott Lowe <scott.lowe@scottlowe.org>"
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [016]
respawn
respawn limit 10 5
script
if [ -f "/etc/default/etcd" ]; then
. /etc/default/etcd
fi
chdir /var/etcd
exec /usr/local/bin/etcd >>/var/log/etcd.log 2>&1
end script

View file

@ -0,0 +1,41 @@
#!/bin/bash
# Define a couple variables for easier future modifications
VERS="v2.0.9"
FNAME="etcd-$VERS-linux-amd64.tar.gz"
URL="https://github.com/coreos/etcd/releases/download/$VERS/$FNAME"
# Install curl if needed
if [[ ! -e /usr/bin/curl ]]; then
apt-get update
apt-get -yqq install curl
fi
# Install etcd if not already present
if [[ ! -e /usr/local/bin/etcd ]]; then
# Download the etcd release from GitHub
curl -L $URL -o $FNAME
# Expand the download
tar xzvf $FNAME
# Move etcd and etcdctl to /usr/local/bin
cd etcd-v2.0.9-linux-amd64
sudo mv etcd /usr/local/bin/
sudo mv etcdctl /usr/local/bin/
cd ..
# Remove etcd download and directory
rm $FNAME
rm -rf etcd-v2.0.9-linux-amd64
fi
# Create etcd data directory if not already present
if [[ ! -d /var/etcd ]]; then
sudo mkdir /var/etcd
fi
# Copy files into the correct locations; requires shared folders
sudo cp /vagrant/etcd.conf /etc/init/etcd.conf
sudo cp /vagrant/$HOSTNAME.override /etc/init/etcd.override

View file

@ -1,31 +1,31 @@
---
- name: consul-01
- name: etcd-01
box: slowe/ubuntu-trusty-x64
ram: 512
vcpu: 1
priv_ip: 192.168.1.101
- name: consul-02
priv_ip: 192.168.101.101
- name: etcd-02
box: slowe/ubuntu-trusty-x64
ram: 512
vcpu: 1
priv_ip: 192.168.1.102
- name: consul-03
priv_ip: 192.168.101.102
- name: etcd-03
box: slowe/ubuntu-trusty-x64
ram: 512
vcpu: 1
priv_ip: 192.168.1.103
priv_ip: 192.168.101.103
- name: coreos-01
box: coreos-stable
ram: 512
vcpu: 1
priv_ip: 192.168.1.104
priv_ip: 192.168.101.111
- name: coreos-02
box: coreos-stable
ram: 512
vcpu: 1
priv_ip: 192.168.1.105
priv_ip: 192.168.101.112
- name: coreos-03
box: coreos-stable
ram: 512
vcpu: 1
priv_ip: 192.168.1.106
priv_ip: 192.168.101.113