2014-07-14 17:50:04 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
# exit on any error
|
|
|
|
set -e
|
|
|
|
source $(dirname $0)/provision-config.sh
|
|
|
|
|
|
|
|
MINION_IP=$4
|
|
|
|
|
2014-08-12 19:43:35 +00:00
|
|
|
# make sure each minion has an entry in hosts file for master
|
|
|
|
if [ ! "$(cat /etc/hosts | grep $MASTER_NAME)" ]; then
|
|
|
|
echo "Adding host entry for $MASTER_NAME"
|
|
|
|
echo "$MASTER_IP $MASTER_NAME" >> /etc/hosts
|
|
|
|
fi
|
2014-07-14 17:50:04 +00:00
|
|
|
|
2014-08-12 19:43:35 +00:00
|
|
|
# Let the minion know who its master is
|
|
|
|
mkdir -p /etc/salt/minion.d
|
|
|
|
echo "master: $MASTER_NAME" > /etc/salt/minion.d/master.conf
|
2014-07-14 17:50:04 +00:00
|
|
|
|
2014-08-12 19:43:35 +00:00
|
|
|
# Our minions will have a pool role to distinguish them from the master.
|
|
|
|
cat <<EOF >/etc/salt/minion.d/grains.conf
|
2014-07-14 17:50:04 +00:00
|
|
|
grains:
|
|
|
|
minion_ip: $MINION_IP
|
|
|
|
etcd_servers: $MASTER_IP
|
|
|
|
roles:
|
|
|
|
- kubernetes-pool
|
|
|
|
cbr-cidr: $MINION_IP_RANGE
|
|
|
|
EOF
|
|
|
|
|
2014-08-12 19:43:35 +00:00
|
|
|
# we will run provision to update code each time we test, so we do not want to do salt install each time
|
|
|
|
if [ ! $(which salt-minion) ]; then
|
2014-07-14 17:50:04 +00:00
|
|
|
# Install Salt
|
|
|
|
#
|
|
|
|
# We specify -X to avoid a race condition that can cause minion failure to
|
|
|
|
# install. See https://github.com/saltstack/salt-bootstrap/issues/270
|
2014-08-01 13:07:05 +00:00
|
|
|
curl -sS -L http://bootstrap.saltstack.com | sh -s -- -X
|
2014-07-14 17:50:04 +00:00
|
|
|
|
|
|
|
## TODO this only works on systemd distros, need to find a work-around as removing -X above fails to start the services installed
|
|
|
|
systemctl enable salt-minion
|
|
|
|
systemctl start salt-minion
|
|
|
|
fi
|