Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2015.8] Update bootstrap script to latest stable release, v2015.07.17 #25508

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 88 additions & 36 deletions salt/cloud/deploy/bootstrap-salt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# CREATED: 10/15/2012 09:49:37 PM WEST
#======================================================================================================================
set -o nounset # Treat unset variables as an error
__ScriptVersion="2015.05.07"
__ScriptVersion="2015.07.17"
__ScriptName="bootstrap-salt.sh"

#======================================================================================================================
Expand Down Expand Up @@ -90,7 +90,7 @@ echoinfo() {

#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: echowarn
# DESCRIPTION: Echo warning information to stdout.
# DESCRIPTION: Echo warning informations to stdout.
#----------------------------------------------------------------------------------------------------------------------
echowarn() {
printf "${YC} * WARN${EC}: %s\n" "$@";
Expand Down Expand Up @@ -211,6 +211,7 @@ _LIBCLOUD_MIN_VERSION="0.14.0"
_PY_REQUESTS_MIN_VERSION="2.0"
_EXTRA_PACKAGES=""
_HTTP_PROXY=""
_DISABLE_SALT_CHECKS=$BS_FALSE
__SALT_GIT_CHECKOUT_DIR=${BS_SALT_GIT_CHECKOUT_DIR:-/tmp/git/salt}


Expand Down Expand Up @@ -277,14 +278,17 @@ usage() {
-L Install the Apache Libcloud package if possible(required for salt-cloud)
-p Extra-package to install while installing salt dependencies. One package
per -p flag. You're responsible for providing the proper package name.
-d Disable check_service functions. Setting this flag disables the
'install_<distro>_check_services' checks. You can also do this by
touching /tmp/disable_salt_checks on the target host. Defaults \${BS_FALSE}
-H Use the specified http proxy for the installation
-Z Enable external software source for newer ZeroMQ(Only available for RHEL/CentOS/Fedora based distributions)

EOT
} # ---------- end of function usage ----------


while getopts ":hvnDc:Gg:k:MSNXCPFUKIA:i:Lp:H:Z" opt
while getopts ":hvnDc:Gg:k:MSNXCPFUKIA:i:Lp:dH:Z" opt
do
case "${opt}" in

Expand Down Expand Up @@ -333,6 +337,7 @@ do
i ) _SALT_MINION_ID=$OPTARG ;;
L ) _INSTALL_CLOUD=$BS_TRUE ;;
p ) _EXTRA_PACKAGES="$_EXTRA_PACKAGES $OPTARG" ;;
d ) _DISABLE_SALT_CHECKS=$BS_TRUE ;;
H ) _HTTP_PROXY="$OPTARG" ;;
Z) _ENABLE_EXTERNAL_ZMQ_REPOS=$BS_TRUE ;;

Expand Down Expand Up @@ -467,6 +472,12 @@ if [ "${CALLER}x" = "${0}x" ]; then
CALLER="PIPED THROUGH"
fi

# Work around for 'Docker + salt-bootstrap failure' https://github.com/saltstack/salt-bootstrap/issues/394
if [ ${_DISABLE_SALT_CHECKS} -eq 0 ]; then
[ -f /tmp/disable_salt_checks ] && _DISABLE_SALT_CHECKS=$BS_TRUE && \
echowarn "Found file: /tmp/disable_salt_checks, setting \$_DISABLE_SALT_CHECKS=true"
fi

echoinfo "${CALLER} ${0} -- Version ${__ScriptVersion}"
#echowarn "Running the unstable version of ${__ScriptName}"

Expand Down Expand Up @@ -1147,7 +1158,7 @@ fi
if ([ "${DISTRO_NAME_L}" != "ubuntu" ] && [ "$ITYPE" = "daily" ]); then
echoerror "${DISTRO_NAME} does not have daily packages support"
exit 1
elif ([ "${DISTRO_NAME_L}" != "ubuntu" ] && [ "$STABLE_REV" != "latest" ]); then
elif ([ "${DISTRO_NAME_L}" != "ubuntu" ] && [ "$ITYPE" = "stable" ] && [ "$STABLE_REV" != "latest" ]); then
echoerror "${DISTRO_NAME} does not have major version pegged packages support"
exit 1
fi
Expand Down Expand Up @@ -1899,7 +1910,8 @@ install_ubuntu_daily() {

install_ubuntu_git() {
if [ -f "${__SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then
python setup.py install --install-layout=deb --salt-config-dir="$_SALT_ETC_DIR" || return 1
python setup.py install --install-layout=deb --salt-config-dir="$_SALT_ETC_DIR" || \
python setup.py --salt-config-dir="$_SALT_ETC_DIR" install --install-layout=deb || return 1
else
python setup.py install --install-layout=deb || return 1
fi
Expand All @@ -1915,7 +1927,7 @@ install_ubuntu_git_post() {
[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
[ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue

if [ -f /bin/systemctl ]; then
if [ -f /bin/systemctl ] && [ "$DISTRO_MAJOR_VERSION" -ge 15 ]; then
copyfile "${__SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-${fname}.service" "/lib/systemd/system/salt-${fname}.service"

# Skip salt-api since the service should be opt-in and not necessarily started on boot
Expand Down Expand Up @@ -1954,8 +1966,8 @@ install_ubuntu_git_post() {
install_ubuntu_restart_daemons() {
[ $_START_DAEMONS -eq $BS_FALSE ] && return

# Ensure upstart configs are loaded
if [ -f /bin/systemctl ]; then
# Ensure upstart configs / systemd units are loaded
if [ -f /bin/systemctl ] && [ "$DISTRO_MAJOR_VERSION" -ge 15 ]; then
systemctl daemon-reload
elif [ -f /sbin/initctl ]; then
/sbin/initctl reload-configuration
Expand All @@ -1970,7 +1982,7 @@ install_ubuntu_restart_daemons() {
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
[ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue

if [ -f /bin/systemctl ]; then
if [ -f /bin/systemctl ] && [ "$DISTRO_MAJOR_VERSION" -ge 15 ]; then
echodebug "There's systemd support while checking salt-$fname"
systemctl stop salt-$fname > /dev/null 2>&1
systemctl start salt-$fname.service
Expand Down Expand Up @@ -2015,7 +2027,7 @@ install_ubuntu_check_services() {
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
[ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue

if [ -f /bin/systemctl ]; then
if [ -f /bin/systemctl ] && [ "$DISTRO_MAJOR_VERSION" -ge 15 ]; then
__check_services_systemd salt-$fname || return 1
elif [ -f /sbin/initctl ] && [ -f /etc/init/salt-${fname}.conf ]; then
__check_services_upstart salt-$fname || return 1
Expand Down Expand Up @@ -2137,7 +2149,7 @@ _eof
# We NEED to install the unstable dpkg or mime-support WILL fail to install
__apt_get_install_noinput -t unstable dpkg liblzma5 python mime-support || return 1
__apt_get_install_noinput -t unstable libzmq3 libzmq3-dev || return 1
__apt_get_install_noinput build-essential python-dev python-pip || return 1
__apt_get_install_noinput build-essential python-dev python-pip python-setuptools || return 1

# Saltstack's Unstable Debian repository
if [ "$(grep -R 'debian.saltstack.com' /etc/apt)" = "" ]; then
Expand Down Expand Up @@ -2179,6 +2191,14 @@ _eof

__apt_get_install_noinput python-zmq || return 1

if [ "$_PIP_ALLOWED" -eq $BS_TRUE ]; then
# Building pyzmq from source to build it against libzmq3.
# Should override current installation
# Using easy_install instead of pip because at least on Debian 6,
# there's no default virtualenv active.
easy_install -U pyzmq || return 1
fi

if [ "${_EXTRA_PACKAGES}" != "" ]; then
echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}"
# shellcheck disable=SC2086
Expand Down Expand Up @@ -2210,7 +2230,7 @@ install_debian_7_deps() {

# Debian Backports
if [ "$(grep -R 'wheezy-backports' /etc/apt | grep -v "^#")" = "" ]; then
echo "deb http://http.debian.net/debian wheezy-backports main" >> \
echo "deb http://httpredir.debian.org/debian wheezy-backports main" >> \
/etc/apt/sources.list.d/backports.list
fi

Expand Down Expand Up @@ -2278,7 +2298,7 @@ install_debian_8_deps() {

# Debian Backports
if [ "$(grep -R 'jessie-backports' /etc/apt | grep -v "^#")" = "" ]; then
echo "deb http://http.debian.net/debian jessie-backports main" >> \
echo "deb http://httpredir.debian.org/debian jessie-backports main" >> \
/etc/apt/sources.list.d/backports.list
fi

Expand Down Expand Up @@ -2380,7 +2400,7 @@ install_debian_6_git_deps() {
install_debian_6_deps || return 1
if [ "$_PIP_ALLOWED" -eq $BS_TRUE ]; then
__PACKAGES="build-essential lsb-release python python-dev python-pkg-resources python-crypto"
__PACKAGES="${__PACKAGES} python-m2crypto python-yaml msgpack-python python-pip"
__PACKAGES="${__PACKAGES} python-m2crypto python-yaml msgpack-python python-pip python-setuptools"

if [ "$(which git)" = "" ]; then
__PACKAGES="${__PACKAGES} git"
Expand Down Expand Up @@ -2435,14 +2455,6 @@ __install_debian_stable() {
# shellcheck disable=SC2086
__apt_get_install_noinput ${__PACKAGES} || return 1

if [ "$_PIP_ALLOWED" -eq $BS_TRUE ]; then
# Building pyzmq from source to build it against libzmq3.
# Should override current installation
# Using easy_install instead of pip because at least on Debian 6,
# there's no default virtualenv active.
easy_install -U pyzmq || return 1
fi

return 0
}

Expand All @@ -2465,7 +2477,8 @@ install_debian_8_stable() {
install_debian_git() {

if [ -f "${__SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then
python setup.py install --install-layout=deb --salt-config-dir="$_SALT_ETC_DIR" || return 1
python setup.py install --install-layout=deb --salt-config-dir="$_SALT_ETC_DIR" || \
python setup.py --salt-config-dir="$_SALT_ETC_DIR" install --install-layout=deb || return 1
else
python setup.py install --install-layout=deb || return 1
fi
Expand Down Expand Up @@ -2509,6 +2522,8 @@ install_debian_git_post() {
elif [ ! -f /etc/init.d/salt-$fname ] || ([ -f /etc/init.d/salt-$fname ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ]); then
if [ -f "${__SALT_GIT_CHECKOUT_DIR}/debian/salt-$fname.init" ]; then
copyfile "${__SALT_GIT_CHECKOUT_DIR}/debian/salt-$fname.init" "/etc/init.d/salt-$fname"
else
__fetch_url "/etc/init.d/salt-$fname" "http://anonscm.debian.org/cgit/pkg-salt/salt.git/plain/debian/salt-${fname}.init"
fi
if [ ! -f "/etc/init.d/salt-$fname" ]; then
echowarn "The init script for salt-$fname was not found, skipping it..."
Expand Down Expand Up @@ -2665,7 +2680,8 @@ install_fedora_git_deps() {

install_fedora_git() {
if [ -f "${__SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then
python setup.py install --salt-config-dir="$_SALT_ETC_DIR" || return 1
python setup.py install --salt-config-dir="$_SALT_ETC_DIR" || \
python setup.py --salt-config-dir="$_SALT_ETC_DIR" install || return 1
else
python setup.py install || return 1
fi
Expand Down Expand Up @@ -2989,7 +3005,8 @@ install_centos_git() {
_PYEXE=python2
fi
if [ -f "${__SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then
$_PYEXE setup.py install --salt-config-dir="$_SALT_ETC_DIR" || return 1
$_PYEXE setup.py install --salt-config-dir="$_SALT_ETC_DIR" || \
$_PYEXE setup.py --salt-config-dir="$_SALT_ETC_DIR" install || return 1
else
$_PYEXE setup.py install || return 1
fi
Expand Down Expand Up @@ -3137,11 +3154,17 @@ install_centos_check_services() {
__test_rhel_optionals_packages() {
__install_epel_repository || return 1

# Make sure yum-utils is installed
yum list installed yum-utils > /dev/null 2>&1 || yum -y install yum-utils --enablerepo=${_EPEL_REPO} || return 1

if [ "$DISTRO_MAJOR_VERSION" -ge 7 ]; then
yum-config-manager --enable \*server-optional || return 1
fi

if [ "$DISTRO_MAJOR_VERSION" -ge 6 ]; then
#python-jinja2 is in repo server-releases-optional in EC2/RHEL6
yum-config-manager --enable rhui-\*-server-releases-optional || return 1

# Let's enable package installation testing, kind of, --dry-run
echoinfo "Testing if packages usually on the optionals repository are available:"
__YUM_CONF_DIR="$(mktemp -d)"
Expand Down Expand Up @@ -3749,7 +3772,8 @@ install_arch_linux_stable() {

install_arch_linux_git() {
if [ -f "${__SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then
python2 setup.py install --salt-config-dir="$_SALT_ETC_DIR" || return 1
python2 setup.py install --salt-config-dir="$_SALT_ETC_DIR" || \
python2 setup.py --salt-config-dir="$_SALT_ETC_DIR" install || return 1
else
python2 setup.py install || return 1
fi
Expand Down Expand Up @@ -4063,6 +4087,17 @@ install_freebsd_git() {
--salt-base-master-roots-dir="${_SALT_ETC_DIR}/salt-master" \
--salt-logs-dir=/var/log/salt \
--salt-pidfile-dir=/var/run \
|| /usr/local/bin/python2 setup.py \
--salt-root-dir=/usr/local \
--salt-config-dir="${_SALT_ETC_DIR}" \
--salt-cache-dir=/var/cache/salt \
--salt-sock-dir=/var/run/salt \
--salt-srv-root-dir=/srv \
--salt-base-file-roots-dir="${_SALT_ETC_DIR}/states" \
--salt-base-pillar-roots-dir="${_SALT_ETC_DIR}/pillar" \
--salt-base-master-roots-dir="${_SALT_ETC_DIR}/salt-master" \
--salt-logs-dir=/var/log/salt \
--salt-pidfile-dir=/var/run install \
|| return 1
fi

Expand Down Expand Up @@ -4140,6 +4175,11 @@ install_freebsd_restart_daemons() {
install_smartos_deps() {
pkgin -y install zeromq py27-m2crypto py27-crypto py27-msgpack py27-yaml py27-jinja2 py27-zmq py27-requests || return 1

# Set _SALT_ETC_DIR to SmartOS default if they didn't specify
_SALT_ETC_DIR=${BS_SALT_ETC_DIR:-/opt/local/etc/salt}
# We also need to redefine the PKI directory
_PKI_DIR=${_SALT_ETC_DIR}/pki

# Let's trigger config_salt()
if [ "$_TEMP_CONFIG_DIR" = "null" ]; then
# Let's set the configuration directory to /tmp
Expand All @@ -4159,6 +4199,10 @@ install_smartos_deps() {
fi
fi

if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then
pkgin -y install py27-apache-libcloud || return 1
fi

if [ "${_EXTRA_PACKAGES}" != "" ]; then
echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}"
# shellcheck disable=SC2086
Expand All @@ -4172,8 +4216,9 @@ install_smartos_deps() {
install_smartos_git_deps() {
install_smartos_deps || return 1

if [ "$(which git)" = "" ]; then
pkgin -y install scmgit || return 1
which git > /dev/null 2>&1
if [ $? -eq 1 ]; then
pkgin -y install git || return 1
fi

if [ -f "${__SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then
Expand Down Expand Up @@ -4205,7 +4250,9 @@ install_smartos_stable() {

install_smartos_git() {
# Use setuptools in order to also install dependencies
USE_SETUPTOOLS=1 /opt/local/bin/python setup.py install || return 1
# lets force our config path on the setup for now, since salt/syspaths.py only got fixed in 2015.5.0
USE_SETUPTOOLS=1 /opt/local/bin/python setup.py install --salt-config-dir="$_SALT_ETC_DIR" || \
USE_SETUPTOOLS=1 /opt/local/bin/python setup.py --salt-config-dir="$_SALT_ETC_DIR" install || return 1
return 0
}

Expand Down Expand Up @@ -4745,7 +4792,7 @@ __gentoo_config_protection() {
# this point, manually merge the changes using etc-update/dispatch-conf/
# cfg-update and then restart the bootstrapping script, so instead we allow
# at this point to modify certain config files directly
export CONFIG_PROTECT_MASK="$CONFIG_PROTECT_MASK /etc/portage/package.keywords /etc/portage/package.unmask /etc/portage/package.use /etc/portage/package.license"
export CONFIG_PROTECT_MASK="${CONFIG_PROTECT_MASK:-} /etc/portage/package.keywords /etc/portage/package.unmask /etc/portage/package.use /etc/portage/package.license"
}

__gentoo_pre_dep() {
Expand Down Expand Up @@ -5169,12 +5216,17 @@ done
echodebug "DAEMONS_RUNNING_FUNC=${DAEMONS_RUNNING_FUNC}"

# Let's get the check services function
CHECK_SERVICES_FUNC_NAMES="install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}_check_services"
CHECK_SERVICES_FUNC_NAMES="$CHECK_SERVICES_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}_check_services"
CHECK_SERVICES_FUNC_NAMES="$CHECK_SERVICES_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_check_services"
CHECK_SERVICES_FUNC_NAMES="$CHECK_SERVICES_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_check_services"
CHECK_SERVICES_FUNC_NAMES="$CHECK_SERVICES_FUNC_NAMES install_${DISTRO_NAME_L}_${ITYPE}_check_services"
CHECK_SERVICES_FUNC_NAMES="$CHECK_SERVICES_FUNC_NAMES install_${DISTRO_NAME_L}_check_services"
if [ ${_DISABLE_SALT_CHECKS} -eq $BS_FALSE ]; then
CHECK_SERVICES_FUNC_NAMES="install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}_check_services"
CHECK_SERVICES_FUNC_NAMES="$CHECK_SERVICES_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}_check_services"
CHECK_SERVICES_FUNC_NAMES="$CHECK_SERVICES_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_check_services"
CHECK_SERVICES_FUNC_NAMES="$CHECK_SERVICES_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_check_services"
CHECK_SERVICES_FUNC_NAMES="$CHECK_SERVICES_FUNC_NAMES install_${DISTRO_NAME_L}_${ITYPE}_check_services"
CHECK_SERVICES_FUNC_NAMES="$CHECK_SERVICES_FUNC_NAMES install_${DISTRO_NAME_L}_check_services"
else
CHECK_SERVICES_FUNC_NAMES=False
echowarn "DISABLE_SALT_CHECKS set, not setting \$CHECK_SERVICES_FUNC_NAMES"
fi

CHECK_SERVICES_FUNC="null"
for FUNC_NAME in $(__strip_duplicates "$CHECK_SERVICES_FUNC_NAMES"); do
Expand Down