mirror of
https://github.com/saltstack/salt-bootstrap.git
synced 2025-04-16 09:40:21 +00:00
Merge current develop branch into Stable for v2014.06.19
This commit is contained in:
commit
e386530be3
4 changed files with 148 additions and 34 deletions
|
@ -20,9 +20,13 @@ Elias Probst eliasp
|
|||
Erik Johnson terminalmage erik@saltstack.com
|
||||
Forrest Alvarez gravyboat
|
||||
Geoff Garside geoffgarside geoff@geoffgarside.co.uk
|
||||
giannello
|
||||
Guillaume Derval GuillaumeDerval guillaume@guillaumederval.be
|
||||
gweis
|
||||
Henrik Holmboe holmboe
|
||||
Jeff Hui jeffh jeff@jeffhui.net
|
||||
Jeff Strunk jstrunk
|
||||
Juan A. Moyano wincus wincus.public@gmail.com
|
||||
Karl Grzeszczak karlgrz
|
||||
Kenneth Wilke KennethWilke
|
||||
Liu Xiaohui oreh herolxh@gmail.com
|
||||
|
@ -37,6 +41,7 @@ Raymond Barbiero visualphoenix
|
|||
Roberto Aguilar rca roberto@baremetal.io
|
||||
Tate Eskew tateeskew
|
||||
Thomas S. Hatch thatch45 thatch45@saltstack.com
|
||||
Valentin Bud valentinbud valentin@databus.pro
|
||||
Vladimir Kozhukalov kozhukalov
|
||||
Whit Morriss whitmo whit@nocoast.us
|
||||
========================== ===================== ============================
|
||||
|
|
17
ChangeLog
17
ChangeLog
|
@ -1,4 +1,17 @@
|
|||
Version 2014.04:16
|
||||
Version 2014.06.19:
|
||||
* Allow passing the master address as an environment variable, `BS_SALT_MASTER_ADDRESS`
|
||||
* Fixed an issue with the keys pre-seed. We were passing absolute paths where we only needed
|
||||
basenames.
|
||||
* Added HTTP proxy configuration support. Thanks @gianello
|
||||
* Distro Support Added:
|
||||
* Elementary OS
|
||||
* RHEL 7 Beta/RC
|
||||
* Kali Linux. Thanks Valentin Bud(valentinbud)
|
||||
* Distro Support Fixed:
|
||||
* Improved RHEL optionals repository detection
|
||||
|
||||
|
||||
Version 2014.04.16:
|
||||
* Fixed a bug for RHEL 6 based distributions where yum-utils was not getting installed.
|
||||
* Added minor version check for RHEL 6 optional channel.
|
||||
* Added quotes around "apache-libcloud>=$_LIBCLOUD_MIN_VERSION" for proper version requirements
|
||||
|
@ -8,6 +21,8 @@ Version 2014.04:16
|
|||
its tags for proper versioning.
|
||||
* Distro Support Fixed:
|
||||
* CentOS netinstall ISO's don't install `chkconfig`
|
||||
* Improved RHEL optional repository detection. This allows user repository usage, which
|
||||
don't need the optional repository support since they usually provide their packages.
|
||||
* Distro Support Added:
|
||||
* Oracle Linux
|
||||
* Scientific Linux
|
||||
|
|
|
@ -324,7 +324,7 @@ Supported Operating Systems
|
|||
- SmartOS
|
||||
- SuSE 11 SP1/11 SP2
|
||||
- Ubuntu 10.x/11.x/12.x/13.04/13.10
|
||||
|
||||
- Elementary OS 0.2
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -17,20 +17,21 @@
|
|||
# CREATED: 10/15/2012 09:49:37 PM WEST
|
||||
#======================================================================================================================
|
||||
set -o nounset # Treat unset variables as an error
|
||||
__ScriptVersion="2014.04.16"
|
||||
__ScriptVersion="2014.06.19"
|
||||
__ScriptName="bootstrap-salt.sh"
|
||||
|
||||
#======================================================================================================================
|
||||
# Environment variables taken into account.
|
||||
#----------------------------------------------------------------------------------------------------------------------
|
||||
# * BS_COLORS: If 0 disables colour support
|
||||
# * BS_PIP_ALLOWED: If 1 enable pip based installations(if needed)
|
||||
# * BS_ECHO_DEBUG: If 1 enable debug echo which can also be set by -D
|
||||
# * BS_SALT_ETC_DIR: Defaults to /etc/salt (Only tweak'able on git based installations)
|
||||
# * BS_KEEP_TEMP_FILES: If 1, don't move temporary files, instead copy them
|
||||
# * BS_FORCE_OVERWRITE: Force overriding copied files(config, init.d, etc)
|
||||
# * BS_UPGRADE_SYS: If 1 and an option, upgrade system. Default 0.
|
||||
# * BS_GENTOO_USE_BINHOST: If 1 add `--getbinpkg` to gentoo's emerge
|
||||
# * BS_COLORS: If 0 disables colour support
|
||||
# * BS_PIP_ALLOWED: If 1 enable pip based installations(if needed)
|
||||
# * BS_ECHO_DEBUG: If 1 enable debug echo which can also be set by -D
|
||||
# * BS_SALT_ETC_DIR: Defaults to /etc/salt (Only tweak'able on git based installations)
|
||||
# * BS_KEEP_TEMP_FILES: If 1, don't move temporary files, instead copy them
|
||||
# * BS_FORCE_OVERWRITE: Force overriding copied files(config, init.d, etc)
|
||||
# * BS_UPGRADE_SYS: If 1 and an option, upgrade system. Default 0.
|
||||
# * BS_GENTOO_USE_BINHOST: If 1 add `--getbinpkg` to gentoo's emerge
|
||||
# * BS__SALT_MASTER_ADDRESS: The IP or DNS name of the salt-master the minion should connect to
|
||||
#======================================================================================================================
|
||||
|
||||
|
||||
|
@ -225,6 +226,7 @@ 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.
|
||||
-H Use the specified http proxy for the installation
|
||||
|
||||
EOT
|
||||
} # ---------- end of function usage ----------
|
||||
|
@ -252,19 +254,21 @@ _PKI_DIR=${_SALT_ETC_DIR}/pki
|
|||
_FORCE_OVERWRITE=${BS_FORCE_OVERWRITE:-$BS_FALSE}
|
||||
_GENTOO_USE_BINHOST=${BS_GENTOO_USE_BINHOST:-$BS_FALSE}
|
||||
_EPEL_REPO=${BS_EPEL_REPO:-epel}
|
||||
__EPEL_REPOS_INSTALLED=${BS_FALSE}
|
||||
_UPGRADE_SYS=${BS_UPGRADE_SYS:-$BS_FALSE}
|
||||
_INSECURE_DL=${BS_INSECURE_DL:-$BS_FALSE}
|
||||
_WGET_ARGS=${BS_WGET_ARGS:-}
|
||||
_CURL_ARGS=${BS_CURL_ARGS:-}
|
||||
_FETCH_ARGS=${BS_FETCH_ARGS:-}
|
||||
_SALT_MASTER_ADDRESS="null"
|
||||
_SALT_MASTER_ADDRESS=${BS_SALT_MASTER_ADDRESS:-null}
|
||||
_SALT_MINION_ID="null"
|
||||
# __SIMPLIFY_VERSION is mostly used in Solaris based distributions
|
||||
__SIMPLIFY_VERSION=$BS_TRUE
|
||||
_LIBCLOUD_MIN_VERSION="0.14.0"
|
||||
_EXTRA_PACKAGES=""
|
||||
_HTTP_PROXY=""
|
||||
|
||||
while getopts ":hvnDc:g:k:MSNXCPFUKIA:i:Lp:" opt
|
||||
while getopts ":hvnDc:g:k:MSNXCPFUKIA:i:Lp:H:" opt
|
||||
do
|
||||
case "${opt}" in
|
||||
|
||||
|
@ -306,6 +310,7 @@ do
|
|||
i ) _SALT_MINION_ID=$OPTARG ;;
|
||||
L ) _INSTALL_CLOUD=$BS_TRUE ;;
|
||||
p ) _EXTRA_PACKAGES="$_EXTRA_PACKAGES $OPTARG" ;;
|
||||
H ) _HTTP_PROXY="$OPTARG" ;;
|
||||
|
||||
|
||||
\?) echo
|
||||
|
@ -410,8 +415,15 @@ if [ "$(${whoami})" != "root" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Export the http_proxy configuration to our current environment
|
||||
if [ "x${_HTTP_PROXY}" != "x" ]; then
|
||||
export http_proxy="$_HTTP_PROXY"
|
||||
fi
|
||||
|
||||
# Let's discover how we're being called
|
||||
CALLER="$(echo `ps -a -o pid,args | grep $$ | grep -v grep | tr -s ' '` | cut -d ' ' -f 2)"
|
||||
# shellcheck disable=SC2009
|
||||
CALLER=$(ps -a -o pid,args | grep $$ | grep -v grep | tr -s ' ' | cut -d ' ' -f 3)
|
||||
|
||||
if [ "${CALLER}x" = "${0}x" ]; then
|
||||
CALLER="PIPED THROUGH"
|
||||
fi
|
||||
|
@ -419,7 +431,6 @@ fi
|
|||
echoinfo "${CALLER} ${0} -- Version ${__ScriptVersion}"
|
||||
#echowarn "Running the unstable version of ${__ScriptName}"
|
||||
|
||||
|
||||
#--- FUNCTION -------------------------------------------------------------------------------------------------------
|
||||
# NAME: __exit_cleanup
|
||||
# DESCRIPTION: Cleanup any leftovers after script has ended
|
||||
|
@ -455,6 +466,7 @@ __exit_cleanup() {
|
|||
rm -f $LOGPIPE
|
||||
|
||||
# Kill tee when exiting, CentOS, at least requires this
|
||||
# shellcheck disable=SC2009
|
||||
TEE_PID=$(ps ax | grep tee | grep $LOGFILE | awk '{print $1}')
|
||||
|
||||
[ "x$TEE_PID" = "x" ] && exit $EXIT_CODE
|
||||
|
@ -631,7 +643,7 @@ __sort_release_files() {
|
|||
done
|
||||
# Now, least important goes last in the min_prio list
|
||||
min_prio="lsb-release"
|
||||
for entry in $max_prio; do
|
||||
for entry in $min_prio; do
|
||||
if [ "x$(echo ${primary_release_files} | grep $entry)" != "x" ]; then
|
||||
primary_release_files=$(echo ${primary_release_files} | sed -e "s:\(.*\)\($entry\)\(.*\):\1 \3 \2:g")
|
||||
fi
|
||||
|
@ -883,7 +895,7 @@ __gather_system_info() {
|
|||
# functions by pretending to be Ubuntu (i.e. change global vars)
|
||||
#----------------------------------------------------------------------------------------------------------------------
|
||||
__ubuntu_derivatives_translation() {
|
||||
UBUNTU_DERIVATIVES="(trisquel|linuxmint|linaro)"
|
||||
UBUNTU_DERIVATIVES="(trisquel|linuxmint|linaro|elementary_os)"
|
||||
# Mappings
|
||||
trisquel_6_ubuntu_base="12.04"
|
||||
linuxmint_13_ubuntu_base="12.04"
|
||||
|
@ -893,14 +905,24 @@ __ubuntu_derivatives_translation() {
|
|||
# https://bugs.launchpad.net/linuxmint/+bug/1198751
|
||||
|
||||
linuxmint_16_ubuntu_base="13.10"
|
||||
|
||||
linaro_12_ubuntu_base="12.04"
|
||||
elementary_os_02_ubuntu_base="12.04"
|
||||
|
||||
# Translate Ubuntu derivatives to their base Ubuntu version
|
||||
match=$(echo $DISTRO_NAME_L | egrep ${UBUNTU_DERIVATIVES})
|
||||
|
||||
if [ "x${match}" != "x" ]; then
|
||||
_major="$(echo $DISTRO_VERSION | sed 's/^\([0-9]*\).*/\1/g')"
|
||||
case $match in
|
||||
"elementary_os")
|
||||
_major="$(echo $DISTRO_VERSION | sed 's/\.//g')"
|
||||
;;
|
||||
*)
|
||||
_major="$(echo $DISTRO_VERSION | sed 's/^\([0-9]*\).*/\1/g')"
|
||||
;;
|
||||
esac
|
||||
|
||||
_ubuntu_version="$(eval echo \$${1}_${_major}_ubuntu_base)"
|
||||
|
||||
if [ "x$_ubuntu_version" != "x" ]; then
|
||||
echodebug "Detected Ubuntu $_ubuntu_version derivative"
|
||||
DISTRO_NAME_L="ubuntu"
|
||||
|
@ -909,6 +931,45 @@ __ubuntu_derivatives_translation() {
|
|||
fi
|
||||
}
|
||||
|
||||
#--- FUNCTION -------------------------------------------------------------------------------------------------------
|
||||
# NAME: __debian_derivatives_translation
|
||||
# DESCRIPTION: Map Debian derivatives to their Debian base versions.
|
||||
# If distro has a known Debian base version, use those install
|
||||
# functions by pretending to be Debian (i.e. change global vars)
|
||||
#----------------------------------------------------------------------------------------------------------------------
|
||||
__debian_derivatives_translation() {
|
||||
|
||||
# If the file does not exist, return
|
||||
[ ! -f /etc/os-release ] && return
|
||||
|
||||
DEBIAN_DERIVATIVES="(kali)"
|
||||
# Mappings
|
||||
kali_1_debian_base="7.0"
|
||||
|
||||
# Detect derivates, Kali *only* for now
|
||||
rv=$(grep ^ID= /etc/os-release | sed -e 's/.*=//')
|
||||
|
||||
# Translate Debian derivatives to their base Debian version
|
||||
match=$(echo $rv | egrep ${DEBIAN_DERIVATIVES})
|
||||
|
||||
if [ "x${match}" != "x" ]; then
|
||||
case $match in
|
||||
kali)
|
||||
_major="$(echo $DISTRO_VERSION | sed 's/^\([0-9]*\).*/\1/g')"
|
||||
_debian_derivative="kali"
|
||||
;;
|
||||
esac
|
||||
|
||||
_debian_version="$(eval echo \$${_debian_derivative}_${_major}_debian_base)"
|
||||
|
||||
if [ "x$_debian_version" != "x" ]; then
|
||||
echodebug "Detected Debian $_debian_version derivative"
|
||||
DISTRO_NAME_L="debian"
|
||||
DISTRO_VERSION="$_debian_version"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
__gather_system_info
|
||||
|
||||
echo
|
||||
|
@ -920,6 +981,11 @@ echoinfo " OS Version: ${OS_VERSION}"
|
|||
echoinfo " Distribution: ${DISTRO_NAME} ${DISTRO_VERSION}"
|
||||
echo
|
||||
|
||||
# Let users know that we'll use a proxy
|
||||
if [ "x${_HTTP_PROXY}" != "x" ]; then
|
||||
echoinfo "Using http proxy $_HTTP_PROXY"
|
||||
fi
|
||||
|
||||
# Let users know what's going to be installed/configured
|
||||
if [ $_INSTALL_MINION -eq $BS_TRUE ]; then
|
||||
if [ $_CONFIG_ONLY -eq $BS_FALSE ]; then
|
||||
|
@ -957,7 +1023,10 @@ fi
|
|||
DISTRO_NAME_L=$(echo $DISTRO_NAME | tr '[:upper:]' '[:lower:]' | sed 's/[^a-zA-Z0-9_ ]//g' | sed -re 's/([[:space:]])+/_/g')
|
||||
|
||||
# For Ubuntu derivatives, pretend to be their Ubuntu base version
|
||||
__ubuntu_derivatives_translation "$DISTRO_NAME_L"
|
||||
__ubuntu_derivatives_translation
|
||||
|
||||
# For Debian derivates, pretend to be their Debian base version
|
||||
__debian_derivatives_translation
|
||||
|
||||
# Simplify version naming on functions
|
||||
if [ "x${DISTRO_VERSION}" = "x" ] || [ $__SIMPLIFY_VERSION -eq $BS_FALSE ]; then
|
||||
|
@ -2264,7 +2333,10 @@ install_fedora_check_services() {
|
|||
#
|
||||
# CentOS Install Functions
|
||||
#
|
||||
install_centos_stable_deps() {
|
||||
__install_epel_repository() {
|
||||
if [ ${__EPEL_REPOS_INSTALLED} -eq $BS_TRUE ]; then
|
||||
return 0
|
||||
fi
|
||||
if [ $CPU_ARCH_L = "i686" ]; then
|
||||
EPEL_ARCH="i386"
|
||||
else
|
||||
|
@ -2274,10 +2346,18 @@ install_centos_stable_deps() {
|
|||
rpm -Uvh --force http://mirrors.kernel.org/fedora-epel/5/${EPEL_ARCH}/epel-release-5-4.noarch.rpm || return 1
|
||||
elif [ $DISTRO_MAJOR_VERSION -eq 6 ]; then
|
||||
rpm -Uvh --force http://mirrors.kernel.org/fedora-epel/6/${EPEL_ARCH}/epel-release-6-8.noarch.rpm || return 1
|
||||
elif [ $DISTRO_MAJOR_VERSION -eq 7 ]; then
|
||||
rpm -Uvh --force http://mirrors.kernel.org/fedora-epel/beta/7/${EPEL_ARCH}/epel-release-7-0.1.noarch.rpm || return 1
|
||||
else
|
||||
echoerror "Failed add EPEL repository support."
|
||||
return 1
|
||||
fi
|
||||
__EPEL_REPOS_INSTALLED=${BS_TRUE}
|
||||
return 0
|
||||
}
|
||||
|
||||
install_centos_stable_deps() {
|
||||
__install_epel_repository
|
||||
|
||||
if [ $_UPGRADE_SYS -eq $BS_TRUE ]; then
|
||||
yum -y update || return 1
|
||||
|
@ -2479,15 +2559,23 @@ install_centos_check_services() {
|
|||
# RedHat Install Functions
|
||||
#
|
||||
install_red_hat_linux_stable_deps() {
|
||||
if [ $CPU_ARCH_L = "i686" ]; then
|
||||
OPTIONAL_ARCH="i386"
|
||||
else
|
||||
OPTIONAL_ARCH=$CPU_ARCH_L
|
||||
fi
|
||||
if [ $DISTRO_MAJOR_VERSION -eq 6 ] && case "X$(rhn-channel -l | grep optional)" in Xrhel-${OPTIONAL_ARCH}-server-optional-${DISTRO_MAJOR_VERSION}* ) false ;; * ) true ;; esac ; then
|
||||
echoerror "Failed to find RHN optional repo, please enable it using the GUI or rhn-channel command."
|
||||
return 1
|
||||
__install_epel_repository
|
||||
|
||||
if [ $DISTRO_MAJOR_VERSION -eq 6 ] || [ $DISTRO_MAJOR_VERSION -gt 6 ]; then
|
||||
# Let's enable package installation testing, kind of, --dry-run
|
||||
echoinfo "Installing 'yum-tsflags' to test for package installation success"
|
||||
yum install -y yum-tsflags --enablerepo=${_EPEL_REPO} || return 1
|
||||
|
||||
# Let's try installing the packages that usually require the optional repository
|
||||
for package in python-jinja2; do
|
||||
yum install -y --tsflags='test' ${package} --enablerepo=${_EPEL_REPO} >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echoerror "Failed to install '${package}'. The optional repository or it's subscription might be missing."
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
install_centos_stable_deps || return 1
|
||||
return 0
|
||||
}
|
||||
|
@ -2497,6 +2585,11 @@ install_red_hat_linux_git_deps() {
|
|||
return 0
|
||||
}
|
||||
|
||||
install_red_hat_enterprise_linux_7_stable_deps() {
|
||||
echoerror "Stable version is not available on RHEL 7 Beta/RC. Please set installation type to git."
|
||||
return 1
|
||||
}
|
||||
|
||||
install_red_hat_enterprise_linux_stable_deps() {
|
||||
install_red_hat_linux_stable_deps || return 1
|
||||
return 0
|
||||
|
@ -4006,6 +4099,7 @@ preseed_master() {
|
|||
[ -d $SEED_DEST ] || mkdir -p $SEED_DEST && chmod 700 $SEED_DEST || return 1
|
||||
|
||||
for keyfile in $_TEMP_KEYS_DIR/*; do
|
||||
keyfile=$(basename "${keyfile}")
|
||||
src_keyfile="${_TEMP_KEYS_DIR}/${keyfile}"
|
||||
dst_keyfile="${SEED_DEST}/${keyfile}"
|
||||
|
||||
|
@ -4039,6 +4133,7 @@ daemons_running() {
|
|||
[ $fname = "master" ] && [ $_INSTALL_MASTER -eq $BS_FALSE ] && continue
|
||||
[ $fname = "syndic" ] && [ $_INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
||||
|
||||
# shellcheck disable=SC2009
|
||||
if [ "${DISTRO_NAME}" = "SmartOS" ]; then
|
||||
if [ "$(svcs -Ho STA salt-$fname)" != "ON" ]; then
|
||||
echoerror "salt-$fname was not found running"
|
||||
|
@ -4162,8 +4257,6 @@ STARTDAEMONS_FUNC_NAMES="$STARTDAEMONS_FUNC_NAMES install_${DISTRO_NAME_L}_resta
|
|||
STARTDAEMONS_INSTALL_FUNC="null"
|
||||
for FUNC_NAME in $(__strip_duplicates $STARTDAEMONS_FUNC_NAMES); do
|
||||
if __function_defined $FUNC_NAME; then
|
||||
echodebug "Waiting 3 seconds for processes to settle before checking for them"
|
||||
sleep 3
|
||||
STARTDAEMONS_INSTALL_FUNC=$FUNC_NAME
|
||||
break
|
||||
fi
|
||||
|
@ -4183,8 +4276,6 @@ DAEMONS_RUNNING_FUNC_NAMES="$DAEMONS_RUNNING_FUNC_NAMES daemons_running"
|
|||
|
||||
for FUNC_NAME in $(__strip_duplicates $DAEMONS_RUNNING_FUNC_NAMES); do
|
||||
if __function_defined $FUNC_NAME; then
|
||||
echodebug "Waiting 3 seconds for processes to settle before checking for them"
|
||||
sleep 3
|
||||
DAEMONS_RUNNING_FUNC=$FUNC_NAME
|
||||
break
|
||||
fi
|
||||
|
@ -4312,6 +4403,8 @@ fi
|
|||
# Run any start daemons function
|
||||
if [ "$STARTDAEMONS_INSTALL_FUNC" != "null" ]; then
|
||||
echoinfo "Running ${STARTDAEMONS_INSTALL_FUNC}()"
|
||||
echodebug "Waiting 3 seconds for processes to settle before checking for them"
|
||||
sleep 3
|
||||
$STARTDAEMONS_INSTALL_FUNC
|
||||
if [ $? -ne 0 ]; then
|
||||
echoerror "Failed to run ${STARTDAEMONS_INSTALL_FUNC}()!!!"
|
||||
|
@ -4321,8 +4414,9 @@ fi
|
|||
|
||||
# Check if the installed daemons are running or not
|
||||
if [ "$DAEMONS_RUNNING_FUNC" != "null" ] && [ $_START_DAEMONS -eq $BS_TRUE ]; then
|
||||
sleep 3 # Sleep a little bit to let daemons start
|
||||
echoinfo "Running ${DAEMONS_RUNNING_FUNC}()"
|
||||
echodebug "Waiting 3 seconds for processes to settle before checking for them"
|
||||
sleep 3 # Sleep a little bit to let daemons start
|
||||
$DAEMONS_RUNNING_FUNC
|
||||
if [ $? -ne 0 ]; then
|
||||
echoerror "Failed to run ${DAEMONS_RUNNING_FUNC}()!!!"
|
||||
|
|
Loading…
Add table
Reference in a new issue