Merge "pkg/pip salt-master bootstrap with pkg/git formulas deploy"
This commit is contained in:
commit
9ac8418eb5
|
@ -0,0 +1,319 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
#
|
||||
# ENVIRONMENT
|
||||
#
|
||||
|
||||
OS_DISTRIBUTION=${OS_DISTRIBUTION:-ubuntu}
|
||||
OS_NETWORKING=${OS_NETWORKING:-opencontrail}
|
||||
OS_VERSION=${OS_VERSION:-mitaka}
|
||||
OS_DEPLOYMENT=${OS_DEPLOYMENT:-single}
|
||||
OS_SYSTEM="${OS_VERSION}_${OS_DISTRIBUTION}_${OS_NETWORKING}_${OS_DEPLOYMENT}"
|
||||
|
||||
SALT_SOURCE=${SALT_SOURCE:-pkg}
|
||||
SALT_VERSION=${SALT_VERSION:-latest}
|
||||
|
||||
FORMULA_SOURCE=${FORMULA_SOURCE:-git}
|
||||
FORMULA_PATH=${FORMULA_PATH:-/usr/share/salt-formulas}
|
||||
FORMULA_BRANCH=${FORMULA_BRANCH:-master}
|
||||
FORMULA_REPOSITORY=${FORMULA_REPOSITORY:-deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ trusty tcp-salt}
|
||||
FORMULA_GPG=${FORMULA_GPG:-http://apt.tcpcloud.eu/public.gpg}
|
||||
|
||||
if [ "$FORMULA_SOURCE" == "git" ]; then
|
||||
SALT_ENV="dev"
|
||||
elif [ "$FORMULA_SOURCE" == "pkg" ]; then
|
||||
SALT_ENV="prd"
|
||||
fi
|
||||
|
||||
RECLASS_ADDRESS=${RECLASS_ADDRESS:-https://github.com/tcpcloud/openstack-salt-model.git}
|
||||
RECLASS_BRANCH=${RECLASS_BRANCH:-master}
|
||||
RECLASS_SYSTEM=${RECLASS_SYSTEM:-$OS_SYSTEM}
|
||||
|
||||
CONFIG_HOSTNAME=${CONFIG_HOSTNAME:-config}
|
||||
CONFIG_DOMAIN=${CONFIG_DOMAIN:-openstack.local}
|
||||
CONFIG_HOST=${CONFIG_HOSTNAME}.${CONFIG_DOMAIN}
|
||||
CONFIG_ADDRESS=${CONFIG_ADDRESS:-10.10.10.200}
|
||||
|
||||
MINION_MASTER=${MINION_MASTER:-$CONFIG_ADDRESS}
|
||||
MINION_HOSTNAME=${MINION_HOSTNAME:-minion}
|
||||
MINION_ID=${MINION_HOSTNAME}.${CONFIG_DOMAIN}
|
||||
|
||||
install_salt_master_pkg()
|
||||
{
|
||||
echo -e "\nPreparing base OS repository ...\n"
|
||||
|
||||
echo -e "deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ trusty main security extra tcp" > /etc/apt/sources.list
|
||||
wget -O - http://apt.tcpcloud.eu/public.gpg | apt-key add -
|
||||
|
||||
apt-get clean
|
||||
apt-get update
|
||||
|
||||
echo -e "\nInstalling salt master ...\n"
|
||||
|
||||
apt-get install reclass git -y
|
||||
|
||||
if [ "$SALT_VERSION" == "latest" ]; then
|
||||
apt-get install -y salt-common salt-master salt-minion
|
||||
else
|
||||
apt-get install -y --force-yes salt-common=$SALT_VERSION salt-master=$SALT_VERSION salt-minion=$SALT_VERSION
|
||||
fi
|
||||
|
||||
configure_salt_master
|
||||
|
||||
install_salt_minion_pkg "master"
|
||||
|
||||
echo -e "\nRestarting services ...\n"
|
||||
service salt-master restart
|
||||
[ -f /etc/salt/pki/minion/minion_master.pub ] && rm -f /etc/salt/pki/minion/minion_master.pub
|
||||
service salt-minion restart
|
||||
salt-call pillar.data > /dev/null 2>&1
|
||||
}
|
||||
|
||||
install_salt_master_pip()
|
||||
{
|
||||
echo -e "\nPreparing base OS repository ...\n"
|
||||
|
||||
echo -e "deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ trusty main security extra tcp" > /etc/apt/sources.list
|
||||
wget -O - http://apt.tcpcloud.eu/public.gpg | apt-key add -
|
||||
|
||||
apt-get clean
|
||||
apt-get update
|
||||
|
||||
echo -e "\nInstalling salt master ...\n"
|
||||
|
||||
if [ -x "`which invoke-rc.d 2>/dev/null`" -a -x "/etc/init.d/salt-minion" ] ; then
|
||||
apt-get purge -y salt-minion salt-common && apt-get autoremove -y
|
||||
fi
|
||||
|
||||
apt-get install -y python-pip python-dev zlib1g-dev reclass git
|
||||
|
||||
if [ "$SALT_VERSION" == "latest" ]; then
|
||||
pip install salt
|
||||
else
|
||||
pip install salt==$SALT_VERSION
|
||||
fi
|
||||
|
||||
wget -O /etc/init.d/salt-master https://anonscm.debian.org/cgit/pkg-salt/salt.git/plain/debian/salt-master.init && chmod 755 /etc/init.d/salt-master
|
||||
ln -s /usr/local/bin/salt-master /usr/bin/salt-master
|
||||
|
||||
configure_salt_master
|
||||
|
||||
install_salt_minion_pkg "master"
|
||||
|
||||
echo -e "\nRestarting services ...\n"
|
||||
service salt-master restart
|
||||
[ -f /etc/salt/pki/minion/minion_master.pub ] && rm -f /etc/salt/pki/minion/minion_master.pub
|
||||
service salt-minion restart
|
||||
salt-call pillar.data > /dev/null 2>&1
|
||||
}
|
||||
|
||||
configure_salt_master()
|
||||
{
|
||||
|
||||
[ ! -d /etc/salt/master.d ] && mkdir -p /etc/salt/master.d
|
||||
|
||||
cat << 'EOF' > /etc/salt/master.d/master.conf
|
||||
file_roots:
|
||||
base:
|
||||
- /usr/share/salt-formulas/env
|
||||
pillar_opts: False
|
||||
open_mode: True
|
||||
reclass: &reclass
|
||||
storage_type: yaml_fs
|
||||
inventory_base_uri: /srv/salt/reclass
|
||||
ext_pillar:
|
||||
- reclass: *reclass
|
||||
master_tops:
|
||||
reclass: *reclass
|
||||
EOF
|
||||
|
||||
echo "Configuring reclass ..."
|
||||
|
||||
[ ! -d /etc/reclass ] && mkdir /etc/reclass
|
||||
cat << 'EOF' > /etc/reclass/reclass-config.yml
|
||||
storage_type: yaml_fs
|
||||
pretty_print: True
|
||||
output: yaml
|
||||
inventory_base_uri: /srv/salt/reclass
|
||||
EOF
|
||||
|
||||
git clone ${RECLASS_ADDRESS} /srv/salt/reclass -b ${RECLASS_BRANCH}
|
||||
|
||||
if [ ! -f "/srv/salt/reclass/nodes/${CONFIG_HOST}.yml" ]; then
|
||||
|
||||
cat << EOF > /srv/salt/reclass/nodes/${CONFIG_HOST}.yml
|
||||
classes:
|
||||
- service.git.client
|
||||
- system.linux.system.single
|
||||
- system.openssh.client.workshop
|
||||
- system.salt.master.single
|
||||
- system.salt.master.formula.$FORMULA_SOURCE
|
||||
- system.reclass.storage.salt
|
||||
- system.reclass.storage.system.$RECLASS_SYSTEM
|
||||
parameters:
|
||||
_param:
|
||||
reclass_data_repository: "$RECLASS_ADDRESS"
|
||||
reclass_data_revision: $RECLASS_BRANCH
|
||||
salt_formula_branch: $FORMULA_BRANCH
|
||||
reclass_config_master: $CONFIG_ADDRESS
|
||||
single_address: $CONFIG_ADDRESS
|
||||
salt_master_host: 127.0.0.1
|
||||
salt_master_base_environment: $SALT_ENV
|
||||
linux:
|
||||
system:
|
||||
name: $CONFIG_HOSTNAME
|
||||
domain: $CONFIG_DOMAIN
|
||||
EOF
|
||||
|
||||
if [ "$SALT_VERSION" == "latest" ]; then
|
||||
|
||||
cat << EOF >> /srv/salt/reclass/nodes/${CONFIG_HOST}.yml
|
||||
salt:
|
||||
master:
|
||||
accept_policy: open_mode
|
||||
source:
|
||||
engine: $SALT_SOURCE
|
||||
minion:
|
||||
source:
|
||||
engine: $SALT_SOURCE
|
||||
EOF
|
||||
|
||||
else
|
||||
|
||||
cat << EOF >> /srv/salt/reclass/nodes/${CONFIG_HOST}.yml
|
||||
salt:
|
||||
master:
|
||||
accept_policy: open_mode
|
||||
source:
|
||||
engine: $SALT_SOURCE
|
||||
version: $SALT_VERSION
|
||||
minion:
|
||||
source:
|
||||
engine: $SALT_SOURCE
|
||||
version: $SALT_VERSION
|
||||
EOF
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
service salt-master restart
|
||||
}
|
||||
|
||||
install_salt_minion_pkg()
|
||||
{
|
||||
echo -e "\nInstalling salt minion ...\n"
|
||||
|
||||
if [ "$SALT_VERSION" == "latest" ]; then
|
||||
apt-get install -y salt-common salt-minion
|
||||
else
|
||||
apt-get install -y --force-yes salt-common=$SALT_VERSION salt-minion=$SALT_VERSION
|
||||
fi
|
||||
|
||||
if [ "$SALT_VERSION" == "latest" ]; then
|
||||
apt-get install -y salt-common salt-minion
|
||||
else
|
||||
apt-get install -y --force-yes salt-common=$SALT_VERSION salt-minion=$SALT_VERSION
|
||||
fi
|
||||
|
||||
[ ! -d /etc/salt/minion.d ] && mkdir -p /etc/salt/minion.d
|
||||
echo -e "master: 127.0.0.1\nid: $CONFIG_HOST" > /etc/salt/minion.d/minion.conf
|
||||
|
||||
service salt-minion restart
|
||||
}
|
||||
|
||||
install_salt_minion_pip()
|
||||
{
|
||||
echo -e "\nInstalling salt minion ...\n"
|
||||
|
||||
[ ! -d /etc/salt/minion.d ] && mkdir -p /etc/salt/minion.d
|
||||
echo -e "master: 127.0.0.1\nid: $CONFIG_HOST" > /etc/salt/minion.d/minion.conf
|
||||
|
||||
wget -O /etc/init.d/salt-minion https://anonscm.debian.org/cgit/pkg-salt/salt.git/plain/debian/salt-minion.init && chmod 755 /etc/init.d/salt-minion
|
||||
ln -s /usr/local/bin/salt-minion /usr/bin/salt-minion
|
||||
|
||||
service salt-minion restart
|
||||
}
|
||||
|
||||
install_salt_formula_pkg()
|
||||
{
|
||||
echo "Configuring necessary formulas ..."
|
||||
which wget > /dev/null || (apt-get update; apt-get install -y wget)
|
||||
|
||||
echo "${FORMULA_REPOSITORY}" > /etc/apt/sources.list.d/salt-formulas.list
|
||||
wget -O - "${FORMULA_GPG}" | apt-key add -
|
||||
|
||||
apt-get clean
|
||||
apt-get update
|
||||
|
||||
[ ! -d /srv/salt/reclass/classes/service ] && mkdir -p /srv/salt/reclass/classes/service
|
||||
|
||||
declare -a formula_services=("linux" "reclass" "salt" "openssh" "ntp" "git" "nginx" "collectd" "sensu" "heka" "sphinx")
|
||||
|
||||
for formula_service in "${formula_services[@]}"; do
|
||||
echo -e "\nConfiguring salt formula ${formula_service} ...\n"
|
||||
[ ! -d "${FORMULA_PATH}/env/${formula_service}" ] && \
|
||||
apt-get install -y salt-formula-${formula_service}
|
||||
[ ! -L "/srv/salt/reclass/classes/service/${formula_service}" ] && \
|
||||
ln -s ${FORMULA_PATH}/reclass/service/${formula_service} /srv/salt/reclass/classes/service/${formula_service}
|
||||
done
|
||||
|
||||
[ ! -d /srv/salt/env ] && mkdir -p /srv/salt/env
|
||||
[ ! -L /srv/salt/env/prd ] && ln -s ${FORMULA_PATH}/env /srv/salt/env/prd
|
||||
}
|
||||
|
||||
install_salt_formula_git()
|
||||
{
|
||||
echo "Configuring necessary formulas ..."
|
||||
|
||||
[ ! -d /srv/salt/reclass/classes/service ] && mkdir -p /srv/salt/reclass/classes/service
|
||||
|
||||
declare -a formula_services=("linux" "reclass" "salt" "openssh" "ntp" "git" "nginx" "collectd" "sensu" "heka" "sphinx")
|
||||
|
||||
for formula_service in "${formula_services[@]}"; do
|
||||
echo -e "\nConfiguring salt formula ${formula_service} ...\n"
|
||||
[ ! -d "${FORMULA_PATH}/env/_formulas/${formula_service}" ] && \
|
||||
git clone https://github.com/tcpcloud/salt-formula-${formula_service}.git ${FORMULA_PATH}/env/_formulas/${formula_service} -b ${FORMULA_BRANCH}
|
||||
[ ! -L "/usr/share/salt-formulas/env/${formula_service}" ] && \
|
||||
ln -s ${FORMULA_PATH}/env/_formulas/${formula_service}/${formula_service} /usr/share/salt-formulas/env/${formula_service}
|
||||
[ ! -L "/srv/salt/reclass/classes/service/${formula_service}" ] && \
|
||||
ln -s ${FORMULA_PATH}/env/_formulas/${formula_service}/metadata/service /srv/salt/reclass/classes/service/${formula_service}
|
||||
done
|
||||
|
||||
[ ! -d /srv/salt/env ] && mkdir -p /srv/salt/env
|
||||
[ ! -L /srv/salt/env/dev ] && ln -s /usr/share/salt-formulas/env /srv/salt/env/dev
|
||||
}
|
||||
|
||||
run_salt_states()
|
||||
{
|
||||
echo -e "\nReclass metadata ...\n"
|
||||
reclass --nodeinfo ${CONFIG_HOST}
|
||||
|
||||
echo -e "\nSalt grains metadata ...\n"
|
||||
salt-call grains.items --no-color
|
||||
|
||||
echo -e "\nSalt pillar metadata ...\n"
|
||||
salt-call pillar.data --no-color
|
||||
|
||||
echo -e "\nRunning necessary base states ...\n"
|
||||
salt-call --retcode-passthrough state.sls linux,salt.minion,salt --no-color
|
||||
|
||||
echo -e "\nRunning complete state ...\n"
|
||||
salt-call --retcode-passthrough state.highstate --no-color
|
||||
}
|
||||
|
||||
if [ "$SALT_SOURCE" == "pkg" ]; then
|
||||
install_salt_master_pkg
|
||||
install_salt_minion_pkg
|
||||
elif [ "$SALT_SOURCE" == "pip" ]; then
|
||||
install_salt_master_pip
|
||||
install_salt_minion_pip
|
||||
fi
|
||||
|
||||
if [ "$FORMULA_SOURCE" == "pkg" ]; then
|
||||
install_salt_formula_pkg
|
||||
elif [ "$FORMULA_SOURCE" == "git" ]; then
|
||||
install_salt_formula_git
|
||||
fi
|
||||
|
||||
run_salt_states
|
|
@ -0,0 +1,111 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
#
|
||||
# ENVIRONMENT
|
||||
#
|
||||
|
||||
OS_DISTRIBUTION=${OS_DISTRIBUTION:-ubuntu}
|
||||
OS_NETWORKING=${OS_NETWORKING:-opencontrail}
|
||||
OS_DEPLOYMENT=${OS_DEPLOYMENT:-single}
|
||||
OS_SYSTEM="${OS_DISTRIBUTION}_${OS_NETWORKING}_${OS_DEPLOYMENT}"
|
||||
|
||||
SALT_SOURCE=${SALT_SOURCE:-pkg}
|
||||
SALT_VERSION=${SALT_VERSION:-latest}
|
||||
|
||||
FORMULA_SOURCE=${FORMULA_SOURCE:-git}
|
||||
FORMULA_PATH=${FORMULA_PATH:-/usr/share/salt-formulas}
|
||||
FORMULA_BRANCH=${FORMULA_BRANCH:-master}
|
||||
FORMULA_REPOSITORY=${FORMULA_REPOSITORY:-deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ trusty tcp-salt}
|
||||
FORMULA_GPG=${FORMULA_GPG:-http://apt.tcpcloud.eu/public.gpg}
|
||||
|
||||
if [ "$FORMULA_SOURCE" == "git" ]; then
|
||||
SALT_ENV="dev"
|
||||
elif [ "$FORMULA_SOURCE" == "pkg" ]; then
|
||||
SALT_ENV="prd"
|
||||
fi
|
||||
|
||||
RECLASS_ADDRESS=${RECLASS_ADDRESS:-https://github.com/tcpcloud/openstack-salt-model.git}
|
||||
RECLASS_BRANCH=${RECLASS_BRANCH:-master}
|
||||
RECLASS_SYSTEM=${RECLASS_SYSTEM:-$OS_SYSTEM}
|
||||
|
||||
CONFIG_HOSTNAME=${CONFIG_HOSTNAME:-config}
|
||||
CONFIG_DOMAIN=${CONFIG_DOMAIN:-openstack.local}
|
||||
CONFIG_HOST=${CONFIG_HOSTNAME}.${CONFIG_DOMAIN}
|
||||
CONFIG_ADDRESS=${CONFIG_ADDRESS:-10.10.10.200}
|
||||
|
||||
MINION_MASTER=${MINION_MASTER:-$CONFIG_ADDRESS}
|
||||
MINION_HOSTNAME=${MINION_HOSTNAME:-minion}
|
||||
MINION_ID=${MINION_HOSTNAME}.${CONFIG_DOMAIN}
|
||||
|
||||
install_salt_minion_pkg()
|
||||
{
|
||||
echo -e "\nInstalling salt minion ...\n"
|
||||
|
||||
if [ "$SALT_VERSION" == "latest" ]; then
|
||||
apt-get install -y salt-common salt-minion
|
||||
else
|
||||
apt-get install -y --force-yes salt-common=$SALT_VERSION salt-minion=$SALT_VERSION
|
||||
fi
|
||||
|
||||
echo -e "\nPreparing base OS repository ...\n"
|
||||
|
||||
echo -e "deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ trusty main security extra tcp" > /etc/apt/sources.list
|
||||
wget -O - http://apt.tcpcloud.eu/public.gpg | apt-key add -
|
||||
|
||||
apt-get clean
|
||||
apt-get update
|
||||
|
||||
if [ "$SALT_VERSION" == "latest" ]; then
|
||||
apt-get install -y salt-common salt-minion
|
||||
else
|
||||
apt-get install -y --force-yes salt-common=$SALT_VERSION salt-minion=$SALT_VERSION
|
||||
fi
|
||||
|
||||
echo -e "\nInstalling salt minion ...\n"
|
||||
|
||||
[ ! -d /etc/salt/minion.d ] && mkdir -p /etc/salt/minion.d
|
||||
echo -e "master: $MINION_MASTER\nid: $MINION_ID" > /etc/salt/minion.d/minion.conf
|
||||
|
||||
service salt-minion restart
|
||||
}
|
||||
|
||||
install_salt_minion_pip()
|
||||
{
|
||||
echo -e "\nInstalling salt minion ...\n"
|
||||
|
||||
echo -e "\nPreparing base OS repository ...\n"
|
||||
|
||||
echo -e "deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ trusty main security extra tcp" > /etc/apt/sources.list
|
||||
wget -O - http://apt.tcpcloud.eu/public.gpg | apt-key add -
|
||||
|
||||
apt-get clean
|
||||
apt-get update
|
||||
|
||||
echo -e "\nInstalling salt minion ...\n"
|
||||
|
||||
if [ -x "`which invoke-rc.d 2>/dev/null`" -a -x "/etc/init.d/salt-minion" ] ; then
|
||||
apt-get purge -y salt-minion salt-common && apt-get autoremove -y
|
||||
fi
|
||||
|
||||
apt-get install -y python-pip python-dev zlib1g-dev reclass git
|
||||
|
||||
if [ "$SALT_VERSION" == "latest" ]; then
|
||||
pip install salt
|
||||
else
|
||||
pip install salt==$SALT_VERSION
|
||||
fi
|
||||
|
||||
[ ! -d /etc/salt/minion.d ] && mkdir -p /etc/salt/minion.d
|
||||
echo -e "master: $MINION_MASTER\nid: $MINION_ID" > /etc/salt/minion.d/minion.conf
|
||||
|
||||
wget -O /etc/init.d/salt-minion https://anonscm.debian.org/cgit/pkg-salt/salt.git/plain/debian/salt-minion.init && chmod 755 /etc/init.d/salt-minion
|
||||
ln -s /usr/local/bin/salt-minion /usr/bin/salt-minion
|
||||
|
||||
service salt-minion restart
|
||||
}
|
||||
|
||||
if [ "$SALT_SOURCE" == "pkg" ]; then
|
||||
install_salt_minion_pkg
|
||||
elif [ "$SALT_SOURCE" == "pip" ]; then
|
||||
install_salt_minion_pip
|
||||
fi
|
|
@ -1,44 +0,0 @@
|
|||
#!/bin/bash -x
|
||||
|
||||
CONFIG_HOST=${CONFIG_HOST:-config.openstack.local}
|
||||
FORMULA_PATH=${FORMULA_PATH:-/usr/share/salt-formulas/env/_formulas}
|
||||
FORMULA_BRANCH=${FORMULA_BRANCH:-master}
|
||||
RECLASS_ADDRESS=${RECLASS_ADDRESS:-https://github.com/tcpcloud/workshop-salt-model.git}
|
||||
RECLASS_BRANCH=${RECLASS_BRANCH:-master}
|
||||
|
||||
declare -a FORMULA_SERVICES=("linux" "reclass" "salt" "openssh" "ntp" "git" "nginx" "collectd" "sensu" "heka" "sphinx")
|
||||
|
||||
[ ! -d /srv/salt/env ] && mkdir -p /srv/salt/env
|
||||
[ ! -e "/srv/salt/env/dev" ] && ln -s /usr/share/salt-formulas/env /srv/salt/env/dev
|
||||
|
||||
for FORMULA_SERVICE in "${FORMULA_SERVICES[@]}"
|
||||
do
|
||||
printf "\nConfiguring salt formula ${FORMULA_SERVICE} ...\n"
|
||||
[ ! -d "${FORMULA_PATH}/${FORMULA_SERVICE}" ] && \
|
||||
git clone "https://github.com/tcpcloud/salt-formula-${FORMULA_SERVICE}.git" "${FORMULA_PATH}/${FORMULA_SERVICE}" -b ${FORMULA_BRANCH}
|
||||
[ ! -e "/usr/share/salt-formulas/env/${FORMULA_SERVICE}" ] && \
|
||||
ln -s "${FORMULA_PATH}/${FORMULA_SERVICE}/${FORMULA_SERVICE}" "/usr/share/salt-formulas/env/${FORMULA_SERVICE}"
|
||||
[ ! -e "/srv/salt/reclass/classes/service/${FORMULA_SERVICE}" ] && \
|
||||
ln -s "${FORMULA_PATH}/${FORMULA_SERVICE}/metadata/service" "/srv/salt/reclass/classes/service/${FORMULA_SERVICE}"
|
||||
done
|
||||
|
||||
printf "\nRestarting services ...\n"
|
||||
service salt-master restart
|
||||
service salt-minion restart
|
||||
salt-call pillar.data --no-color
|
||||
salt-key -a ${CONFIG_HOST} -y
|
||||
|
||||
printf "\nReclass metadata ...\n"
|
||||
reclass --nodeinfo ${CONFIG_HOST}
|
||||
|
||||
printf "\nSalt grains metadata ...\n"
|
||||
salt-call grains.items --no-color
|
||||
|
||||
printf "\nSalt pillar metadata ...\n"
|
||||
salt-call pillar.data --no-color
|
||||
|
||||
printf "\nRunning base states ...\n"
|
||||
salt-call state.sls linux,openssh,salt.minion,salt.master.service --no-color
|
||||
|
||||
printf "\nRunning complete state ...\n"
|
||||
salt-call state.highstate --no-color
|
|
@ -1,73 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
CONFIG_HOST=${CONFIG_HOST:-config.openstack.local}
|
||||
|
||||
RECLASS_ADDRESS=${RECLASS_ADDRESS:-https://github.com/tcpcloud/workshop-salt-model.git}
|
||||
|
||||
echo "Preparing base OS"
|
||||
which wget > /dev/null || (apt-get update; apt-get install -y wget)
|
||||
|
||||
echo "deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ trusty main security extra tcp tcp-salt" > /etc/apt/sources.list
|
||||
wget -O - http://apt.tcpcloud.eu/public.gpg | apt-key add -
|
||||
|
||||
apt-get clean
|
||||
apt-get update
|
||||
|
||||
echo "Configuring salt master ..."
|
||||
apt-get install -y salt-formula-linux salt-formula-reclass salt-formula-salt
|
||||
apt-get install -y salt-formula-openssh salt-formula-ntp salt-formula-git
|
||||
apt-get install -y salt-formula-collectd salt-formula-sensu salt-formula-heka
|
||||
|
||||
cat << 'EOF' > /etc/salt/master.d/master.conf
|
||||
file_roots:
|
||||
base:
|
||||
- /usr/share/salt-formulas/env
|
||||
pillar_opts: False
|
||||
open_mode: True
|
||||
reclass: &reclass
|
||||
storage_type: yaml_fs
|
||||
inventory_base_uri: /srv/salt/reclass
|
||||
ext_pillar:
|
||||
- reclass: *reclass
|
||||
master_tops:
|
||||
reclass: *reclass
|
||||
EOF
|
||||
|
||||
echo "Configuring reclass ..."
|
||||
git clone $RECLASS_ADDRESS /srv/salt/reclass -b master
|
||||
mkdir -p /srv/salt/reclass/classes/service
|
||||
|
||||
for i in /usr/share/salt-formulas/reclass/service/*; do
|
||||
ln -s $i /srv/salt/reclass/classes/service/
|
||||
done
|
||||
|
||||
[ ! -d /etc/reclass ] && mkdir /etc/reclass
|
||||
cat << 'EOF' > /etc/reclass/reclass-config.yml
|
||||
storage_type: yaml_fs
|
||||
pretty_print: True
|
||||
output: yaml
|
||||
inventory_base_uri: /srv/salt/reclass
|
||||
EOF
|
||||
|
||||
echo "Configuring salt minion ..."
|
||||
apt-get install -y salt-minion
|
||||
[ ! -d /etc/salt/minion.d ] && mkdir -p /etc/salt/minion.d
|
||||
cat << EOF > /etc/salt/minion.d/minion.conf
|
||||
id: $CONFIG_HOST
|
||||
master: localhost
|
||||
EOF
|
||||
|
||||
echo "Restarting services ..."
|
||||
service salt-master restart
|
||||
rm -f /etc/salt/pki/minion/minion_master.pub
|
||||
service salt-minion restart
|
||||
|
||||
echo "Showing system info and metadata ..."
|
||||
salt-call grains.items
|
||||
salt-call pillar.data
|
||||
reclass -n $CONFIG_HOST
|
||||
|
||||
echo "Running complete state ..."
|
||||
salt-call state.sls linux,openssh,salt.minion
|
||||
salt-call state.sls salt.master
|
||||
salt-call state.highstate
|
|
@ -1,48 +0,0 @@
|
|||
#!/bin/bash -x
|
||||
|
||||
printf "\nPreparing base OS repository ...\n"
|
||||
which wget > /dev/null || (apt-get update; apt-get install -y wget)
|
||||
|
||||
printf "deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ trusty main security extra tcp tcp-salt" > /etc/apt/sources.list
|
||||
wget -O - http://apt.tcpcloud.eu/public.gpg | apt-key add -
|
||||
|
||||
apt-get clean
|
||||
apt-get update
|
||||
|
||||
printf "\nInstalling salt master ...\n"
|
||||
apt-get install git salt-master python-reclass -y
|
||||
|
||||
cat << 'EOF' > /etc/salt/master.d/master.conf
|
||||
file_roots:
|
||||
base:
|
||||
- /usr/share/salt-formulas/env
|
||||
pillar_opts: False
|
||||
open_mode: True
|
||||
reclass: &reclass
|
||||
storage_type: yaml_fs
|
||||
inventory_base_uri: /srv/salt/reclass
|
||||
ext_pillar:
|
||||
- reclass: *reclass
|
||||
master_tops:
|
||||
reclass: *reclass
|
||||
EOF
|
||||
|
||||
echo "Configuring reclass ..."
|
||||
git clone $RECLASS_ADDRESS /srv/salt/reclass -b master
|
||||
mkdir -p /srv/salt/reclass/classes/service
|
||||
|
||||
for i in /usr/share/salt-formulas/reclass/service/*; do
|
||||
ln -s $i /srv/salt/reclass/classes/service/
|
||||
done
|
||||
|
||||
[ ! -d /etc/reclass ] && mkdir /etc/reclass
|
||||
cat << 'EOF' > /etc/reclass/reclass-config.yml
|
||||
storage_type: yaml_fs
|
||||
pretty_print: True
|
||||
output: yaml
|
||||
inventory_base_uri: /srv/salt/reclass
|
||||
EOF
|
||||
|
||||
git clone ${RECLASS_ADDRESS} /srv/salt/reclass -b ${RECLASS_BRANCH}
|
||||
mkdir -p /srv/salt/reclass/classes/service
|
||||
mkdir -p /usr/share/salt-formulas/reclass/service
|
|
@ -3,15 +3,18 @@
|
|||
OpenStack-Salt Vagrant deployment
|
||||
=================================
|
||||
|
||||
All-in-one (AIO) deployments are a great way to setup an OpenStack-Salt cloud for:
|
||||
All-in-one (AIO) deployments are a great way to setup an OpenStack-Salt cloud
|
||||
for:
|
||||
|
||||
* a service development environment
|
||||
* an overview of how all of the OpenStack services and roles play together
|
||||
* a simple lab deployment for testing
|
||||
|
||||
Although AIO builds aren't suitable for large production deployments, they're great for small proof-of-concept deployments.
|
||||
Although AIO builds aren't suitable for large production deployments, they're
|
||||
great for small proof-of-concept deployments.
|
||||
|
||||
It's strongly recommended to have hardware that meets the following requirements before starting an AIO deployment:
|
||||
It's strongly recommended to have hardware that meets the following
|
||||
requirements before starting an AIO deployment:
|
||||
|
||||
* CPU with `hardware-assisted virtualization`_ support
|
||||
* At least 80GB disk space
|
||||
|
@ -20,9 +23,15 @@ It's strongly recommended to have hardware that meets the following requirements
|
|||
Vagrant setup
|
||||
-------------
|
||||
|
||||
Installing Vagrant is extremely easy for many operating systems. Go to the `Vagrant downloads page`_ and get the appropriate installer or package for your platform. Install the package using standard procedures for your operating system.
|
||||
Installing Vagrant is extremely easy for many operating systems. Go to the
|
||||
`Vagrant downloads page`_ and get the appropriate installer or package for
|
||||
your platform. Install the package using standard procedures for your
|
||||
operating system.
|
||||
|
||||
The installer will automatically add vagrant to your system path so that it is available in shell. Try logging out and logging back in to your system (this is particularly necessary sometimes for Windows) to get the updated system path up and running.
|
||||
The installer will automatically add vagrant to your system path so that it is
|
||||
available in shell. Try logging out and logging back in to your system (this
|
||||
is particularly necessary sometimes for Windows) to get the updated system
|
||||
path up and running.
|
||||
|
||||
Add the generic ubuntu1404 image for virtualbox virtualization.
|
||||
|
||||
|
@ -59,22 +68,25 @@ The environment consists of three nodes.
|
|||
- 10.10.10.202
|
||||
|
||||
|
||||
|
||||
Minion configuration files
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Prepare basic configuration files for each node deployed.
|
||||
Download openstack-salt
|
||||
|
||||
Set ``/srv/vagrant-openstack/minions/config.conf`` to following:
|
||||
Look at configuration files for each node deployed.
|
||||
|
||||
``scripts/minions/config.conf`` configuration:
|
||||
|
||||
.. literalinclude:: /_static/scripts/minions/config.conf
|
||||
:language: yaml
|
||||
|
||||
Set ``/srv/vagrant-openstack/minions/control.conf`` to following:
|
||||
``scripts/minions/control.conf`` configuration:
|
||||
|
||||
.. literalinclude:: /_static/scripts/minions/control.conf
|
||||
:language: yaml
|
||||
|
||||
Set ``/srv/vagrant-openstack/minions/compute.conf`` to following content:
|
||||
``scripts/minions/compute.conf`` configuration:
|
||||
|
||||
.. literalinclude:: /_static/scripts/minions/compute.conf
|
||||
:language: yaml
|
||||
|
@ -83,20 +95,32 @@ Set ``/srv/vagrant-openstack/minions/compute.conf`` to following content:
|
|||
Vagrant configuration file
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The main vagrant configuration for OpenStack-Salt deployment is located at ``/srv/vagrant-openstack/Vagrantfile``.
|
||||
The main vagrant configuration for OpenStack-Salt deployment is located at
|
||||
``scripts/Vagrantfile``.
|
||||
|
||||
.. literalinclude:: /_static/scripts/Vagrantfile
|
||||
:language: ruby
|
||||
|
||||
|
||||
Salt master bootstrap file
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Salt master bootstrap from package
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The salt-master bootstrap is located at ``/srv/vagrant-openstack/bootstrap-salt-master.sh`` and it needs to be placed at the vagrant-openstack folder to be accessible from the virtual machine.
|
||||
The salt-master bootstrap is located at ``scripts/bootstrap/salt-
|
||||
master-pkg.sh`` and is accessible from the virtual machine at ``/vagrant
|
||||
/bootstrap/salt-master-pkg.sh``.
|
||||
|
||||
.. literalinclude:: /_static/scripts/bootstrap/salt-master-pkg.sh
|
||||
:language: bash
|
||||
|
||||
Salt master pip based bootstrap
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The salt-master bootstrap is located at ``scripts/bootstrap/salt- master-
|
||||
pip.sh`` and is accessible from the virtual machine at ``/vagrant/bootstrap
|
||||
/salt-master-pip.sh``.
|
||||
|
||||
.. literalinclude:: /_static/scripts/bootstrap/salt-master-pip.sh
|
||||
:language: bash
|
||||
|
||||
Launching the Vagrant nodes
|
||||
---------------------------
|
||||
|
@ -114,45 +138,60 @@ Check the status of the deployment environment.
|
|||
openstack_control not created (virtualbox)
|
||||
openstack_compute not created (virtualbox)
|
||||
|
||||
Setup OpenStack-Salt config node, launch it and connect to it using following commands, it cannot be provisioned by vagrant salt, as the salt master is not configured yet.
|
||||
Setup OpenStack-Salt config node, launch it and connect to it using following
|
||||
commands, it cannot be provisioned by vagrant salt, as the salt master is not
|
||||
configured yet.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ vagrant up openstack_config
|
||||
$ vagrant ssh openstack_config
|
||||
|
||||
Bootstrap the salt master service on the config node, it can be configured with following parameters:
|
||||
|
||||
Bootstrap Salt master
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Bootstrap the salt master service on the config node, it can be configured
|
||||
with following parameters:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ cd /vagrant
|
||||
|
||||
$ export RECLASS_ADDRESS=https://github.com/tcpcloud/workshop-salt-model.git
|
||||
$ export RECLASS_ADDRESS=https://github.com/tcpcloud/openstack-salt-model.git
|
||||
$ export CONFIG_HOST=config.openstack.local
|
||||
|
||||
# to deploy salt-master from packages, run:
|
||||
To deploy salt-master from packages, run on config node:
|
||||
|
||||
$ ./bootstrap-salt-master-pkg.sh
|
||||
.. code-block:: bash
|
||||
|
||||
# to deploy salt-master from git, run:
|
||||
$ /vagrant/bootstrap/salt-master-pkg.sh
|
||||
|
||||
$ ./bootstrap-salt-master-git.sh
|
||||
To deploy salt-master from pip, run on config node:
|
||||
|
||||
Now setup the OpenStack-Salt control node. Launch it and provision using following command:
|
||||
.. code-block:: bash
|
||||
|
||||
$ /vagrant/bootstrap/salt-master-pip.sh
|
||||
|
||||
Now setup the OpenStack-Salt control node. Launch it using following command:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ vagrant up openstack_control
|
||||
$ vagrant provision openstack_control
|
||||
|
||||
Now setup the OpenStack-Salt compute node. Launch it and provision using following command:
|
||||
Now setup the OpenStack-Salt compute node. Launch it using following command:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ vagrant up openstack_compute
|
||||
$ vagrant provision openstack_compute
|
||||
|
||||
The installation is now over, you should be able to access the user interface of cloud deployment at
|
||||
To orchestrate the services accross all nodes, run following command on config
|
||||
node:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ salt-run state.orchestrate orchestrate
|
||||
|
||||
The installation is now over, you should be able to access the user interface
|
||||
of cloud deployment at your control node.
|
||||
|
||||
.. _hardware-assisted virtualization: https://en.wikipedia.org/wiki/Hardware-assisted_virtualization
|
||||
.. _Vagrant downloads page: https://www.vagrantup.com/downloads.html
|
||||
|
|
Loading…
Reference in New Issue