Fix `vagrant provision` with a bunch of guards

This commit is contained in:
Michael Schurter 2017-01-27 13:08:50 -08:00
parent d2bc719a26
commit a0d792ea77
5 changed files with 51 additions and 28 deletions

44
Vagrantfile vendored
View File

@ -8,17 +8,19 @@ DEFAULT_CPU_COUNT = 2
$script = <<SCRIPT
GO_VERSION="1.7.5"
export DEBIAN_FRONTEND=noninteractive
sudo dpkg --add-architecture i386
sudo apt-get update
# Install base dependencies
sudo apt-get install -y build-essential curl git-core mercurial bzr \
libpcre3-dev pkg-config zip default-jre qemu silversearcher-ag jq htop \
vim unzip tree \
liblxc1 lxc-dev lxc-templates \ # lxc
gcc-5-aarch64-linux-gnu binutils-aarch64-linux-gnu \ # arm64
libc6-dev-i386 linux-libc-dev:i386 \ # i386
gcc-5-arm-linux-gnueabi gcc-5-multilib-arm-linux-gnueabi binutils-arm-linux-gnueabi # arm
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential curl git-core mercurial bzr \
libpcre3-dev pkg-config zip default-jre qemu silversearcher-ag \
jq htop vim unzip tree \
liblxc1 lxc-dev lxc-templates \
gcc-5-aarch64-linux-gnu binutils-aarch64-linux-gnu \
libc6-dev-i386 linux-libc-dev:i386 \
gcc-5-arm-linux-gnueabi gcc-5-multilib-arm-linux-gnueabi binutils-arm-linux-gnueabi
# Setup go, for development of Nomad
SRCROOT="/opt/go"
@ -28,12 +30,16 @@ SRCPATH="/opt/gopath"
ARCH=`uname -m | sed 's|i686|386|' | sed 's|x86_64|amd64|'`
# Install Go
cd /tmp
wget -q https://storage.googleapis.com/golang/go${GO_VERSION}.linux-${ARCH}.tar.gz
tar -xf go${GO_VERSION}.linux-${ARCH}.tar.gz
sudo mv go $SRCROOT
sudo chmod 775 $SRCROOT
sudo chown ubuntu:ubuntu $SRCROOT
if [[ $(go version) == "go version go${GO_VERSION} linux/${ARCH}" ]]; then
echo "Go ${GO_VERSION} ${ARCH} already installed; Skipping"
else
cd /tmp
wget -q https://storage.googleapis.com/golang/go${GO_VERSION}.linux-${ARCH}.tar.gz
tar -xf go${GO_VERSION}.linux-${ARCH}.tar.gz
sudo mv go $SRCROOT
sudo chmod 775 $SRCROOT
sudo chown ubuntu:ubuntu $SRCROOT
fi
# Setup the GOPATH; even though the shared folder spec gives the working
# directory the right user/group, we need to set it properly on the
@ -52,10 +58,14 @@ sudo chmod 0755 /etc/profile.d/gopath.sh
source /etc/profile.d/gopath.sh
# Install Docker
echo deb https://apt.dockerproject.org/repo ubuntu-`lsb_release -c | awk '{print $2}'` main | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo apt-get update
sudo apt-get install -y docker-engine
if [[ -f /etc/apt/sources.list.d/docker.list ]]; then
echo "Docker repository already installed; Skipping"
else
echo deb https://apt.dockerproject.org/repo ubuntu-`lsb_release -c | awk '{print $2}'` main | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo apt-get update
fi
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker-engine
# Restart docker to make sure we get the latest version of the daemon if there is an upgrade
sudo service docker restart

View File

@ -1,13 +1,18 @@
#!/bin/bash
set -ex
set -e
CONSUL_VERSION="0.7.2"
CONSUL_VERSION="0.7.3"
CURDIR=`pwd`
if [[ $(consul version | head -n 1 | cut -d ' ' -f 2) == "v$CONSUL_VERSION" ]]; then
echo "Consul v$CONSUL_VERSION already installed; Skipping"
exit
fi
echo Fetching Consul...
cd /tmp/
wget https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip -O consul.zip
wget -q https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip -O consul.zip
echo Installing Consul...
unzip consul.zip
sudo chmod +x consul

View File

@ -1,6 +1,6 @@
#!/bin/bash
set -ex
set -e
RKT_VERSION="v1.18.0"
CMD="cp"
@ -14,7 +14,7 @@ if [ ! -d "rkt-${RKT_VERSION}" ]; then
printf "rkt-%s/ doesn't exist\n" "${RKT_VERSION}"
if [ ! -f "rkt-${RKT_VERSION}.tar.gz" ]; then
printf "Fetching rkt-%s.tar.gz\n" "${RKT_VERSION}"
wget https://github.com/coreos/rkt/releases/download/$RKT_VERSION/rkt-$RKT_VERSION.tar.gz
wget -q https://github.com/coreos/rkt/releases/download/$RKT_VERSION/rkt-$RKT_VERSION.tar.gz
tar xzvf rkt-$RKT_VERSION.tar.gz
fi
fi

View File

@ -1,8 +1,11 @@
#!/bin/bash
set -ex
set -e
# Configure rkt networking
sudo mkdir -p /etc/rkt/net.d
echo '{"name": "default", "type": "ptp", "ipMasq": false, "ipam": { "type": "host-local", "subnet": "172.16.28.0/24", "routes": [ { "dst": "0.0.0.0/0" } ] } }' | sudo tee -a /etc/rkt/net.d/99-network.conf
if [[ -f /etc/rkt/net.d/99-network.conf ]]; then
echo "rkt network already configured; Skipping"
exit
fi
echo '{"name": "default", "type": "ptp", "ipMasq": false, "ipam": { "type": "host-local", "subnet": "172.16.28.0/24", "routes": [ { "dst": "0.0.0.0/0" } ] } }' | jq . | sudo tee -a /etc/rkt/net.d/99-network.conf

View File

@ -1,13 +1,18 @@
#!/bin/bash
set -ex
set -e
VAULT_VERSION="0.6.2"
VAULT_VERSION="0.6.4"
CURDIR=`pwd`
if [[ $(vault version | cut -d ' ' -f 2) == "v$VAULT_VERSION" ]]; then
echo "Vault v$VAULT_VERSION already installed; Skipping"
exit
fi
echo Fetching Vault ${VAULT_VERSION}...
cd /tmp/
wget https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip -O vault.zip
wget -q https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip -O vault.zip
echo Installing Vault...
unzip vault.zip
sudo chmod +x vault