From 24d8a86c3110d87e1a0eaa5a36ac4b28a3dbcf4f Mon Sep 17 00:00:00 2001 From: Alexander Krasnukhin Date: Sat, 9 Jul 2016 03:46:35 +0200 Subject: [PATCH 01/30] Fix badge url Fix badge url to refer to saltstack repo instead of mine. This was merged by mistake. --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index c7d54f8..73ad7b3 100644 --- a/README.rst +++ b/README.rst @@ -538,6 +538,6 @@ Salt is ready and working in the Docker container with Minion authenticated on M .. vim: fenc=utf-8 spell spl=en cc=100 tw=99 fo=want sts=2 sw=2 et -.. |windows_build| image:: https://ci.appveyor.com/api/projects/status/github/themalkolm/salt-bootstrap?branch=develop&svg=true - :target: https://ci.appveyor.com/project/themalkolm/salt-bootstrap +.. |windows_build| image:: https://ci.appveyor.com/api/projects/status/github/saltstack/salt-bootstrap?branch=develop&svg=true + :target: https://ci.appveyor.com/project/saltstack-public/salt-bootstrap :alt: Build status of the develop branch on Windows From 061c50ec950e2038c53b9c3b3807707a25d2dd53 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Wed, 1 Jun 2016 15:28:04 +0300 Subject: [PATCH 02/30] Debian 8: support git installation on non-x86 architectures with `-r` --- bootstrap-salt.sh | 93 ++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 4d9f2cc..ef71974 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -2723,9 +2723,16 @@ install_debian_7_deps() { elif [ "$CPU_ARCH_L" = "armv7l" ]; then repo_arch="armhf" elif [ "$CPU_ARCH_L" = "i386" ] || [ "$CPU_ARCH_L" = "i686" ]; then - echoerror "repo.saltstack.com likely doesn't have 32-bit packages for Debian (yet?)" repo_arch="i386" + echoerror "repo.saltstack.com likely doesn't have all required $repo_arch packages for Debian $DISTRO_MAJOR_VERSION (yet?)." + else + repo_arch="$CPU_ARCH_L" + + echoerror "repo.saltstack.com doesn't have packages for your system architecture: $repo_arch." + exit 1 fi + else + echowarn "Packages from repo.saltstack.com are required to install Salt version 2015.8 or higher on Debian $DISTRO_MAJOR_VERSION." fi if [ $_START_DAEMONS -eq $BS_FALSE ]; then @@ -2749,10 +2756,11 @@ install_debian_7_deps() { fi if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then - # Versions starting with 2015.8.7 are hosted at repo.saltstack.com + # Versions starting with 2015.8.7 and 2016.3.0 are hosted at repo.saltstack.com if [ "$(echo "$STABLE_REV" | egrep '^(2015\.8|2016\.3|latest|archive\/201[5-6]\.)')" != "" ] || \ [ "$ITYPE" = "git" ]; then - SALTSTACK_DEBIAN_URL="${HTTP_VAL}://repo.saltstack.com/apt/debian/$DISTRO_MAJOR_VERSION/$repo_arch/${STABLE_REV:-latest}" + # amd64 is is just a part of repository URI, 32-bit pkgs are hosted under the same location + SALTSTACK_DEBIAN_URL="${HTTP_VAL}://repo.saltstack.com/apt/debian/$DISTRO_MAJOR_VERSION/amd64/${STABLE_REV:-latest}" echo "deb $SALTSTACK_DEBIAN_URL wheezy main" > "/etc/apt/sources.list.d/saltstack.list" if [ "$HTTP_VAL" = "https" ] ; then @@ -2801,8 +2809,14 @@ install_debian_8_deps() { elif [ "$CPU_ARCH_L" = "armv7l" ]; then repo_arch="armhf" elif [ "$CPU_ARCH_L" = "i386" ] || [ "$CPU_ARCH_L" = "i686" ]; then - echoerror "repo.saltstack.com likely doesn't have 32-bit packages for Debian (yet?)" repo_arch="i386" + else + repo_arch="$CPU_ARCH_L" + + echoerror "repo.saltstack.com doesn't have packages for your system architecture: $repo_arch." + echoerror "Try git installation mode and disable SaltStack apt repository, for example:" + echoerror " sh ${__ScriptName} -r git v2016.3.0" + exit 1 fi fi @@ -2828,8 +2842,10 @@ install_debian_8_deps() { if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then # Versions starting with 2015.5.6, 2015.8.1 and 2016.3.0 are hosted at repo.saltstack.com - if [ "$(echo "$STABLE_REV" | egrep '^(2015\.5|2015\.8|2016\.3|latest|archive\/201[5-6]\.)')" != "" ]; then - SALTSTACK_DEBIAN_URL="${HTTP_VAL}://repo.saltstack.com/apt/debian/$DISTRO_MAJOR_VERSION/$repo_arch/$STABLE_REV" + if [ "$(echo "$STABLE_REV" | egrep '^(2015\.5|2015\.8|2016\.3|latest|archive\/201[5-6]\.)')" != "" ] || \ + [ "$ITYPE" = "git" ]; then + # amd64 is is just a part of repository URI, 32-bit pkgs are hosted under the same location + SALTSTACK_DEBIAN_URL="${HTTP_VAL}://repo.saltstack.com/apt/debian/$DISTRO_MAJOR_VERSION/amd64/${STABLE_REV:-latest}" echo "deb $SALTSTACK_DEBIAN_URL jessie main" > "/etc/apt/sources.list.d/saltstack.list" if [ "$HTTP_VAL" = "https" ] ; then @@ -2878,9 +2894,11 @@ install_debian_git_deps() { __git_clone_and_checkout || return 1 - __apt_get_install_noinput lsb-release python python-pkg-resources python-crypto \ - python-jinja2 python-m2crypto python-yaml msgpack-python python-tornado \ - python-backports.ssl-match-hostname || return 1 + __PACKAGES='lsb-release python-crypto python-jinja2 python-m2crypto python-msgpack python-yaml' + __PACKAGES="${__PACKAGES} ${__TORNADO_PACKAGES:-python-backports.ssl-match-hostname python-tornado}" + + # shellcheck disable=SC2086 + __apt_get_install_noinput ${__PACKAGES} || return 1 # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then @@ -2893,60 +2911,45 @@ install_debian_git_deps() { install_debian_7_git_deps() { install_debian_7_deps || return 1 - install_debian_git_deps || return 1 # Grab the actual deps + install_debian_git_deps || return 1 + return 0 } install_debian_8_git_deps() { install_debian_8_deps || return 1 - if ! __check_command_exists git; then - __apt_get_install_noinput git || return 1 - fi + __PIP_PACKAGES='' - __git_clone_and_checkout || return 1 + if [ $_DISABLE_REPOS -eq $BS_TRUE ] || [ "$repo_arch" = "i386" ]; then + if (__check_pip_allowed >/dev/null 2>&1); then + __PIP_PACKAGES='tornado' + # Skip installation of python-tornado debian package, use pip instead + __TORNADO_PACKAGES='build-essential python-dev' - __PACKAGES="lsb-release python-pkg-resources python-crypto python-jinja2 python-m2crypto python-yaml msgpack-python" - __PIP_PACKAGES="" - - if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then - __REQUIRED_TORNADO="$(grep ^tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" | tr -d ' ')" - - if [ -n "${__REQUIRED_TORNADO}" ]; then - if (__check_pip_allowed >/dev/null 2>&1); then - __PACKAGES="${__PACKAGES} python-dev" - __PIP_PACKAGES="${__PIP_PACKAGES} tornado" - - if ! __check_command_exists pip; then - __PACKAGES="${__PACKAGES} python-pip" - fi - else - # Check if Debian Backports repo already configured - if ! apt-cache policy | grep -q 'Debian Backports'; then - echo 'deb http://httpredir.debian.org/debian jessie-backports main' > \ - /etc/apt/sources.list.d/backports.list - apt-get update - fi - - __PACKAGES="${__PACKAGES} python-tornado/jessie-backports" + if ! __check_command_exists pip; then + __TORNADO_PACKAGES="${__TORNADO_PACKAGES} python-pip" fi + else + # Check if Debian Backports repo already configured + if ! apt-cache policy | grep -q 'Debian Backports'; then + echo 'deb http://httpredir.debian.org/debian jessie-backports main' > \ + /etc/apt/sources.list.d/backports.list + apt-get update || return 1 + fi + + # Tornado package will be installed from backports repo + __TORNADO_PACKAGES="python-backports.ssl-match-hostname python-tornado/jessie-backports" fi fi - # shellcheck disable=SC2086 - __apt_get_install_noinput ${__PACKAGES} || return 1 + install_debian_git_deps || return 1 if [ "${__PIP_PACKAGES}" != "" ]; then # shellcheck disable=SC2086,SC2090 pip install -U ${__PIP_PACKAGES} || return 1 fi - # Let's trigger config_salt() - if [ "$_TEMP_CONFIG_DIR" = "null" ]; then - _TEMP_CONFIG_DIR="${_SALT_GIT_CHECKOUT_DIR}/conf/" - CONFIG_SALT_FUNC="config_salt" - fi - return 0 } From 0a69f1f407d3116d8fbc210000f0a79bfa1db97c Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Thu, 2 Jun 2016 14:55:16 +0300 Subject: [PATCH 03/30] Debian 8 git: do not configure backports repo when using `-r` --- bootstrap-salt.sh | 77 +++++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index ef71974..4648cac 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -2724,6 +2724,7 @@ install_debian_7_deps() { repo_arch="armhf" elif [ "$CPU_ARCH_L" = "i386" ] || [ "$CPU_ARCH_L" = "i686" ]; then repo_arch="i386" + echoerror "repo.saltstack.com likely doesn't have all required $repo_arch packages for Debian $DISTRO_MAJOR_VERSION (yet?)." else repo_arch="$CPU_ARCH_L" @@ -2770,7 +2771,7 @@ install_debian_7_deps() { # shellcheck disable=SC2086 wget $_WGET_ARGS -q "$SALTSTACK_DEBIAN_URL/SALTSTACK-GPG-KEY.pub" -O - | apt-key add - || return 1 elif [ -n "$STABLE_REV" ]; then - echoerror "Installation of Salt $STABLE_REV currently unsupported by ${__ScriptName} ${__ScriptVersion}" + echoerror "Installation of Salt ${STABLE_REV#*/} packages not supported by ${__ScriptName} ${__ScriptVersion} on Debian $DISTRO_MAJOR_VERSION." return 1 fi fi @@ -2810,12 +2811,14 @@ install_debian_8_deps() { repo_arch="armhf" elif [ "$CPU_ARCH_L" = "i386" ] || [ "$CPU_ARCH_L" = "i686" ]; then repo_arch="i386" + + echoerror "repo.saltstack.com likely doesn't have all required $repo_arch packages for Debian $DISTRO_MAJOR_VERSION (yet?)." else repo_arch="$CPU_ARCH_L" echoerror "repo.saltstack.com doesn't have packages for your system architecture: $repo_arch." echoerror "Try git installation mode and disable SaltStack apt repository, for example:" - echoerror " sh ${__ScriptName} -r git v2016.3.0" + echoerror " sh ${__ScriptName} -r -P git v2016.3.0" exit 1 fi fi @@ -2855,7 +2858,7 @@ install_debian_8_deps() { # shellcheck disable=SC2086 wget $_WGET_ARGS -q "$SALTSTACK_DEBIAN_URL/SALTSTACK-GPG-KEY.pub" -O - | apt-key add - || return 1 elif [ -n "$STABLE_REV" ]; then - echoerror "Installation of Salt $STABLE_REV currently unsupported by ${__ScriptName} ${__ScriptVersion}" + echoerror "Installation of Salt ${STABLE_REV#*/} packages not supported by ${__ScriptName} ${__ScriptVersion} on Debian $DISTRO_MAJOR_VERSION." return 1 fi fi @@ -2894,11 +2897,9 @@ install_debian_git_deps() { __git_clone_and_checkout || return 1 - __PACKAGES='lsb-release python-crypto python-jinja2 python-m2crypto python-msgpack python-yaml' - __PACKAGES="${__PACKAGES} ${__TORNADO_PACKAGES:-python-backports.ssl-match-hostname python-tornado}" - # shellcheck disable=SC2086 - __apt_get_install_noinput ${__PACKAGES} || return 1 + __apt_get_install_noinput lsb-release python-backports.ssl-match-hostname python-crypto python-jinja2 \ + python-m2crypto python-msgpack python-tornado python-yaml || return 1 # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then @@ -2919,37 +2920,53 @@ install_debian_7_git_deps() { install_debian_8_git_deps() { install_debian_8_deps || return 1 - __PIP_PACKAGES='' - - if [ $_DISABLE_REPOS -eq $BS_TRUE ] || [ "$repo_arch" = "i386" ]; then - if (__check_pip_allowed >/dev/null 2>&1); then - __PIP_PACKAGES='tornado' - # Skip installation of python-tornado debian package, use pip instead - __TORNADO_PACKAGES='build-essential python-dev' - - if ! __check_command_exists pip; then - __TORNADO_PACKAGES="${__TORNADO_PACKAGES} python-pip" - fi - else - # Check if Debian Backports repo already configured - if ! apt-cache policy | grep -q 'Debian Backports'; then - echo 'deb http://httpredir.debian.org/debian jessie-backports main' > \ - /etc/apt/sources.list.d/backports.list - apt-get update || return 1 - fi - - # Tornado package will be installed from backports repo - __TORNADO_PACKAGES="python-backports.ssl-match-hostname python-tornado/jessie-backports" - fi + if ! __check_command_exists git; then + __apt_get_install_noinput git || return 1 fi - install_debian_git_deps || return 1 + __git_clone_and_checkout || return 1 + + __PACKAGES='lsb-release python-crypto python-jinja2 python-m2crypto python-msgpack python-yaml' + __PIP_PACKAGES='' + + if (__check_pip_allowed >/dev/null 2>&1); then + __PIP_PACKAGES='tornado' + # Install development environment for building tornado Python module + __PACKAGES="${__PACKAGES} build-essential python-dev" + + if ! __check_command_exists pip; then + __PACKAGES="${__PACKAGES} python-pip" + fi + # Attempt to configure backports repo on non-x86_64 system + elif [ $_DISABLE_REPOS -eq $BS_FALSE ] && [ "$CPU_ARCH_L" != "x86_64" ]; then + # Check if Debian Backports repo already configured + if ! apt-cache policy | grep -q 'Debian Backports'; then + echo 'deb http://httpredir.debian.org/debian jessie-backports main' > \ + /etc/apt/sources.list.d/backports.list + fi + + apt-get update || return 1 + + # python-tornado package should be installed from backports repo + __PACKAGES="${__PACKAGES} python-backports.ssl-match-hostname python-tornado/jessie-backports" + else + __PACKAGES="${__PACKAGES} python-backports.ssl-match-hostname python-tornado" + fi + + # shellcheck disable=SC2086 + __apt_get_install_noinput ${__PACKAGES} || return 1 if [ "${__PIP_PACKAGES}" != "" ]; then # shellcheck disable=SC2086,SC2090 pip install -U ${__PIP_PACKAGES} || return 1 fi + # Let's trigger config_salt() + if [ "$_TEMP_CONFIG_DIR" = "null" ]; then + _TEMP_CONFIG_DIR="${_SALT_GIT_CHECKOUT_DIR}/conf/" + CONFIG_SALT_FUNC="config_salt" + fi + return 0 } From 260e5ec5edcf512b8449a0d9c554acfb19e75411 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Mon, 6 Jun 2016 11:24:22 +0300 Subject: [PATCH 04/30] Re-format usage output to fix 80 characters width terminal --- bootstrap-salt.sh | 71 ++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 4648cac..cbd03b7 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -265,27 +265,27 @@ __usage() { - ${__ScriptName} - ${__ScriptName} stable - ${__ScriptName} stable 2015.8 - - ${__ScriptName} stable 2015.8.9 + - ${__ScriptName} stable 2015.8.10 - ${__ScriptName} daily - ${__ScriptName} testing - ${__ScriptName} git - ${__ScriptName} git 2015.8 - - ${__ScriptName} git v2015.8.9 + - ${__ScriptName} git v2015.8.10 - ${__ScriptName} git 8c3fadf15ec183e5ce8c63739850d543617e4357 Options: -h Display this message -v Display script version - -n No colours. - -D Show debug output. + -n No colours + -D Show debug output -c Temporary configuration directory -g Salt repository URL. Default: ${_SALTSTACK_REPO_URL} -G Instead of cloning from ${_SALTSTACK_REPO_URL}, clone from https://${_SALTSTACK_REPO_URL#*://} - (Usually necessary on systems which have the regular git protocol port + (usually necessary on systems which have the regular git protocol port blocked, where https usually is not) -w Install packages from downstream package repository rather than - upstream, saltstack package repository. This is currently only + upstream, saltstack package repository. This is currently only implemented for SUSE. -k Temporary directory holding the minion keys which will pre-seed the master. @@ -295,6 +295,10 @@ __usage() { -S Also install salt-syndic -N Do not install salt-minion -X Do not start daemons after installation + -d Disable check_service functions. Setting this flag disables the + 'install__check_services' checks. You can also do this by + touching /tmp/disable_salt_checks on the target host. + Default: \${BS_FALSE} -C Only run the configuration function. This option automatically bypasses any installation. Implies -F (forced overwrite). To overwrite master or syndic configs, -M or -S, respectively, must also be specified. @@ -303,10 +307,10 @@ __usage() { distribution. Using this flag allows the script to use pip as a last resort method. NOTE: This only works for functions which actually implement pip based installations. - -F Allow copied files to overwrite existing (config, init.d, etc). - -U If set, fully upgrade the system prior to bootstrapping salt + -F Allow copied files to overwrite existing (config, init.d, etc) + -U If set, fully upgrade the system prior to bootstrapping Salt -K If set, keep the temporary files in the temporary directories specified - with -c and -k. + with -c and -k -I If set, allow insecure connections while downloading any files. For example, pass '--no-check-certificate' to 'wget' or '--insecure' to 'curl' @@ -314,17 +318,14 @@ __usage() { \${BS_SALT_ETC_DIR}/minion.d/99-master-address.conf -i Pass the salt-minion id. This will be stored under \${BS_SALT_ETC_DIR}/minion_id - -L Install the Apache Libcloud package if possible(required for salt-cloud) - -p Extra-package to install while installing salt dependencies. One package + -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__check_services' checks. You can also do this by - touching /tmp/disable_salt_checks on the target host. - Default: \${BS_FALSE} -H Use the specified HTTP proxy for all download URLs (including https://). For example: http://myproxy.example.com:3128 -Z Enable additional package repository for newer ZeroMQ - (Only available for RHEL/CentOS/Fedora/Ubuntu based distributions) + (only available for RHEL/CentOS/Fedora/Ubuntu based distributions) -b Assume that dependencies are already installed and software sources are set up. If git is selected, git tree is still checked out as dependency step. @@ -332,27 +333,29 @@ __usage() { This may result in an "n/a" in the version number. -l Disable ssl checks. When passed, switches "https" calls to "http" where possible. - -V Install salt into virtualenv(Only available for Ubuntu base distributions) - -a Pip install all python pkg dependencies for salt. Requires -V to install - all pip pkgs into the virtualenv(Only available for Ubuntu based - distributions) + -V Install Salt into virtualenv + (only available for Ubuntu based distributions) + -a Pip install all Python pkg dependencies for Salt. Requires -V to install + all pip pkgs into the virtualenv. + (Only available for Ubuntu based distributions) -r Disable all repository configuration performed by this script. This option assumes all necessary repository configuration is already present on the system. - -R Specify a custom repository URL. Assumes the custom repository URL points - to a repository that mirrors Salt packages located at repo.saltstack.com. - The option passed with -R replaces "repo.saltstack.com". If -R is passed, - -r is also set. Currently only works on CentOS/RHEL based distributions. - -J Replace the Master config file with data passed in as a json string. If a - Master config file is found, a reasonable effort will be made to save the - file with a ".bak" extension. If used in conjunction with -C or -F, no ".bak" - file will be created as either of those options will force a complete - overwrite of the file. - -j Replace the Minion config file with data passed in as a json string. If a - Minion config file is found, a reasonable effort will be made to save the - file with a ".bak" extension. If used in conjunction with -C or -F, no ".bak" - file will be created as either of those options will force a complete - overwrite of the file. + -R Specify a custom repository URL. Assumes the custom repository URL + points to a repository that mirrors Salt packages located at + repo.saltstack.com. The option passed with -R replaces the + "repo.saltstack.com". If -R is passed, -r is also set. Currently only + works on CentOS/RHEL based distributions. + -J Replace the Master config file with data passed in as a json string. If + a Master config file is found, a reasonable effort will be made to save + the file with a ".bak" extension. If used in conjunction with -C or -F, + no ".bak" file will be created as either of those options will force + a complete overwrite of the file. + -j Replace the Minion config file with data passed in as a json string. If + a Minion config file is found, a reasonable effort will be made to save + the file with a ".bak" extension. If used in conjunction with -C or -F, + no ".bak" file will be created as either of those options will force + a complete overwrite of the file. -q Quiet salt installation from git (setup.py install -q) EOT From 88078bef120af104de5a5c24fd5038acc61bea0e Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Thu, 9 Jun 2016 14:23:03 +0300 Subject: [PATCH 05/30] Debian: add note to README about supported system architectures --- README.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.rst b/README.rst index 73ad7b3..b136cde 100644 --- a/README.rst +++ b/README.rst @@ -212,6 +212,12 @@ Debian and derivatives - Linux Mint Debian Edition 1 (based on Debian 8) - Kali Linux 1.0 (based on Debian 7) +.. note:: + + Installation of Salt packages on Debian distribution from repo.saltstack.com repository is + currently supported for ``amd64`` (``x86-64``) architechture ONLY. Use ``git`` bootstrap + mode as mentioned above to install Salt on other architechtures, such as ``i386`` or ``armel``. + Red Hat family ~~~~~~~~~~~~~~ From e719a1f63ee73db2878b71257db66f232c9669f9 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Sat, 11 Jun 2016 16:06:32 +0300 Subject: [PATCH 06/30] Detect OS packages architecture on Debian instead of relying on CPU data --- bootstrap-salt.sh | 111 ++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 59 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index cbd03b7..3b37f62 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -1164,6 +1164,21 @@ __gather_system_info() { } +#--- FUNCTION ------------------------------------------------------------------------------------------------------- +# NAME: __get_dpkg_architecture +# DESCRIPTION: Determine primary architecture for packages to install on Debian and derivatives +#---------------------------------------------------------------------------------------------------------------------- +__get_dpkg_architecture() { + if ! __check_command_exist dpkg; then + DPKG_ARCHITECTURE="$(dpkg --print-architecture)" + else + echoerror "dpkg: command not found." + return 1 + fi + + return 0 +} + #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: __ubuntu_derivatives_translation # DESCRIPTION: Map Ubuntu derivatives to their Ubuntu base versions. @@ -2337,19 +2352,18 @@ install_ubuntu_deps() { } install_ubuntu_stable_deps() { - - if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then - if [ "$CPU_ARCH_L" = "amd64" ] || [ "$CPU_ARCH_L" = "x86_64" ]; then - repo_arch="amd64" - elif [ "$CPU_ARCH_L" = "i386" ] || [ "$CPU_ARCH_L" = "i686" ]; then - echoerror "repo.saltstack.com likely doesn't have 32-bit packages for Ubuntu (yet?)" - repo_arch="i386" - fi - fi - install_ubuntu_deps || return 1 if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then + __get_dpkg_architecture || return 1 + + if [ "$DPKG_ARCHITECTURE" = "i386" ]; then + echoerror "repo.saltstack.com likely doesn't have all required 32-bit packages for Ubuntu $DISTRO_MAJOR_VERSION (yet?)." + elif [ "$DPKG_ARCHITECTURE" != "amd64" ]; then + echoerror "repo.saltstack.com doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." + exit 1 + fi + # Versions starting with 2015.5.6 and 2015.8.1 are hosted at repo.saltstack.com if [ "$(echo "$STABLE_REV" | egrep '^(2015\.5|2015\.8|2016\.3|latest|archive\/)')" != "" ]; then # Workaround for latest non-LTS ubuntu @@ -2362,8 +2376,10 @@ install_ubuntu_stable_deps() { UBUNTU_CODENAME=$DISTRO_CODENAME fi - # SaltStack's stable Ubuntu repository - SALTSTACK_UBUNTU_URL="${HTTP_VAL}://repo.saltstack.com/apt/ubuntu/$UBUNTU_VERSION/$repo_arch/$STABLE_REV" + # SaltStack's stable Ubuntu repository: + # amd64 is is just a part of repository URI, 32-bit pkgs are hosted under the same location + SALTSTACK_UBUNTU_URL="${HTTP_VAL}://repo.saltstack.com/apt/ubuntu/$UBUNTU_VERSION/amd64/$STABLE_REV" + if [ "$(grep -ER 'latest .+ main' /etc/apt)" = "" ]; then set +o nounset echo "deb $SALTSTACK_UBUNTU_URL $UBUNTU_CODENAME main" > "/etc/apt/sources.list.d/saltstack.list" @@ -2681,6 +2697,7 @@ install_debian_deps() { if [ $_START_DAEMONS -eq $BS_FALSE ]; then echowarn "Not starting daemons on Debian based distributions is not working mostly because starting them is the default behaviour." fi + # No user interaction, libc6 restart services for example export DEBIAN_FRONTEND=noninteractive @@ -2720,25 +2737,6 @@ install_debian_deps() { } install_debian_7_deps() { - if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then - if [ "$CPU_ARCH_L" = "amd64" ] || [ "$CPU_ARCH_L" = "x86_64" ]; then - repo_arch="amd64" - elif [ "$CPU_ARCH_L" = "armv7l" ]; then - repo_arch="armhf" - elif [ "$CPU_ARCH_L" = "i386" ] || [ "$CPU_ARCH_L" = "i686" ]; then - repo_arch="i386" - - echoerror "repo.saltstack.com likely doesn't have all required $repo_arch packages for Debian $DISTRO_MAJOR_VERSION (yet?)." - else - repo_arch="$CPU_ARCH_L" - - echoerror "repo.saltstack.com doesn't have packages for your system architecture: $repo_arch." - exit 1 - fi - else - echowarn "Packages from repo.saltstack.com are required to install Salt version 2015.8 or higher on Debian $DISTRO_MAJOR_VERSION." - fi - if [ $_START_DAEMONS -eq $BS_FALSE ]; then echowarn "Not starting daemons on Debian based distributions is not working mostly because starting them is the default behaviour." fi @@ -2760,6 +2758,15 @@ install_debian_7_deps() { fi if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then + __get_dpkg_architecture || return 1 + + if [ "$DPKG_ARCHITECTURE" = "i386" ]; then + echoerror "repo.saltstack.com likely doesn't have all required 32-bit packages for Debian $DISTRO_MAJOR_VERSION (yet?)." + elif [ "$DPKG_ARCHITECTURE" != "amd64" ]; then + echoerror "repo.saltstack.com doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." + exit 1 + fi + # Versions starting with 2015.8.7 and 2016.3.0 are hosted at repo.saltstack.com if [ "$(echo "$STABLE_REV" | egrep '^(2015\.8|2016\.3|latest|archive\/201[5-6]\.)')" != "" ] || \ [ "$ITYPE" = "git" ]; then @@ -2777,6 +2784,8 @@ install_debian_7_deps() { echoerror "Installation of Salt ${STABLE_REV#*/} packages not supported by ${__ScriptName} ${__ScriptVersion} on Debian $DISTRO_MAJOR_VERSION." return 1 fi + else + echowarn "Packages from repo.saltstack.com are required to install Salt version 2015.8 or higher on Debian $DISTRO_MAJOR_VERSION." fi apt-get update || return 1 @@ -2807,25 +2816,6 @@ install_debian_7_deps() { } install_debian_8_deps() { - if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then - if [ "$CPU_ARCH_L" = "amd64" ] || [ "$CPU_ARCH_L" = "x86_64" ]; then - repo_arch="amd64" - elif [ "$CPU_ARCH_L" = "armv7l" ]; then - repo_arch="armhf" - elif [ "$CPU_ARCH_L" = "i386" ] || [ "$CPU_ARCH_L" = "i686" ]; then - repo_arch="i386" - - echoerror "repo.saltstack.com likely doesn't have all required $repo_arch packages for Debian $DISTRO_MAJOR_VERSION (yet?)." - else - repo_arch="$CPU_ARCH_L" - - echoerror "repo.saltstack.com doesn't have packages for your system architecture: $repo_arch." - echoerror "Try git installation mode and disable SaltStack apt repository, for example:" - echoerror " sh ${__ScriptName} -r -P git v2016.3.0" - exit 1 - fi - fi - if [ $_START_DAEMONS -eq $BS_FALSE ]; then echowarn "Not starting daemons on Debian based distributions is not working mostly because starting them is the default behaviour." fi @@ -2847,6 +2837,17 @@ install_debian_8_deps() { fi if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then + __get_dpkg_architecture || return 1 + + if [ "$DPKG_ARCHITECTURE" = "i386" ]; then + echoerror "repo.saltstack.com likely doesn't have all required 32-bit packages for Debian $DISTRO_MAJOR_VERSION (yet?)." + elif [ "$DPKG_ARCHITECTURE" != "amd64" ]; then + echoerror "repo.saltstack.com doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." + echoerror "Try git installation mode and disable SaltStack apt repository, for example:" + echoerror " sh ${__ScriptName} -r -P git v2016.3.0" + exit 1 + fi + # Versions starting with 2015.5.6, 2015.8.1 and 2016.3.0 are hosted at repo.saltstack.com if [ "$(echo "$STABLE_REV" | egrep '^(2015\.5|2015\.8|2016\.3|latest|archive\/201[5-6]\.)')" != "" ] || \ [ "$ITYPE" = "git" ]; then @@ -2941,7 +2942,7 @@ install_debian_8_git_deps() { __PACKAGES="${__PACKAGES} python-pip" fi # Attempt to configure backports repo on non-x86_64 system - elif [ $_DISABLE_REPOS -eq $BS_FALSE ] && [ "$CPU_ARCH_L" != "x86_64" ]; then + elif [ $_DISABLE_REPOS -eq $BS_FALSE ] && [ "$DPKG_ARCHITECTURE" != "amd64" ]; then # Check if Debian Backports repo already configured if ! apt-cache policy | grep -q 'Debian Backports'; then echo 'deb http://httpredir.debian.org/debian jessie-backports main' > \ @@ -4121,14 +4122,6 @@ _eof } install_amazon_linux_ami_git_deps() { - - # When installing from git, this variable might not be set yet for amazon linux. Set this - # to "latest" in order to set up the SaltStack repository and avoid a malformed baseurl - # and gpgkey reference in the install_amazon_linux_amI_deps function. - if [ "$STABLE_REV" = "" ]; then - STABLE_REV="latest" - fi - install_amazon_linux_ami_deps || return 1 if ! __check_command_exists git; then From 0ca3a3a7206bc681d6bd037614ddb53e0d5623c8 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Mon, 13 Jun 2016 10:44:04 +0300 Subject: [PATCH 07/30] Debian: add suggestion to try git installation mode on i386 arch --- bootstrap-salt.sh | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 3b37f62..efd5cd1 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -264,14 +264,14 @@ __usage() { Examples: - ${__ScriptName} - ${__ScriptName} stable - - ${__ScriptName} stable 2015.8 - - ${__ScriptName} stable 2015.8.10 + - ${__ScriptName} stable 2016.3 + - ${__ScriptName} stable 2016.3.0 - ${__ScriptName} daily - ${__ScriptName} testing - ${__ScriptName} git - - ${__ScriptName} git 2015.8 - - ${__ScriptName} git v2015.8.10 - - ${__ScriptName} git 8c3fadf15ec183e5ce8c63739850d543617e4357 + - ${__ScriptName} git 2016.3 + - ${__ScriptName} git v2016.3.0 + - ${__ScriptName} git 11acecc43e2c2e4e9a0e73d76b46b035afe8d538 Options: -h Display this message @@ -1169,7 +1169,7 @@ __gather_system_info() { # DESCRIPTION: Determine primary architecture for packages to install on Debian and derivatives #---------------------------------------------------------------------------------------------------------------------- __get_dpkg_architecture() { - if ! __check_command_exist dpkg; then + if ! __check_command_exists dpkg; then DPKG_ARCHITECTURE="$(dpkg --print-architecture)" else echoerror "dpkg: command not found." @@ -2746,9 +2746,6 @@ install_debian_7_deps() { apt-get update - # Make sure wget is available - __apt_get_install_noinput wget - # Install Keys __apt_get_install_noinput debian-archive-keyring && apt-get update @@ -2757,13 +2754,18 @@ install_debian_7_deps() { apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8B48AD6246925553 || return 1 fi + # Make sure wget is available + __apt_get_install_noinput wget || return 1 + if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then __get_dpkg_architecture || return 1 if [ "$DPKG_ARCHITECTURE" = "i386" ]; then echoerror "repo.saltstack.com likely doesn't have all required 32-bit packages for Debian $DISTRO_MAJOR_VERSION (yet?)." + echoerror "You can try git installation mode, i.e.: sh ${__ScriptName} git v2016.3.0" elif [ "$DPKG_ARCHITECTURE" != "amd64" ]; then echoerror "repo.saltstack.com doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." + exit 1 fi @@ -2782,6 +2784,7 @@ install_debian_7_deps() { wget $_WGET_ARGS -q "$SALTSTACK_DEBIAN_URL/SALTSTACK-GPG-KEY.pub" -O - | apt-key add - || return 1 elif [ -n "$STABLE_REV" ]; then echoerror "Installation of Salt ${STABLE_REV#*/} packages not supported by ${__ScriptName} ${__ScriptVersion} on Debian $DISTRO_MAJOR_VERSION." + return 1 fi else @@ -2825,9 +2828,6 @@ install_debian_8_deps() { apt-get update - # Make sure wget is available - __apt_get_install_noinput wget - # Install Keys __apt_get_install_noinput debian-archive-keyring && apt-get update @@ -2836,15 +2836,20 @@ install_debian_8_deps() { apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010 || return 1 fi + # Make sure wget is available + __apt_get_install_noinput wget || return 1 + if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then __get_dpkg_architecture || return 1 if [ "$DPKG_ARCHITECTURE" = "i386" ]; then echoerror "repo.saltstack.com likely doesn't have all required 32-bit packages for Debian $DISTRO_MAJOR_VERSION (yet?)." + echoerror "You can try git installation mode, i.e.: sh ${__ScriptName} git v2016.3.0" elif [ "$DPKG_ARCHITECTURE" != "amd64" ]; then echoerror "repo.saltstack.com doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." echoerror "Try git installation mode and disable SaltStack apt repository, for example:" echoerror " sh ${__ScriptName} -r -P git v2016.3.0" + exit 1 fi @@ -2863,6 +2868,7 @@ install_debian_8_deps() { wget $_WGET_ARGS -q "$SALTSTACK_DEBIAN_URL/SALTSTACK-GPG-KEY.pub" -O - | apt-key add - || return 1 elif [ -n "$STABLE_REV" ]; then echoerror "Installation of Salt ${STABLE_REV#*/} packages not supported by ${__ScriptName} ${__ScriptVersion} on Debian $DISTRO_MAJOR_VERSION." + return 1 fi fi @@ -3077,7 +3083,7 @@ install_debian_git_post() { } install_debian_restart_daemons() { - [ "$_START_DAEMONS" -eq $BS_FALSE ] && return + [ "$_START_DAEMONS" -eq $BS_FALSE ] && return 0 for fname in minion master syndic api; do # Skip salt-api since the service should be opt-in and not necessarily started on boot @@ -6409,4 +6415,5 @@ if [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then else echoinfo "Salt configured" fi + exit 0 From e117569922a6ed9ee0fa23b7a401cc50369a9a25 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Wed, 15 Jun 2016 16:03:52 +0300 Subject: [PATCH 08/30] Debian: add python-psutil to deps (required for 2016.3) --- bootstrap-salt.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index efd5cd1..7c85e25 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -1169,7 +1169,7 @@ __gather_system_info() { # DESCRIPTION: Determine primary architecture for packages to install on Debian and derivatives #---------------------------------------------------------------------------------------------------------------------- __get_dpkg_architecture() { - if ! __check_command_exists dpkg; then + if __check_command_exists dpkg; then DPKG_ARCHITECTURE="$(dpkg --print-architecture)" else echoerror "dpkg: command not found." @@ -2793,7 +2793,7 @@ install_debian_7_deps() { apt-get update || return 1 - __PACKAGES="libzmq3 libzmq3-dev python-zmq python-requests python-apt" + __PACKAGES="libzmq3 libzmq3-dev python-zmq python-requests python-apt python-psutil" # Additionally install procps and pciutils which allows for Docker bootstraps. See 366#issuecomment-39666813 __PACKAGES="${__PACKAGES} procps pciutils" @@ -2875,7 +2875,7 @@ install_debian_8_deps() { apt-get update || return 1 - __PACKAGES="libzmq3 libzmq3-dev python-zmq python-requests python-apt" + __PACKAGES="libzmq3 libzmq3-dev python-zmq python-requests python-apt python-psutil" # Additionally install procps and pciutils which allows for Docker bootstraps. See 366#issuecomment-39666813 __PACKAGES="${__PACKAGES} procps pciutils" From e96c58ea4dcc46affc7f5d575e06755083659456 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Wed, 15 Jun 2016 17:54:53 +0300 Subject: [PATCH 09/30] Create default logs directory which is absent after git installations --- bootstrap-salt.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 7c85e25..355f50d 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -6007,6 +6007,10 @@ config_salt() { echowarn "No configuration or keys were copied over. No configuration was done!" exit 0 fi + + # Create default logs directory if not exists (happens with git installations) + mkdir -p /var/log/salt + return 0 } # From 50989170938471a094385618cf339ebe1e5a0092 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Fri, 24 Jun 2016 10:45:35 +0300 Subject: [PATCH 10/30] Fix `-X` and `-d` options to do what they exactly supposed to do --- bootstrap-salt.sh | 120 +++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 70 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 355f50d..b09a06c 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -204,6 +204,7 @@ _INSTALL_MINION=$BS_TRUE _INSTALL_CLOUD=$BS_FALSE _VIRTUALENV_DIR=${BS_VIRTUALENV_DIR:-"null"} _START_DAEMONS=$BS_TRUE +_DISABLE_SALT_CHECKS=$BS_FALSE _ECHO_DEBUG=${BS_ECHO_DEBUG:-$BS_FALSE} _CONFIG_ONLY=$BS_FALSE _PIP_ALLOWED=${BS_PIP_ALLOWED:-$BS_FALSE} @@ -228,7 +229,6 @@ _SIMPLIFY_VERSION=$BS_TRUE _LIBCLOUD_MIN_VERSION="0.14.0" _EXTRA_PACKAGES="" _HTTP_PROXY="" -_DISABLE_SALT_CHECKS=$BS_FALSE _SALT_GIT_CHECKOUT_DIR=${BS_SALT_GIT_CHECKOUT_DIR:-/tmp/git/salt} _NO_DEPS=$BS_FALSE _FORCE_SHALLOW_CLONE=$BS_FALSE @@ -295,10 +295,9 @@ __usage() { -S Also install salt-syndic -N Do not install salt-minion -X Do not start daemons after installation - -d Disable check_service functions. Setting this flag disables the - 'install__check_services' checks. You can also do this by - touching /tmp/disable_salt_checks on the target host. - Default: \${BS_FALSE} + -d Disables checking if Salt services are enabled to start on system boot. + You can also do this by touching /tmp/disable_salt_checks on the target + host. Default: \${BS_FALSE} -C Only run the configuration function. This option automatically bypasses any installation. Implies -F (forced overwrite). To overwrite master or syndic configs, -M or -S, respectively, must also be specified. @@ -612,9 +611,10 @@ if [ "${CALLER}x" = "${0}x" ]; then 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" +if [ ${_DISABLE_SALT_CHECKS} -eq $BS_FALSE ] && [ -f /tmp/disable_salt_checks ]; then + # shellcheck disable=SC2016 + echowarn 'Found file: /tmp/disable_salt_checks, setting _DISABLE_SALT_CHECKS=$BS_TRUE' + _DISABLE_SALT_CHECKS=$BS_TRUE fi # Because -a can only be installed into virtualenv @@ -1555,7 +1555,7 @@ __git_clone_and_checkout() { # We need to add the saltstack repository as a remote and fetch tags for proper versioning echoinfo "Adding SaltStack's Salt repository as a remote" git remote add upstream "$_SALTSTACK_REPO_URL" || return 1 - echodebug "Fetching upstream(SaltStack's Salt repository) git tags" + echodebug "Fetching upstream (SaltStack's Salt repository) git tags" git fetch --tags upstream || return 1 GIT_REV="origin/$GIT_REV" fi @@ -1727,7 +1727,7 @@ __copyfile() { # If the destination is a directory, let's make it a full path so the logic # below works as expected if [ -d "$dfile" ]; then - echodebug "The passed destination($dfile) is a directory" + echodebug "The passed destination ($dfile) is a directory" dfile="${dfile}/$(basename "$sfile")" echodebug "Full destination path is now: $dfile" fi @@ -6058,7 +6058,7 @@ preseed_master() { # This function checks if all of the installed daemons are running or not. # daemons_running() { - [ "$_START_DAEMONS" -eq $BS_FALSE ] && return + [ "$_START_DAEMONS" -eq $BS_FALSE ] && return 0 FAILED_DAEMONS=0 for fname in minion master syndic api; do @@ -6068,7 +6068,6 @@ daemons_running() { # Skip if not meant to be installed [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - #[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue # shellcheck disable=SC2009 @@ -6092,9 +6091,9 @@ daemons_running() { #====================================================================================================================== # LET'S PROCEED WITH OUR INSTALLATION #====================================================================================================================== -# Let's get the dependencies install function -if [ "$_NO_DEPS" -eq $BS_FALSE ]; then +# Let's get the dependencies install function +if [ ${_NO_DEPS} -eq $BS_FALSE ]; then DEP_FUNC_NAMES="install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}_deps" DEP_FUNC_NAMES="$DEP_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}_deps" DEP_FUNC_NAMES="$DEP_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_deps" @@ -6117,45 +6116,39 @@ done echodebug "DEPS_INSTALL_FUNC=${DEPS_INSTALL_FUNC}" # Let's get the minion config function +CONFIG_FUNC_NAMES="config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}_salt" +CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}_salt" +CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_salt" +CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_salt" +CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}_${ITYPE}_salt" +CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}_salt" +CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_salt" + CONFIG_SALT_FUNC="null" -if [ "$_TEMP_CONFIG_DIR" != "null" ]; then - - CONFIG_FUNC_NAMES="config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}_salt" - CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}_salt" - CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_salt" - CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_salt" - CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}_${ITYPE}_salt" - CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}_salt" - CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_salt" - - for FUNC_NAME in $(__strip_duplicates "$CONFIG_FUNC_NAMES"); do - if __function_defined "$FUNC_NAME"; then - CONFIG_SALT_FUNC="$FUNC_NAME" - break - fi - done -fi +for FUNC_NAME in $(__strip_duplicates "$CONFIG_FUNC_NAMES"); do + if __function_defined "$FUNC_NAME"; then + CONFIG_SALT_FUNC="$FUNC_NAME" + break + fi +done echodebug "CONFIG_SALT_FUNC=${CONFIG_SALT_FUNC}" # Let's get the pre-seed master function +PRESEED_FUNC_NAMES="preseed_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}_master" +PRESEED_FUNC_NAMES="$PRESEED_FUNC_NAMES preseed_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}_master" +PRESEED_FUNC_NAMES="$PRESEED_FUNC_NAMES preseed_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_master" +PRESEED_FUNC_NAMES="$PRESEED_FUNC_NAMES preseed_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_master" +PRESEED_FUNC_NAMES="$PRESEED_FUNC_NAMES preseed_${DISTRO_NAME_L}_${ITYPE}_master" +PRESEED_FUNC_NAMES="$PRESEED_FUNC_NAMES preseed_${DISTRO_NAME_L}_master" +PRESEED_FUNC_NAMES="$PRESEED_FUNC_NAMES preseed_master" + PRESEED_MASTER_FUNC="null" -if [ "$_TEMP_KEYS_DIR" != "null" ]; then - - PRESEED_FUNC_NAMES="preseed_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}_master" - PRESEED_FUNC_NAMES="$PRESEED_FUNC_NAMES preseed_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}_master" - PRESEED_FUNC_NAMES="$PRESEED_FUNC_NAMES preseed_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_master" - PRESEED_FUNC_NAMES="$PRESEED_FUNC_NAMES preseed_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_master" - PRESEED_FUNC_NAMES="$PRESEED_FUNC_NAMES preseed_${DISTRO_NAME_L}_${ITYPE}_master" - PRESEED_FUNC_NAMES="$PRESEED_FUNC_NAMES preseed_${DISTRO_NAME_L}_master" - PRESEED_FUNC_NAMES="$PRESEED_FUNC_NAMES preseed_master" - - for FUNC_NAME in $(__strip_duplicates "$PRESEED_FUNC_NAMES"); do - if __function_defined "$FUNC_NAME"; then - PRESEED_MASTER_FUNC="$FUNC_NAME" - break - fi - done -fi +for FUNC_NAME in $(__strip_duplicates "$PRESEED_FUNC_NAMES"); do + if __function_defined "$FUNC_NAME"; then + PRESEED_MASTER_FUNC="$FUNC_NAME" + break + fi +done echodebug "PRESEED_MASTER_FUNC=${PRESEED_MASTER_FUNC}" # Let's get the install function @@ -6189,7 +6182,6 @@ for FUNC_NAME in $(__strip_duplicates "$POST_FUNC_NAMES"); do done echodebug "POST_INSTALL_FUNC=${POST_INSTALL_FUNC}" - # Let's get the start daemons install function STARTDAEMONS_FUNC_NAMES="install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}_restart_daemons" STARTDAEMONS_FUNC_NAMES="$STARTDAEMONS_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}_restart_daemons" @@ -6207,9 +6199,7 @@ for FUNC_NAME in $(__strip_duplicates "$STARTDAEMONS_FUNC_NAMES"); do done echodebug "STARTDAEMONS_INSTALL_FUNC=${STARTDAEMONS_INSTALL_FUNC}" - # Let's get the daemons running check function. -DAEMONS_RUNNING_FUNC="null" DAEMONS_RUNNING_FUNC_NAMES="daemons_running_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}" DAEMONS_RUNNING_FUNC_NAMES="$DAEMONS_RUNNING_FUNC_NAMES daemons_running_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}" DAEMONS_RUNNING_FUNC_NAMES="$DAEMONS_RUNNING_FUNC_NAMES daemons_running_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}" @@ -6218,6 +6208,7 @@ DAEMONS_RUNNING_FUNC_NAMES="$DAEMONS_RUNNING_FUNC_NAMES daemons_running_${DISTRO DAEMONS_RUNNING_FUNC_NAMES="$DAEMONS_RUNNING_FUNC_NAMES daemons_running_${DISTRO_NAME_L}" DAEMONS_RUNNING_FUNC_NAMES="$DAEMONS_RUNNING_FUNC_NAMES daemons_running" +DAEMONS_RUNNING_FUNC="null" for FUNC_NAME in $(__strip_duplicates "$DAEMONS_RUNNING_FUNC_NAMES"); do if __function_defined "$FUNC_NAME"; then DAEMONS_RUNNING_FUNC="$FUNC_NAME" @@ -6235,8 +6226,7 @@ if [ ${_DISABLE_SALT_CHECKS} -eq $BS_FALSE ]; then 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" + CHECK_SERVICES_FUNC_NAMES="" fi CHECK_SERVICES_FUNC="null" @@ -6248,7 +6238,6 @@ for FUNC_NAME in $(__strip_duplicates "$CHECK_SERVICES_FUNC_NAMES"); do done echodebug "CHECK_SERVICES_FUNC=${CHECK_SERVICES_FUNC}" - if [ "$DEPS_INSTALL_FUNC" = "null" ]; then echoerror "No dependencies installation function found. Exiting..." exit 1 @@ -6259,7 +6248,6 @@ if [ "$INSTALL_FUNC" = "null" ]; then exit 1 fi - # Install dependencies if [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then # Only execute function is not in config mode only @@ -6271,17 +6259,15 @@ if [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then fi fi - # Triggering config_salt() if overwriting master or minion configs if [ "$_CUSTOM_MASTER_CONFIG" != "null" ] || [ "$_CUSTOM_MINION_CONFIG" != "null" ]; then if [ "$_TEMP_CONFIG_DIR" = "null" ]; then _TEMP_CONFIG_DIR="$_SALT_ETC_DIR" fi - CONFIG_SALT_FUNC="config_salt" fi # Configure Salt -if [ "$_TEMP_CONFIG_DIR" != "null" ] && [ "$CONFIG_SALT_FUNC" != "null" ]; then +if [ "$CONFIG_SALT_FUNC" != "null" ] && [ "$_TEMP_CONFIG_DIR" != "null" ]; then echoinfo "Running ${CONFIG_SALT_FUNC}()" $CONFIG_SALT_FUNC if [ $? -ne 0 ]; then @@ -6290,9 +6276,8 @@ if [ "$_TEMP_CONFIG_DIR" != "null" ] && [ "$CONFIG_SALT_FUNC" != "null" ]; then fi fi - # Pre-Seed master keys -if [ "$_TEMP_KEYS_DIR" != "null" ] && [ "$PRESEED_MASTER_FUNC" != "null" ]; then +if [ "$PRESEED_MASTER_FUNC" != "null" ] && [ "$_TEMP_KEYS_DIR" != "null" ]; then echoinfo "Running ${PRESEED_MASTER_FUNC}()" $PRESEED_MASTER_FUNC if [ $? -ne 0 ]; then @@ -6301,7 +6286,6 @@ if [ "$_TEMP_KEYS_DIR" != "null" ] && [ "$PRESEED_MASTER_FUNC" != "null" ]; then fi fi - # Install Salt if [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then # Only execute function is not in config mode only @@ -6337,7 +6321,7 @@ if [ "$_SALT_MINION_ID" != "null" ]; then fi # Run any post install function. Only execute function if not in config mode only -if [ "$_CONFIG_ONLY" -eq $BS_FALSE ] && [ "$POST_INSTALL_FUNC" != "null" ]; then +if [ "$POST_INSTALL_FUNC" != "null" ] && [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then echoinfo "Running ${POST_INSTALL_FUNC}()" $POST_INSTALL_FUNC if [ $? -ne 0 ]; then @@ -6347,7 +6331,7 @@ if [ "$_CONFIG_ONLY" -eq $BS_FALSE ] && [ "$POST_INSTALL_FUNC" != "null" ]; then fi # Run any check services function, Only execute function if not in config mode only -if [ "$_CONFIG_ONLY" -eq $BS_FALSE ] && [ "$CHECK_SERVICES_FUNC" != "null" ]; then +if [ "$CHECK_SERVICES_FUNC" != "null" ] && [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then echoinfo "Running ${CHECK_SERVICES_FUNC}()" $CHECK_SERVICES_FUNC if [ $? -ne 0 ]; then @@ -6356,9 +6340,8 @@ if [ "$_CONFIG_ONLY" -eq $BS_FALSE ] && [ "$CHECK_SERVICES_FUNC" != "null" ]; th fi fi - # Run any start daemons function -if [ "$STARTDAEMONS_INSTALL_FUNC" != "null" ]; then +if [ "$STARTDAEMONS_INSTALL_FUNC" != "null" ] && [ ${_START_DAEMONS} -eq $BS_TRUE ]; then echoinfo "Running ${STARTDAEMONS_INSTALL_FUNC}()" echodebug "Waiting ${_SLEEP} seconds for processes to settle before checking for them" sleep ${_SLEEP} @@ -6370,7 +6353,7 @@ if [ "$STARTDAEMONS_INSTALL_FUNC" != "null" ]; then fi # Check if the installed daemons are running or not -if [ "$DAEMONS_RUNNING_FUNC" != "null" ] && [ $_START_DAEMONS -eq $BS_TRUE ]; then +if [ "$DAEMONS_RUNNING_FUNC" != "null" ] && [ ${_START_DAEMONS} -eq $BS_TRUE ]; then echoinfo "Running ${DAEMONS_RUNNING_FUNC}()" echodebug "Waiting ${_SLEEP} seconds for processes to settle before checking for them" sleep ${_SLEEP} # Sleep a little bit to let daemons start @@ -6385,7 +6368,6 @@ if [ "$DAEMONS_RUNNING_FUNC" != "null" ] && [ $_START_DAEMONS -eq $BS_TRUE ]; th # Skip if not meant to be installed [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - #[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ "$_ECHO_DEBUG" -eq $BS_FALSE ]; then @@ -6393,7 +6375,6 @@ if [ "$DAEMONS_RUNNING_FUNC" != "null" ] && [ $_START_DAEMONS -eq $BS_TRUE ]; th continue fi - [ ! -f "$_SALT_ETC_DIR/$fname" ] && [ $fname != "syndic" ] && echodebug "$_SALT_ETC_DIR/$fname does not exist" echodebug "Running salt-$fname by hand outputs: $(nohup salt-$fname -l debug)" @@ -6412,12 +6393,11 @@ if [ "$DAEMONS_RUNNING_FUNC" != "null" ] && [ $_START_DAEMONS -eq $BS_TRUE ]; th fi fi - # Done! if [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then echoinfo "Salt installed!" else - echoinfo "Salt configured" + echoinfo "Salt configured!" fi exit 0 From acba493c41f85f3b8cad57c817ec811ba570770a Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Thu, 30 Jun 2016 17:41:54 +0300 Subject: [PATCH 11/30] Debian: install majority of Salt dependencies for git mode only. Apt should resolve and install all deps for Salt packages --- bootstrap-salt.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index b09a06c..a095666 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -2793,9 +2793,8 @@ install_debian_7_deps() { apt-get update || return 1 - __PACKAGES="libzmq3 libzmq3-dev python-zmq python-requests python-apt python-psutil" # Additionally install procps and pciutils which allows for Docker bootstraps. See 366#issuecomment-39666813 - __PACKAGES="${__PACKAGES} procps pciutils" + __PACKAGES='procps pciutils' if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then # Install python-libcloud if asked to @@ -2875,9 +2874,8 @@ install_debian_8_deps() { apt-get update || return 1 - __PACKAGES="libzmq3 libzmq3-dev python-zmq python-requests python-apt python-psutil" # Additionally install procps and pciutils which allows for Docker bootstraps. See 366#issuecomment-39666813 - __PACKAGES="${__PACKAGES} procps pciutils" + __PACKAGES='procps pciutils' if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then # Install python-libcloud if asked to @@ -2908,8 +2906,9 @@ install_debian_git_deps() { __git_clone_and_checkout || return 1 # shellcheck disable=SC2086 - __apt_get_install_noinput lsb-release python-backports.ssl-match-hostname python-crypto python-jinja2 \ - python-m2crypto python-msgpack python-tornado python-yaml || return 1 + __apt_get_install_noinput libzmq3 libzmq3-dev lsb-release python-apt python-backports.ssl-match-hostname \ + python-crypto python-jinja2 python-m2crypto python-msgpack python-requests python-tornado python-yaml \ + python-zmq || return 1 # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then @@ -2936,7 +2935,7 @@ install_debian_8_git_deps() { __git_clone_and_checkout || return 1 - __PACKAGES='lsb-release python-crypto python-jinja2 python-m2crypto python-msgpack python-yaml' + __PACKAGES='libzmq3 libzmq3-dev lsb-release python-apt python-crypto python-jinja2 python-m2crypto python-msgpack python-requests python-yaml python-zmq' __PIP_PACKAGES='' if (__check_pip_allowed >/dev/null 2>&1); then From 1f128dd8126883a2321459aaa2f6d5528cc2fe6e Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Mon, 11 Jul 2016 14:16:48 +0300 Subject: [PATCH 12/30] Set STABLE_REV variable to "latest" early, properly fixes git bootstraps --- bootstrap-salt.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index a095666..92d220d 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -265,13 +265,13 @@ __usage() { - ${__ScriptName} - ${__ScriptName} stable - ${__ScriptName} stable 2016.3 - - ${__ScriptName} stable 2016.3.0 + - ${__ScriptName} stable 2016.3.1 - ${__ScriptName} daily - ${__ScriptName} testing - ${__ScriptName} git - ${__ScriptName} git 2016.3 - - ${__ScriptName} git v2016.3.0 - - ${__ScriptName} git 11acecc43e2c2e4e9a0e73d76b46b035afe8d538 + - ${__ScriptName} git v2016.3.1 + - ${__ScriptName} git 06f249901a2e2f1ed310d58ea3921a129f214358 Options: -h Display this message @@ -520,7 +520,7 @@ if [ "$ITYPE" = "git" ]; then fi # Disable shell warning about unbound variable during git install - STABLE_REV="" + STABLE_REV="latest" # If doing stable install, check if version specified elif [ "$ITYPE" = "stable" ]; then @@ -2361,6 +2361,7 @@ install_ubuntu_stable_deps() { echoerror "repo.saltstack.com likely doesn't have all required 32-bit packages for Ubuntu $DISTRO_MAJOR_VERSION (yet?)." elif [ "$DPKG_ARCHITECTURE" != "amd64" ]; then echoerror "repo.saltstack.com doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." + echoerror "You can try git installation mode, i.e.: sh ${__ScriptName} git v2016.3.1" exit 1 fi @@ -2762,7 +2763,7 @@ install_debian_7_deps() { if [ "$DPKG_ARCHITECTURE" = "i386" ]; then echoerror "repo.saltstack.com likely doesn't have all required 32-bit packages for Debian $DISTRO_MAJOR_VERSION (yet?)." - echoerror "You can try git installation mode, i.e.: sh ${__ScriptName} git v2016.3.0" + echoerror "You can try git installation mode, i.e.: sh ${__ScriptName} git v2016.3.1" elif [ "$DPKG_ARCHITECTURE" != "amd64" ]; then echoerror "repo.saltstack.com doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." @@ -2843,7 +2844,7 @@ install_debian_8_deps() { if [ "$DPKG_ARCHITECTURE" = "i386" ]; then echoerror "repo.saltstack.com likely doesn't have all required 32-bit packages for Debian $DISTRO_MAJOR_VERSION (yet?)." - echoerror "You can try git installation mode, i.e.: sh ${__ScriptName} git v2016.3.0" + echoerror "You can try git installation mode, i.e.: sh ${__ScriptName} git v2016.3.1" elif [ "$DPKG_ARCHITECTURE" != "amd64" ]; then echoerror "repo.saltstack.com doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." echoerror "Try git installation mode and disable SaltStack apt repository, for example:" From 0b48f3b32f4df8389140230264c12b38851b2957 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Thu, 14 Jul 2016 17:40:13 +0300 Subject: [PATCH 13/30] Handle `armhf` arch SaltStack repository for Debian/Raspbian --- bootstrap-salt.sh | 56 +++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 92d220d..a84eaa5 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -2357,19 +2357,26 @@ install_ubuntu_stable_deps() { if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then __get_dpkg_architecture || return 1 + __REPO_ARCH="$DPKG_ARCHITECTURE" + if [ "$DPKG_ARCHITECTURE" = "i386" ]; then echoerror "repo.saltstack.com likely doesn't have all required 32-bit packages for Ubuntu $DISTRO_MAJOR_VERSION (yet?)." + + # amd64 is just a part of repository URI, 32-bit pkgs are hosted under the same location + __REPO_ARCH="amd64" elif [ "$DPKG_ARCHITECTURE" != "amd64" ]; then echoerror "repo.saltstack.com doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." - echoerror "You can try git installation mode, i.e.: sh ${__ScriptName} git v2016.3.1" - exit 1 + if [ "$ITYPE" != "git" ]; then + echoerror "You can try git installation mode, i.e.: sh ${__ScriptName} git v2016.3.1" + exit 1 + fi fi # Versions starting with 2015.5.6 and 2015.8.1 are hosted at repo.saltstack.com if [ "$(echo "$STABLE_REV" | egrep '^(2015\.5|2015\.8|2016\.3|latest|archive\/)')" != "" ]; then # Workaround for latest non-LTS ubuntu if [ "$DISTRO_MAJOR_VERSION" -eq 15 ]; then - echowarn "Non-LTS Ubuntu detected, but stable packages requested. Trying packages from latest LTS release. You may experience problems" + echowarn "Non-LTS Ubuntu detected, but stable packages requested. Trying packages from latest LTS release. You may experience problems." UBUNTU_VERSION=14.04 UBUNTU_CODENAME=trusty else @@ -2378,8 +2385,7 @@ install_ubuntu_stable_deps() { fi # SaltStack's stable Ubuntu repository: - # amd64 is is just a part of repository URI, 32-bit pkgs are hosted under the same location - SALTSTACK_UBUNTU_URL="${HTTP_VAL}://repo.saltstack.com/apt/ubuntu/$UBUNTU_VERSION/amd64/$STABLE_REV" + SALTSTACK_UBUNTU_URL="${HTTP_VAL}://repo.saltstack.com/apt/ubuntu/${UBUNTU_VERSION}/${__REPO_ARCH}/${STABLE_REV}" if [ "$(grep -ER 'latest .+ main' /etc/apt)" = "" ]; then set +o nounset @@ -2761,20 +2767,26 @@ install_debian_7_deps() { if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then __get_dpkg_architecture || return 1 + __REPO_ARCH="$DPKG_ARCHITECTURE" + if [ "$DPKG_ARCHITECTURE" = "i386" ]; then echoerror "repo.saltstack.com likely doesn't have all required 32-bit packages for Debian $DISTRO_MAJOR_VERSION (yet?)." - echoerror "You can try git installation mode, i.e.: sh ${__ScriptName} git v2016.3.1" + + if [ "$ITYPE" != "git" ]; then + echoerror "You can try git installation mode, i.e.: sh ${__ScriptName} git v2016.3.1" + fi + + # amd64 is just a part of repository URI, 32-bit pkgs are hosted under the same location + __REPO_ARCH="amd64" elif [ "$DPKG_ARCHITECTURE" != "amd64" ]; then echoerror "repo.saltstack.com doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." - exit 1 fi # Versions starting with 2015.8.7 and 2016.3.0 are hosted at repo.saltstack.com - if [ "$(echo "$STABLE_REV" | egrep '^(2015\.8|2016\.3|latest|archive\/201[5-6]\.)')" != "" ] || \ - [ "$ITYPE" = "git" ]; then - # amd64 is is just a part of repository URI, 32-bit pkgs are hosted under the same location - SALTSTACK_DEBIAN_URL="${HTTP_VAL}://repo.saltstack.com/apt/debian/$DISTRO_MAJOR_VERSION/amd64/${STABLE_REV:-latest}" + if [ "$(echo "$STABLE_REV" | egrep '^(2015\.8|2016\.3|latest|archive\/201[5-6]\.)')" != "" ]; then + # amd64 is just a part of repository URI, 32-bit pkgs are hosted under the same location + SALTSTACK_DEBIAN_URL="${HTTP_VAL}://repo.saltstack.com/apt/debian/${DISTRO_MAJOR_VERSION}/${__REPO_ARCH}/${STABLE_REV}" echo "deb $SALTSTACK_DEBIAN_URL wheezy main" > "/etc/apt/sources.list.d/saltstack.list" if [ "$HTTP_VAL" = "https" ] ; then @@ -2842,22 +2854,28 @@ install_debian_8_deps() { if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then __get_dpkg_architecture || return 1 + __REPO_ARCH="$DPKG_ARCHITECTURE" + if [ "$DPKG_ARCHITECTURE" = "i386" ]; then echoerror "repo.saltstack.com likely doesn't have all required 32-bit packages for Debian $DISTRO_MAJOR_VERSION (yet?)." - echoerror "You can try git installation mode, i.e.: sh ${__ScriptName} git v2016.3.1" - elif [ "$DPKG_ARCHITECTURE" != "amd64" ]; then + + if [ "$ITYPE" != "git" ]; then + echoerror "You can try git installation mode, i.e.: sh ${__ScriptName} git v2016.3.1" + fi + + # amd64 is just a part of repository URI, 32-bit pkgs are hosted under the same location + __REPO_ARCH="amd64" + elif [ "$DPKG_ARCHITECTURE" != "amd64" ] && [ "$DPKG_ARCHITECTURE" != "armhf" ]; then echoerror "repo.saltstack.com doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." - echoerror "Try git installation mode and disable SaltStack apt repository, for example:" - echoerror " sh ${__ScriptName} -r -P git v2016.3.0" + echoerror "Try git installation mode with pip and disable SaltStack apt repository, for example:" + echoerror " sh ${__ScriptName} -r -P git v2016.3.1" exit 1 fi # Versions starting with 2015.5.6, 2015.8.1 and 2016.3.0 are hosted at repo.saltstack.com - if [ "$(echo "$STABLE_REV" | egrep '^(2015\.5|2015\.8|2016\.3|latest|archive\/201[5-6]\.)')" != "" ] || \ - [ "$ITYPE" = "git" ]; then - # amd64 is is just a part of repository URI, 32-bit pkgs are hosted under the same location - SALTSTACK_DEBIAN_URL="${HTTP_VAL}://repo.saltstack.com/apt/debian/$DISTRO_MAJOR_VERSION/amd64/${STABLE_REV:-latest}" + if [ "$(echo "$STABLE_REV" | egrep '^(2015\.5|2015\.8|2016\.3|latest|archive\/201[5-6]\.)')" != "" ]; then + SALTSTACK_DEBIAN_URL="${HTTP_VAL}://repo.saltstack.com/apt/debian/${DISTRO_MAJOR_VERSION}/${__REPO_ARCH}/${STABLE_REV}" echo "deb $SALTSTACK_DEBIAN_URL jessie main" > "/etc/apt/sources.list.d/saltstack.list" if [ "$HTTP_VAL" = "https" ] ; then From 6491abd05d580bef2fe19327251588aeb28c9d0d Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Thu, 14 Jul 2016 18:18:34 +0300 Subject: [PATCH 14/30] Update README about supported architectures on Debian 8 --- README.rst | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index b136cde..33e7763 100644 --- a/README.rst +++ b/README.rst @@ -211,12 +211,19 @@ Debian and derivatives - Debian GNU/Linux 7/8 - Linux Mint Debian Edition 1 (based on Debian 8) - Kali Linux 1.0 (based on Debian 7) +- Raspbian 8 (limited support for ``armhf`` architecture, see the note below) .. note:: - Installation of Salt packages on Debian distribution from repo.saltstack.com repository is - currently supported for ``amd64`` (``x86-64``) architechture ONLY. Use ``git`` bootstrap - mode as mentioned above to install Salt on other architechtures, such as ``i386`` or ``armel``. + Installation of Salt packages on Debian 8 based distribution from repo.saltstack.com repository + is currently supported for ``amd64`` (``x86-64``) and ``armhf`` architechtures ONLY. Use ``git`` + bootstrap mode as described above to install Salt on other architechtures, such as ``i386`` or + ``armel``. You also may need to disable repository configuration and allow ``pip`` installations + by providing ``-r`` and ``-P`` options to the bootstrap script, i.e.: + + .. code:: console + + wget -O - https://bootstrap.saltstack.com | sudo sh -s -- -r -P git develop Red Hat family @@ -293,7 +300,6 @@ are not developed yet: **Linux**: -- Raspbian (detected as Debian) - Slackware **SunOS** From eae188d5740c98edf0c3f43fec40d896ef76b70a Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Mon, 18 Jul 2016 13:46:35 +0300 Subject: [PATCH 15/30] Fix bootstrapping from Git on CentOS7 when `systemd` is not running e.g. during the build process of container/VM images --- bootstrap-salt.sh | 71 +++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index a84eaa5..34a4c5f 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -3569,29 +3569,34 @@ install_centos_stable() { } install_centos_stable_post() { - for fname in minion master syndic api; do - # Skip if not meant to be installed + SYSTEMD_RELOAD=$BS_FALSE + + for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot [ $fname = "api" ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + # Skip if not meant to be installed [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - #[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue - if [ -f /etc/init.d/salt-$fname ]; then - # Still in SysV init!? - /sbin/chkconfig salt-$fname on - elif [ -f /usr/bin/systemctl ]; then - # Using systemd - /usr/bin/systemctl is-enabled salt-$fname.service > /dev/null 2>&1 || ( - /usr/bin/systemctl preset salt-$fname.service > /dev/null 2>&1 && - /usr/bin/systemctl enable salt-$fname.service > /dev/null 2>&1 + if [ -f /bin/systemctl ]; then + /usr/systemctl is-enabled salt-${fname}.service > /dev/null 2>&1 || ( + /bin/systemctl preset salt-${fname}.service > /dev/null 2>&1 && + /bin/systemctl enable salt-${fname}.service > /dev/null 2>&1 ) - sleep 0.1 - /usr/bin/systemctl daemon-reload + + SYSTEMD_RELOAD=$BS_TRUE + elif [ -f "/etc/init.d/salt-${fname}" ]; then + /sbin/chkconfig salt-${fname} on fi done + + if [ "$SYSTEMD_RELOAD" -eq $BS_TRUE ]; then + /bin/systemctl daemon-reload + fi + + return 0 } install_centos_git_deps() { @@ -3653,53 +3658,54 @@ install_centos_git() { install_centos_git_post() { SYSTEMD_RELOAD=$BS_FALSE - for fname in minion master syndic api; do + + for fname in api master minion syndic; do + # Skip salt-api since the service should be opt-in and not necessarily started on boot + [ $fname = "api" ] && continue # Skip if not meant to be installed - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /bin/systemctl ]; then - if [ ! -f /usr/lib/systemd/system/salt-${fname}.service ] || ([ -f /usr/lib/systemd/system/salt-${fname}.service ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ]); then + if [ ! -f "/usr/lib/systemd/system/salt-${fname}.service" ] || \ + ([ -f "/usr/lib/systemd/system/salt-${fname}.service" ] && [ "$_FORCE_OVERWRITE" -eq $BS_TRUE ]); then __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-${fname}.service" /usr/lib/systemd/system/ fi - # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue + /usr/systemctl is-enabled salt-${fname}.service > /dev/null 2>&1 || ( + /bin/systemctl preset salt-${fname}.service > /dev/null 2>&1 && + /bin/systemctl enable salt-${fname}.service > /dev/null 2>&1 + ) - /bin/systemctl enable salt-${fname}.service SYSTEMD_RELOAD=$BS_TRUE - - elif [ ! -f /etc/init.d/salt-$fname ] || ([ -f /etc/init.d/salt-$fname ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ]); then + elif [ ! -f "/etc/init.d/salt-$fname" ] || \ + ([ -f "/etc/init.d/salt-$fname" ] && [ "$_FORCE_OVERWRITE" -eq $BS_TRUE ]); then __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-${fname}" /etc/init.d/ chmod +x /etc/init.d/salt-${fname} - # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue - /sbin/chkconfig salt-${fname} on fi - done if [ "$SYSTEMD_RELOAD" -eq $BS_TRUE ]; then /bin/systemctl daemon-reload fi + + return 0 } install_centos_restart_daemons() { [ $_START_DAEMONS -eq $BS_FALSE ] && return - for fname in minion master syndic api; do - # Skip if not meant to be installed + for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot [ $fname = "api" ] && continue - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + # Skip if not meant to be installed [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - #[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /sbin/initctl ] && [ -f /etc/init/salt-${fname}.conf ]; then @@ -3747,14 +3753,13 @@ install_centos_testing_post() { } install_centos_check_services() { - for fname in minion master syndic api; do + for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot [ $fname = "api" ] && continue # Skip if not meant to be installed [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - #[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /sbin/initctl ] && [ -f /etc/init/salt-${fname}.conf ]; then __check_services_upstart salt-$fname || return 1 From 188bb22f28e4e88f4c9d0424ebb3ac9f1b36d190 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Tue, 19 Jul 2016 15:43:12 +0300 Subject: [PATCH 16/30] RHEL: install `salt-cloud` package with `-L` option in `stable` mode --- bootstrap-salt.sh | 208 ++++++++++++++++++++-------------------------- 1 file changed, 92 insertions(+), 116 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 34a4c5f..14edc31 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -291,6 +291,7 @@ __usage() { the master. -s Sleep time used when waiting for daemons to start, restart and when checking for the services running. Default: ${__DEFAULT_SLEEP} + -L Also install salt-cloud and required python-libcloud package -M Also install salt-master -S Also install salt-syndic -N Do not install salt-minion @@ -317,8 +318,6 @@ __usage() { \${BS_SALT_ETC_DIR}/minion.d/99-master-address.conf -i Pass the salt-minion id. This will be stored under \${BS_SALT_ETC_DIR}/minion_id - -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 all download URLs (including https://). @@ -1376,7 +1375,7 @@ if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then fi if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ] && [ "$_CONFIG_ONLY" -eq $BS_FALSE ]; then - echoinfo "Installing Apache-Libcloud required for salt-cloud" + echoinfo "Installing salt-cloud and required python-libcloud package" fi if [ $_START_DAEMONS -eq $BS_FALSE ]; then @@ -1588,6 +1587,22 @@ __apt_get_upgrade_noinput() { } +#--- FUNCTION ------------------------------------------------------------------------------------------------------- +# NAME: __yum_install_noinput +# DESCRIPTION: (DRY) apt-get install with noinput options +#---------------------------------------------------------------------------------------------------------------------- +__yum_install_noinput() { + if [ "$DISTRO_NAME_L" = "oracle_linux" ]; then + # We need to install one package at a time because --enablerepo=X disables ALL OTHER REPOS!!!! + for package in "${@}"; do + yum -y install "${package}" || yum -y install "${package}" --enablerepo="${_EPEL_REPO}" || return $? + done + else + yum -y install "${@}" --enablerepo=${_EPEL_REPO} || return $? + fi +} + + #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: __check_end_of_life_versions # DESCRIPTION: Check for end of life distribution versions @@ -3452,12 +3467,17 @@ __install_saltstack_copr_salt_repository() { __fetch_url "/etc/yum.repos.d/${__REPO_FILENAME}" \ "${HTTP_VAL}://copr.fedorainfracloud.org/coprs/saltstack/salt/repo/${__REPOTYPE}-${DISTRO_MAJOR_VERSION}/${__REPO_FILENAME}" || return 1 fi + return 0 } install_centos_stable_deps() { + if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then + yum -y update || return 1 + fi + if [ "$DISTRO_MAJOR_VERSION" -eq 5 ]; then - # Install curl which is not included in @core CentOS 5 installation + # Install curl which is not included in @Core CentOS 5 installation __check_command_exists curl || yum -y install "curl.${CPU_ARCH_L}" || return 1 fi @@ -3473,98 +3493,38 @@ install_centos_stable_deps() { __install_saltstack_rhel_repository || return 1 fi - if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then - # We're on the develop branch, install whichever tornado is on the requirements file - __REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")" - if [ "${__REQUIRED_TORNADO}" != "" ]; then - if [ "$DISTRO_MAJOR_VERSION" -eq 5 ]; then - yum install -y python26-tornado - else - yum install -y python-tornado - fi - fi - fi - - if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then - yum -y update || return 1 - fi - __PACKAGES="yum-utils chkconfig" - if [ "$DISTRO_MAJOR_VERSION" -eq 5 ]; then - __PACKAGES="${__PACKAGES} python26-PyYAML python26-m2crypto m2crypto python26 python26-requests" - __PACKAGES="${__PACKAGES} python26-crypto python26-msgpack python26-zmq python26-jinja2" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then - __check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" - __PACKAGES="${__PACKAGES} python26-setuptools" - fi - else - __PACKAGES="${__PACKAGES} PyYAML m2crypto python-crypto python-msgpack python-zmq python-jinja2 python-requests" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then - __check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" - __PACKAGES="${__PACKAGES} python-pip" - fi - fi - - if [ "$DISTRO_NAME_L" = "oracle_linux" ]; then - # We need to install one package at a time because --enablerepo=X disables ALL OTHER REPOS!!!! - for package in ${__PACKAGES}; do - # shellcheck disable=SC2086 - yum -y install ${package} || yum -y install ${package} --enablerepo=${_EPEL_REPO} || return 1 - done - else - # shellcheck disable=SC2086 - yum -y install ${__PACKAGES} --enablerepo=${_EPEL_REPO} || return 1 - fi - - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then - __check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" - if [ "$DISTRO_MAJOR_VERSION" -eq 5 ]; then - easy_install-2.6 "apache-libcloud>=$_LIBCLOUD_MIN_VERSION" - else - pip install "apache-libcloud>=$_LIBCLOUD_MIN_VERSION" - fi - fi - if [ "${_EXTRA_PACKAGES}" != "" ]; then - echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" - if [ "$DISTRO_NAME_L" = "oracle_linux" ]; then - # We need to install one package at a time because --enablerepo=X disables ALL OTHER REPOS!!!! - for package in ${_EXTRA_PACKAGES}; do - # shellcheck disable=SC2086 - yum -y install ${package} || yum -y install ${package} --enablerepo=${_EPEL_REPO} || return 1 - done - else - # shellcheck disable=SC2086 - yum install -y ${_EXTRA_PACKAGES} --enablerepo=${_EPEL_REPO} || return 1 - fi + echoinfo "Also installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + __PACKAGES="${__PACKAGES} ${_EXTRA_PACKAGES}" fi + # shellcheck disable=SC2086 + __yum_install_noinput ${__PACKAGES} || return 1 + return 0 } install_centos_stable() { __PACKAGES="" - if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then - __PACKAGES="${__PACKAGES} salt-minion" + + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + __PACKAGES="${__PACKAGES} salt-cloud" fi if [ "$_INSTALL_MASTER" -eq $BS_TRUE ];then __PACKAGES="${__PACKAGES} salt-master" fi + if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + __PACKAGES="${__PACKAGES} salt-minion" + fi if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ];then __PACKAGES="${__PACKAGES} salt-syndic" fi - if [ "$DISTRO_NAME_L" = "oracle_linux" ]; then - # We need to install one package at a time because --enablerepo=X disables ALL OTHER REPOS!!!! - for package in ${__PACKAGES}; do - # shellcheck disable=SC2086 - yum -y install ${package} || yum -y install ${package} --enablerepo=${_EPEL_REPO} || return 1 - done - else - # shellcheck disable=SC2086 - yum -y install ${__PACKAGES} --enablerepo=${_EPEL_REPO} || return 1 - fi + # shellcheck disable=SC2086 + __yum_install_noinput ${__PACKAGES} || return 1 + return 0 } @@ -3601,38 +3561,34 @@ install_centos_stable_post() { install_centos_git_deps() { install_centos_stable_deps || return 1 - if ! __check_command_exists git; then - # git not installed - need to install it - if [ "$DISTRO_NAME_L" = "oracle_linux" ]; then - # try both ways --enablerepo=X disables ALL OTHER REPOS!!!! - yum install -y git || yum install -y git --enablerepo=${_EPEL_REPO} || return 1 - else - yum install -y git --enablerepo=${_EPEL_REPO} || return 1 - fi - fi - if [ "$DISTRO_MAJOR_VERSION" -gt 6 ]; then - if [ "$DISTRO_NAME_L" != "oracle_linux" ]; then - yum install -y systemd-python || yum install -y systemd-python --enablerepo=${_EPEL_REPO} || return 1 - else - yum install -y systemd-python --enablerepo=${_EPEL_REPO} || return 1 - fi + if ! __check_command_exists git; then + __yum_install_noinput git || return 1 fi __git_clone_and_checkout || return 1 - if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then - # We're on the develop branch, install whichever tornado is on the requirements file - __REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")" - if [ "${__REQUIRED_TORNADO}" != "" ]; then - if [ "$DISTRO_MAJOR_VERSION" -eq 5 ]; then - yum install -y python26-tornado - else - yum install -y python-tornado - fi - fi + __PACKAGES="" + + if [ "$DISTRO_MAJOR_VERSION" -eq 5 ]; then + __PACKAGES="${__PACKAGES} python26-PyYAML python26-m2crypto m2crypto python26 python26-requests" + __PACKAGES="${__PACKAGES} python26-crypto python26-jinja2 python26-msgpack python26-tornado python26-zmq" + else + __PACKAGES="${__PACKAGES} PyYAML m2crypto python-crypto python-msgpack python-zmq python-jinja2" + __PACKAGES="${__PACKAGES} python-requests python-tornado" fi + if [ "$DISTRO_MAJOR_VERSION" -ge 7 ]; then + __PACKAGES="${__PACKAGES} systemd-python" + fi + + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + __PACKAGES="${__PACKAGES} python-libcloud" + fi + + # shellcheck disable=SC2086 + __yum_install_noinput ${__PACKAGES} || return 1 + # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then _TEMP_CONFIG_DIR="${_SALT_GIT_CHECKOUT_DIR}/conf/" @@ -3648,11 +3604,13 @@ install_centos_git() { else _PYEXE=python2 fi + if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then $_PYEXE setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install --prefix=/usr || return 1 else $_PYEXE setup.py ${SETUP_PY_INSTALL_ARGS} install --prefix=/usr || return 1 fi + return 0 } @@ -3671,7 +3629,7 @@ install_centos_git_post() { if [ -f /bin/systemctl ]; then if [ ! -f "/usr/lib/systemd/system/salt-${fname}.service" ] || \ ([ -f "/usr/lib/systemd/system/salt-${fname}.service" ] && [ "$_FORCE_OVERWRITE" -eq $BS_TRUE ]); then - __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-${fname}.service" /usr/lib/systemd/system/ + __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-${fname}.service" /usr/lib/systemd/system fi /usr/systemctl is-enabled salt-${fname}.service > /dev/null 2>&1 || ( @@ -3682,7 +3640,7 @@ install_centos_git_post() { SYSTEMD_RELOAD=$BS_TRUE elif [ ! -f "/etc/init.d/salt-$fname" ] || \ ([ -f "/etc/init.d/salt-$fname" ] && [ "$_FORCE_OVERWRITE" -eq $BS_TRUE ]); then - __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-${fname}" /etc/init.d/ + __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-${fname}" /etc/init.d chmod +x /etc/init.d/salt-${fname} /sbin/chkconfig salt-${fname} on @@ -5909,7 +5867,14 @@ config_salt() { # If the configuration directory is not passed, return [ "$_TEMP_CONFIG_DIR" = "null" ] && return - CONFIGURED_ANYTHING=$BS_FALSE + if [ "$_CONFIG_ONLY" -eq $BS_TRUE ]; then + echowarn "Passing -C (config only) option implies -F (forced overwrite)." + if [ "$_FORCE_OVERWRITE" -ne $BS_TRUE ]; then + echowarn "Overwriting configs in 11 seconds!" + sleep 11 + _FORCE_OVERWRITE=$BS_TRUE + fi + fi # Let's create the necessary directories [ -d "$_SALT_ETC_DIR" ] || mkdir "$_SALT_ETC_DIR" || return 1 @@ -5918,10 +5883,12 @@ config_salt() { # If -C or -F was passed, we don't need a .bak file for the config we're updating # This is used in the custom master/minion config file checks below CREATE_BAK=$BS_TRUE - if [ "$_CONFIG_ONLY" -eq $BS_TRUE ] || [ "$_FORCE_OVERWRITE" -eq $BS_TRUE ]; then + if [ "$_FORCE_OVERWRITE" -eq $BS_TRUE ]; then CREATE_BAK=$BS_FALSE fi + CONFIGURED_ANYTHING=$BS_FALSE + # Copy the grains file if found if [ -f "$_TEMP_CONFIG_DIR/grains" ]; then echodebug "Moving provided grains file from $_TEMP_CONFIG_DIR/grains to $_SALT_ETC_DIR/grains" @@ -5929,15 +5896,7 @@ config_salt() { CONFIGURED_ANYTHING=$BS_TRUE fi - if [ "$_CONFIG_ONLY" -eq "$BS_TRUE" ]; then - echowarn "Passing -C (config only) option implies -F (forced overwrite)." - if [ "$_FORCE_OVERWRITE" -ne "$BS_TRUE" ]; then - echowarn "Overwriting configs in 11 seconds!" - sleep 11 - fi - fi - - if [ "$_INSTALL_MINION" -eq "$BS_TRUE" ] || [ "$_CONFIG_ONLY" -eq "$BS_TRUE" ] || [ "$_CUSTOM_MINION_CONFIG" != "null" ]; then + if [ "$_INSTALL_MINION" -eq $BS_TRUE ] || [ "$_CONFIG_ONLY" -eq $BS_TRUE ] || [ "$_CUSTOM_MINION_CONFIG" != "null" ]; then # Create the PKI directory [ -d "$_PKI_DIR/minion" ] || (mkdir -p "$_PKI_DIR/minion" && chmod 700 "$_PKI_DIR/minion") || return 1 @@ -6026,6 +5985,23 @@ config_salt() { fi fi + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + # Recursively copy salt-cloud configs with overwriting if necessary + for file in "$_TEMP_CONFIG_DIR"/cloud*; do + if [ -f "$file" ]; then + __copyfile "$file" "$_SALT_ETC_DIR" + elif [ -d "$file" ]; then + subdir="$(basename "$file")" + mkdir -p "$_SALT_ETC_DIR/$subdir" + for file_d in "$_TEMP_CONFIG_DIR/$subdir"/*; do + [ -f "$file_d" ] && __copyfile "$file_d" "$_SALT_ETC_DIR/$subdir" + done + else + continue + fi + done + fi + if [ "$_CONFIG_ONLY" -eq $BS_TRUE ] && [ $CONFIGURED_ANYTHING -eq $BS_FALSE ]; then echowarn "No configuration or keys were copied over. No configuration was done!" exit 0 From 0f0e5fcd8df51d8fe54b7519f1d4db781093954b Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Fri, 22 Jul 2016 11:03:14 +0300 Subject: [PATCH 17/30] Fix git install mode when using commit hash with `-g` option --- bootstrap-salt.sh | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 34a4c5f..3c94e09 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -279,7 +279,7 @@ __usage() { -n No colours -D Show debug output -c Temporary configuration directory - -g Salt repository URL. Default: ${_SALTSTACK_REPO_URL} + -g Salt Git repository URL. Default: ${_SALTSTACK_REPO_URL} -G Instead of cloning from ${_SALTSTACK_REPO_URL}, clone from https://${_SALTSTACK_REPO_URL#*://} (usually necessary on systems which have the regular git protocol port @@ -1513,16 +1513,16 @@ __git_clone_and_checkout() { else if [ "$_FORCE_SHALLOW_CLONE" -eq "${BS_TRUE}" ]; then echoinfo "Forced shallow cloning of git repository." - __SHALLOW_CLONE="${BS_TRUE}" + __SHALLOW_CLONE=$BS_TRUE elif [ "$(echo "$GIT_REV" | sed 's/^.*\(v\?[[:digit:]]\{1,4\}\.[[:digit:]]\{1,2\}\)\(\.[[:digit:]]\{1,2\}\)\?.*$/MATCH/')" = "MATCH" ]; then echoinfo "Git revision matches a Salt version tag, shallow cloning enabled." - __SHALLOW_CLONE="${BS_TRUE}" + __SHALLOW_CLONE=$BS_TRUE else echowarn "The git revision being installed does not match a Salt version tag. Shallow cloning disabled" - __SHALLOW_CLONE="${BS_FALSE}" + __SHALLOW_CLONE=$BS_FALSE fi - if [ "$__SHALLOW_CLONE" -eq "${BS_TRUE}" ]; then + if [ "$__SHALLOW_CLONE" -eq $BS_TRUE ]; then # Let's try shallow cloning to speed up. # Test for "--single-branch" option introduced in git 1.7.10, the minimal version of git where the shallow # cloning we need actually works @@ -1533,31 +1533,37 @@ __git_clone_and_checkout() { if [ $? -eq 0 ]; then # shellcheck disable=SC2164 cd "${_SALT_GIT_CHECKOUT_DIR}" - __SHALLOW_CLONE="${BS_TRUE}" + __SHALLOW_CLONE=$BS_TRUE else # Shallow clone above failed(missing upstream tags???), let's resume the old behaviour. echowarn "Failed to shallow clone." echoinfo "Resuming regular git clone and remote SaltStack repository addition procedure" - __SHALLOW_CLONE="${BS_FALSE}" + __SHALLOW_CLONE=$BS_FALSE fi else echodebug "Shallow cloning not possible. Required git version not met." - __SHALLOW_CLONE="${BS_FALSE}" + __SHALLOW_CLONE=$BS_FALSE fi fi - if [ "$__SHALLOW_CLONE" -eq "${BS_FALSE}" ]; then + if [ "$__SHALLOW_CLONE" -eq $BS_FALSE ]; then git clone "$_SALT_REPO_URL" "$__SALT_CHECKOUT_REPONAME" || return 1 # shellcheck disable=SC2164 cd "${_SALT_GIT_CHECKOUT_DIR}" - if [ "$(echo "$_SALT_REPO_URL" | grep -c -e '\(\(git\|https\)://github\.com/\|git@github\.com:\)saltstack/salt\.git')" -eq 0 ]; then + if ! echo "$_SALT_REPO_URL" | \ + grep -q -x '\(\(git\|https\)://github\.com/\|git@github\.com:\)saltstack/salt\.git'; then # We need to add the saltstack repository as a remote and fetch tags for proper versioning echoinfo "Adding SaltStack's Salt repository as a remote" git remote add upstream "$_SALTSTACK_REPO_URL" || return 1 + echodebug "Fetching upstream (SaltStack's Salt repository) git tags" git fetch --tags upstream || return 1 - GIT_REV="origin/$GIT_REV" + + # Check if GIT_REV is a remote branch or just a commit hash + if git branch -r | grep -q -F -w "origin/$GIT_REV"; then + GIT_REV="origin/$GIT_REV" + fi fi echodebug "Checking out $GIT_REV" @@ -1565,6 +1571,7 @@ __git_clone_and_checkout() { fi fi + echoinfo "Cloning Salt's git repository succeeded" return 0 } From 9da5169ce810a82be10110d8af2d0e106b042ee6 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Mon, 1 Aug 2016 13:34:51 +0300 Subject: [PATCH 18/30] Debian: install `salt-cloud` package with `-L` option in `stable` mode --- bootstrap-salt.sh | 49 ++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 14edc31..a372f4b 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -2824,11 +2824,6 @@ install_debian_7_deps() { # Additionally install procps and pciutils which allows for Docker bootstraps. See 366#issuecomment-39666813 __PACKAGES='procps pciutils' - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then - # Install python-libcloud if asked to - __PACKAGES="${__PACKAGES} python-libcloud" - fi - # shellcheck disable=SC2086 __apt_get_install_noinput ${__PACKAGES} || return 1 @@ -2911,11 +2906,6 @@ install_debian_8_deps() { # Additionally install procps and pciutils which allows for Docker bootstraps. See 366#issuecomment-39666813 __PACKAGES='procps pciutils' - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then - # Install python-libcloud if asked to - __PACKAGES="${__PACKAGES} python-libcloud" - fi - # shellcheck disable=SC2086 __apt_get_install_noinput ${__PACKAGES} || return 1 @@ -2939,10 +2929,17 @@ install_debian_git_deps() { __git_clone_and_checkout || return 1 + __PACKAGES='libzmq3 libzmq3-dev lsb-release python-apt python-backports.ssl-match-hostname python-crypto' + __PACKAGES="${__PACKAGES} python-jinja2 python-m2crypto python-msgpack python-requests python-tornado" + __PACKAGES="${__PACKAGES} python-tornado python-yaml python-zmq" + + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + # Install python-libcloud if asked to + __PACKAGES="${__PACKAGES} python-libcloud" + fi + # shellcheck disable=SC2086 - __apt_get_install_noinput libzmq3 libzmq3-dev lsb-release python-apt python-backports.ssl-match-hostname \ - python-crypto python-jinja2 python-m2crypto python-msgpack python-requests python-tornado python-yaml \ - python-zmq || return 1 + __apt_get_install_noinput ${__PACKAGES} || return 1 # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then @@ -2970,8 +2967,13 @@ install_debian_8_git_deps() { __git_clone_and_checkout || return 1 __PACKAGES='libzmq3 libzmq3-dev lsb-release python-apt python-crypto python-jinja2 python-m2crypto python-msgpack python-requests python-yaml python-zmq' - __PIP_PACKAGES='' + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + # Install python-libcloud if asked to + __PACKAGES="${__PACKAGES} python-libcloud" + fi + + __PIP_PACKAGES='' if (__check_pip_allowed >/dev/null 2>&1); then __PIP_PACKAGES='tornado' # Install development environment for building tornado Python module @@ -3015,15 +3017,20 @@ install_debian_8_git_deps() { install_debian_stable() { __PACKAGES="" - if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then - __PACKAGES="${__PACKAGES} salt-minion" + + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + __PACKAGES="${__PACKAGES} salt-cloud" fi if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then __PACKAGES="${__PACKAGES} salt-master" fi + if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + __PACKAGES="${__PACKAGES} salt-minion" + fi if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then __PACKAGES="${__PACKAGES} salt-syndic" fi + # shellcheck disable=SC2086 __apt_get_install_noinput ${__PACKAGES} || return 1 @@ -3060,11 +3067,9 @@ install_debian_8_git() { install_debian_git_post() { for fname in minion master syndic api; do + # Skip salt-api since the service should be opt-in and not necessarily started on boot + [ $fname = "api" ] && continue - # Skip if not meant to be installed - [ "$fname" = "api" ] && \ - ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && \ - continue [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue @@ -3145,10 +3150,10 @@ install_debian_check_services() { [ $fname = "api" ] && continue # Skip if not meant to be installed - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - #[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ ! -f "/etc/init.d/salt-$fname" ]) && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + if [ -f /bin/systemctl ]; then __check_services_systemd salt-$fname || return 1 elif [ -f /etc/init.d/salt-$fname ]; then From 18c18cc279b51777ebc0ab179a58d2f2c9aa0870 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Wed, 3 Aug 2016 12:14:25 +0300 Subject: [PATCH 19/30] Ubuntu: install `salt-cloud` package with `-L` option in `stable` mode --- bootstrap-salt.sh | 54 +++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index a372f4b..7040729 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -2332,15 +2332,6 @@ install_ubuntu_deps() { # Additionally install procps and pciutils which allows for Docker bootstraps. See 366#issuecomment-39666813 __PACKAGES="${__PACKAGES} procps pciutils" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then - __check_pip_allowed "You need to allow pip based installations (-P) in order to install 'apache-libcloud'" - if ! __check_command_exists pip; then - __PACKAGES="${__PACKAGES} python-setuptools python-pip" - fi - # shellcheck disable=SC2089 - __PIP_PACKAGES="${__PIP_PACKAGES} 'apache-libcloud>=$_LIBCLOUD_MIN_VERSION'" - fi - apt-get update # shellcheck disable=SC2086,SC2090 __apt_get_install_noinput ${__PACKAGES} || return 1 @@ -2478,34 +2469,53 @@ install_ubuntu_git_deps() { __git_clone_and_checkout || return 1 __PACKAGES="" + __PIP_PACKAGES="" + # See how we are installing packages if [ ${_PIP_ALL} -eq $BS_TRUE ]; then - __PACKAGES="python-dev swig libssl-dev libzmq3 libzmq3-dev" + __PACKAGES="${__PACKAGES} python-dev swig libssl-dev libzmq3 libzmq3-dev" + if ! __check_command_exists pip; then __PACKAGES="${__PACKAGES} python-setuptools python-pip" fi + # Get just the apt packages that are required to build all the pythons - __apt_get_install_noinput "$__PACKAGES" || return 1 + # shellcheck disable=SC2086 + __apt_get_install_noinput ${__PACKAGES} || return 1 # Install the pythons from requirements (only zmq for now) __install_pip_deps "${_SALT_GIT_CHECKOUT_DIR}/requirements/zeromq.txt" || return 1 else install_ubuntu_deps || return 1 - __apt_get_install_noinput python-yaml python-m2crypto python-crypto \ - msgpack-python python-zmq python-jinja2 || return 1 + __PACKAGES="${__PACKAGES} python-yaml python-m2crypto python-crypto msgpack-python python-zmq python-jinja2" + + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + # Install python-libcloud if asked to + __PACKAGES="${__PACKAGES} python-libcloud" + fi + if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then # We're on the develop branch, install whichever tornado is on the requirements file __REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")" + if [ "${__REQUIRED_TORNADO}" != "" ]; then + __check_pip_allowed "You need to allow pip based installations (-P) in order to install the python package '${__REQUIRED_TORNADO}'" + __PACKAGES="${__PACKAGES} python-dev" - check_pip_allowed "You need to allow pip based installations (-P) in order to install the python package '${__REQUIRED_TORNADO}'" + __PIP_PACKAGES="${__PIP_PACKAGES} ${__REQUIRED_TORNADO}" + if ! __check_command_exists pip; then __PACKAGES="${__PACKAGES} python-setuptools python-pip" fi - # shellcheck disable=SC2086 - __apt_get_install_noinput $__PACKAGES || return 1 - pip install -U "${__REQUIRED_TORNADO}" fi fi + + # shellcheck disable=SC2086 + __apt_get_install_noinput ${__PACKAGES} || return 1 + + if [ "${__PIP_PACKAGES}" != "" ]; then + # shellcheck disable=SC2086,SC2090 + pip install -U ${__PIP_PACKAGES} || return 1 + fi fi # Let's trigger config_salt() @@ -2519,12 +2529,16 @@ install_ubuntu_git_deps() { install_ubuntu_stable() { __PACKAGES="" - if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then - __PACKAGES="${__PACKAGES} salt-minion" + + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + __PACKAGES="${__PACKAGES} salt-cloud" fi if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then __PACKAGES="${__PACKAGES} salt-master" fi + if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + __PACKAGES="${__PACKAGES} salt-minion" + fi if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then __PACKAGES="${__PACKAGES} salt-syndic" fi @@ -2929,7 +2943,7 @@ install_debian_git_deps() { __git_clone_and_checkout || return 1 - __PACKAGES='libzmq3 libzmq3-dev lsb-release python-apt python-backports.ssl-match-hostname python-crypto' + __PACKAGES="libzmq3 libzmq3-dev lsb-release python-apt python-backports.ssl-match-hostname python-crypto" __PACKAGES="${__PACKAGES} python-jinja2 python-m2crypto python-msgpack python-requests python-tornado" __PACKAGES="${__PACKAGES} python-tornado python-yaml python-zmq" From b4b94524a3d8d93ceffe7e05c80d5c2860494733 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Fri, 5 Aug 2016 15:43:25 +0300 Subject: [PATCH 20/30] Fedora: install `salt-cloud` package with `-L` option in `stable` mode --- bootstrap-salt.sh | 51 +++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 7040729..cc59097 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -2542,6 +2542,7 @@ install_ubuntu_stable() { if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then __PACKAGES="${__PACKAGES} salt-syndic" fi + # shellcheck disable=SC2086 __apt_get_install_noinput ${__PACKAGES} || return 1 return 0 @@ -3213,10 +3214,6 @@ install_fedora_deps() { __PACKAGES="${__PACKAGES} python-msgpack python-requests" fi - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then - __PACKAGES="${__PACKAGES} python-libcloud" - fi - # shellcheck disable=SC2086 $FEDORA_PACKAGE_MANAGER install -y ${__PACKAGES} || return 1 @@ -3236,28 +3233,36 @@ install_fedora_deps() { install_fedora_stable() { __fedora_get_package_manager __PACKAGES="" + + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + __PACKAGES="${__PACKAGES} salt-cloud" + fi + if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then + __PACKAGES="${__PACKAGES} salt-master" + fi if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then __PACKAGES="${__PACKAGES} salt-minion" fi - if [ "$_INSTALL_MASTER" -eq $BS_TRUE ] || [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then - __PACKAGES="${__PACKAGES} salt-master" + if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then + __PACKAGES="${__PACKAGES} salt-syndic" fi + # shellcheck disable=SC2086 $FEDORA_PACKAGE_MANAGER install -y ${__PACKAGES} || return 1 + return 0 } install_fedora_stable_post() { for fname in minion master syndic api; do - # Skip if not meant to be installed - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue - [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue - # Skip salt-api since the service should be opt-in and not necessarily started on boot [ $fname = "api" ] && continue + # Skip if not meant to be installed + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + systemctl is-enabled salt-$fname.service || (systemctl preset salt-$fname.service && systemctl enable salt-$fname.service) sleep 0.1 systemctl daemon-reload @@ -3272,10 +3277,11 @@ install_fedora_git_deps() { $FEDORA_PACKAGE_MANAGER install -y git || return 1 fi - $FEDORA_PACKAGE_MANAGER install -y systemd-python || return 1 - __git_clone_and_checkout || return 1 + __PACKAGES="systemd-python" + __PIP_PACKAGES="" + if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then # We're on the develop branch, install whichever tornado is on the requirements file __REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")" @@ -3284,14 +3290,25 @@ install_fedora_git_deps() { # Install pip and pip dependencies if ! __check_command_exists pip; then - $FEDORA_PACKAGE_MANAGER install -y python-setuptools python-pip gcc python-devel + __PACKAGES="${__PACKAGES} python-setuptools python-pip gcc python-devel" fi - pip install -U tornado - + __PIP_PACKAGES="${__PIP_PACKAGES} tornado" fi fi + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + __PACKAGES="${__PACKAGES} python-libcloud" + fi + + # shellcheck disable=SC2086 + $FEDORA_PACKAGE_MANAGER install -y ${__PACKAGES} || return 1 + + if [ "${__PIP_PACKAGES}" != "" ]; then + # shellcheck disable=SC2086,SC2090 + pip install -U ${__PIP_PACKAGES} || return 1 + fi + # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then _TEMP_CONFIG_DIR="${_SALT_GIT_CHECKOUT_DIR}/conf/" From eb67ef8b0812df3b3199dbea85960f4ba105d22d Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Mon, 8 Aug 2016 15:20:49 +0300 Subject: [PATCH 21/30] Amazon: install `salt-cloud` package with `-L` option in `stable` mode --- bootstrap-salt.sh | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index cc59097..f8d1f98 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -4124,19 +4124,9 @@ _eof __PACKAGES="PyYAML m2crypto python-crypto python-msgpack python-zmq python26-ordereddict python-jinja2 python-requests" - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then - __check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" - __PACKAGES="${__PACKAGES} python-pip" - fi - # shellcheck disable=SC2086 yum -y install ${__PACKAGES} --enablerepo=${_EPEL_REPO}"" || return 1 - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then - __check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" - pip-python install "apache-libcloud>=$_LIBCLOUD_MIN_VERSION" - fi - if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 @@ -4153,14 +4143,33 @@ install_amazon_linux_ami_git_deps() { __git_clone_and_checkout || return 1 + __PACKAGES="" + __PIP_PACKAGES="" + + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + __check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" + __PACKAGES="${__PACKAGES} python-pip" + __PIP_PACKAGES="${__PIP_PACKAGES} apache-libcloud>=$_LIBCLOUD_MIN_VERSION" + fi + if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then # We're on the develop branch, install whichever tornado is on the requirements file __REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")" if [ "${__REQUIRED_TORNADO}" != "" ]; then - yum install -y python-tornado + __PACKAGES="${__PACKAGES} python-tornado" fi fi + if [ "${__PACKAGES}" != "" ]; then + # shellcheck disable=SC2086 + yum -y install ${__PACKAGES} --enablerepo="${_EPEL_REPO}" || return 1 + fi + + if [ "${__PIP_PACKAGES}" != "" ]; then + # shellcheck disable=SC2086 + pip-python install ${__PIP_PACKAGES} || return 1 + fi + # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then _TEMP_CONFIG_DIR="${_SALT_GIT_CHECKOUT_DIR}/conf/" From bdebaa5032c1d7271e3ff1bfa1ddeb01fc49df70 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Tue, 9 Aug 2016 12:20:52 +0300 Subject: [PATCH 22/30] SUSE: install `salt-cloud` package with `-L` option in `stable` mode --- bootstrap-salt.sh | 83 +++++++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 32 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index f8d1f98..98eb5fa 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -3082,9 +3082,9 @@ install_debian_8_git() { install_debian_git_post() { for fname in minion master syndic api; do - # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue - + # Skip if not meant to be installed + [ "$fname" = "api" ] && \ + ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue [ "$fname" = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue [ "$fname" = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ "$fname" = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue @@ -3513,7 +3513,7 @@ install_centos_stable_deps() { fi if [ "$DISTRO_MAJOR_VERSION" -eq 5 ]; then - # Install curl which is not included in @Core CentOS 5 installation + # Install curl which is not included in @core CentOS 5 installation __check_command_exists curl || yum -y install "curl.${CPU_ARCH_L}" || return 1 fi @@ -3654,10 +3654,9 @@ install_centos_git_post() { SYSTEMD_RELOAD=$BS_FALSE for fname in api master minion syndic; do - # Skip salt-api since the service should be opt-in and not necessarily started on boot - [ $fname = "api" ] && continue - # Skip if not meant to be installed + [ $fname = "api" ] && \ + ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue @@ -3668,18 +3667,11 @@ install_centos_git_post() { __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-${fname}.service" /usr/lib/systemd/system fi - /usr/systemctl is-enabled salt-${fname}.service > /dev/null 2>&1 || ( - /bin/systemctl preset salt-${fname}.service > /dev/null 2>&1 && - /bin/systemctl enable salt-${fname}.service > /dev/null 2>&1 - ) - SYSTEMD_RELOAD=$BS_TRUE elif [ ! -f "/etc/init.d/salt-$fname" ] || \ ([ -f "/etc/init.d/salt-$fname" ] && [ "$_FORCE_OVERWRITE" -eq $BS_TRUE ]); then __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-${fname}" /etc/init.d chmod +x /etc/init.d/salt-${fname} - - /sbin/chkconfig salt-${fname} on fi done @@ -3687,6 +3679,8 @@ install_centos_git_post() { /bin/systemctl daemon-reload fi + install_centos_stable_post || return 1 + return 0 } @@ -3755,6 +3749,7 @@ install_centos_check_services() { [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + if [ -f /sbin/initctl ] && [ -f /etc/init/salt-${fname}.conf ]; then __check_services_upstart salt-$fname || return 1 elif [ -f /etc/init.d/salt-$fname ]; then @@ -3763,6 +3758,7 @@ install_centos_check_services() { __check_services_systemd salt-$fname || return 1 fi done + return 0 } # @@ -5172,10 +5168,6 @@ install_opensuse_stable_deps() { __PACKAGES="${__PACKAGES} libzmq5" fi - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then - __PACKAGES="${__PACKAGES} python-apache-libcloud" - fi - # shellcheck disable=SC2086 __zypper_install ${__PACKAGES} || return 1 @@ -5202,15 +5194,23 @@ install_opensuse_git_deps() { __git_clone_and_checkout || return 1 + __PACKAGES="" + if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then # We're on the develop branch, install whichever tornado is on the requirements file __REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")" if [ "${__REQUIRED_TORNADO}" != "" ]; then - __zypper_install python-tornado + __PACKAGES="${__PACKAGES} python-tornado" fi - fi + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + __PACKAGES="${__PACKAGES} python-apache-libcloud" + fi + + # shellcheck disable=SC2086 + __zypper_install ${__PACKAGES} || return 1 + # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then _TEMP_CONFIG_DIR="${_SALT_GIT_CHECKOUT_DIR}/conf/" @@ -5222,17 +5222,23 @@ install_opensuse_git_deps() { install_opensuse_stable() { __PACKAGES="" - if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then - __PACKAGES="${__PACKAGES} salt-minion" + + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + __PACKAGES="${__PACKAGES} salt-cloud" fi if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then __PACKAGES="${__PACKAGES} salt-master" fi + if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + __PACKAGES="${__PACKAGES} salt-minion" + fi if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then __PACKAGES="${__PACKAGES} salt-syndic" fi + # shellcheck disable=SC2086 __zypper_install $__PACKAGES || return 1 + return 0 } @@ -5321,7 +5327,6 @@ install_opensuse_restart_daemons() { service salt-$fname stop > /dev/null 2>&1 service salt-$fname start - done } @@ -5459,14 +5464,23 @@ install_suse_12_git_deps() { __git_clone_and_checkout || return 1 + __PACKAGES="" + if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then # We're on the develop branch, install whichever tornado is on the requirements file __REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")" if [ "${__REQUIRED_TORNADO}" != "" ]; then - __zypper_install python-tornado + __PACKAGES="${__PACKAGES} python-tornado" fi fi + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + __PACKAGES="${__PACKAGES} python-apache-libcloud" + fi + + # shellcheck disable=SC2086 + __zypper_install ${__PACKAGES} || return 1 + # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then _TEMP_CONFIG_DIR="${_SALT_GIT_CHECKOUT_DIR}/conf/" @@ -5484,6 +5498,7 @@ install_suse_12_stable() { # error: option --single-version-externally-managed not recognized USE_SETUPTOOLS=1 pip install salt || return 1 fi + return 0 } @@ -5584,10 +5599,6 @@ install_suse_11_stable_deps() { __PACKAGES="${__PACKAGES} python-PyYAML" fi - if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then - __PACKAGES="${__PACKAGES} python-apache-libcloud" - fi - # SLES 11 SP3 ships with both python-M2Crypto-0.22.* and python-m2crypto-0.21 and we will be asked which # we want to install, even with --non-interactive. # Let's try to install the higher version first and then the lower one in case of failure @@ -5647,14 +5658,23 @@ install_suse_11_git_deps() { __git_clone_and_checkout || return 1 + __PACKAGES="" + if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then # We're on the develop branch, install whichever tornado is on the requirements file __REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")" if [ "${__REQUIRED_TORNADO}" != "" ]; then - __zypper_install python-tornado + __PACKAGES="${__PACKAGES} python-tornado" fi fi + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + __PACKAGES="${__PACKAGES} python-apache-libcloud" + fi + + # shellcheck disable=SC2086 + __zypper_install ${__PACKAGES} || return 1 + # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then _TEMP_CONFIG_DIR="${_SALT_GIT_CHECKOUT_DIR}/conf/" @@ -5706,6 +5726,7 @@ install_suse_11_stable_post() { done fi + return 0 } @@ -6041,8 +6062,6 @@ config_salt() { for file_d in "$_TEMP_CONFIG_DIR/$subdir"/*; do [ -f "$file_d" ] && __copyfile "$file_d" "$_SALT_ETC_DIR/$subdir" done - else - continue fi done fi @@ -6052,7 +6071,7 @@ config_salt() { exit 0 fi - # Create default logs directory if not exists (happens with git installations) + # Create default logs directory if not exists mkdir -p /var/log/salt return 0 From 3f0e849be1e8060e1c24da2386bb8cc92094c774 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Wed, 10 Aug 2016 11:18:15 +0300 Subject: [PATCH 23/30] Gentoo: install `apache-libcloud` with `emerge` instead of `pip` --- bootstrap-salt.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 98eb5fa..2e5ef01 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -5821,9 +5821,7 @@ __gentoo_post_dep() { __gentoo_config_protection if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then - __check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud" - __emerge -v 'dev-python/pip' - pip install -U "apache-libcloud>=$_LIBCLOUD_MIN_VERSION" + __emerge -v 'dev-python/libcloud' fi __emerge -vo 'dev-python/requests' From 88a401ef25d421f3b7806ed15adaf8bdeaec4007 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Wed, 10 Aug 2016 11:20:31 +0300 Subject: [PATCH 24/30] Fail if unable to copy config file --- bootstrap-salt.sh | 49 ++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 2e5ef01..8dc48e6 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -1753,10 +1753,10 @@ __copyfile() { cp "$sfile" "$dfile" || return 1 elif [ -f "$dfile" ] && [ "$overwrite" -eq $BS_TRUE ]; then # The destination exist and we're overwriting - echodebug "Overriding $dfile with $sfile" + echodebug "Overwriting $dfile with $sfile" cp -f "$sfile" "$dfile" || return 1 elif [ -f "$dfile" ] && [ "$overwrite" -ne $BS_TRUE ]; then - echodebug "Not overriding $dfile with $sfile" + echodebug "Not overwriting $dfile with $sfile" fi return 0 } @@ -4340,7 +4340,8 @@ install_arch_linux_git_post() { # Skip if not meant to be installed [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue + [ $fname = "api" ] && \ + ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /usr/bin/systemctl ]; then @@ -4372,9 +4373,8 @@ install_arch_linux_restart_daemons() { [ $fname = "api" ] && continue # Skip if not meant to be installed - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - #[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f /usr/bin/systemctl ]; then @@ -4398,10 +4398,10 @@ install_arch_check_services() { [ $fname = "api" ] && continue # Skip if not meant to be installed - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - #[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + __check_services_systemd salt-$fname || return 1 done return 0 @@ -4856,12 +4856,13 @@ install_openbsd_post() { cp -p /etc/rc.d/rc.subr /etc/rc.d/rc.subr sed -i."$(date +%F)".saltinstall -e 's:-xf:-f:g' /etc/rc.d/rc.subr fi + _TEMP_CONFIG_DIR="/tmp" - for fname in minion master syndic api; do + for fname in api master minion syndic; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue - [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue [ $fname = "api" ] || ! __check_command_exists "salt-${fname}" && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "syndic" ] && continue if [ $? -eq 1 ]; then @@ -4879,31 +4880,34 @@ install_openbsd_post() { } install_openbsd_check_services() { - for fname in minion master syndic api; do + for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot [ $fname = "api" ] && continue # Skip if not meant to be installed - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "api" ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "syndic" ] && continue + if [ -f /etc/rc.d/salt_${fname} ]; then __check_services_openbsd salt_${fname} || return 1 fi done + return 0 } install_openbsd_restart_daemons() { [ $_START_DAEMONS -eq $BS_FALSE ] && return - for fname in minion master syndic api; do + + for fname in api master minion syndic; do # Skip salt-api since the service should be opt-in and not necessarily started on boot [ $fname = "api" ] && continue + # Skip if not meant to be installed - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue if [ -f "/etc/rc.d/salt_${fname}" ]; then /etc/rc.d/salt_${fname} stop > /dev/null 2>&1 @@ -5009,9 +5013,10 @@ install_smartos_post() { for fname in minion master syndic api; do # Skip if not meant to be installed - [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "api" ] && \ + ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue - [ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || ! __check_command_exists "salt-${fname}") && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue svcs network/salt-$fname > /dev/null 2>&1 @@ -5933,6 +5938,7 @@ config_salt() { if [ "$_CONFIG_ONLY" -eq $BS_TRUE ]; then echowarn "Passing -C (config only) option implies -F (forced overwrite)." + if [ "$_FORCE_OVERWRITE" -ne $BS_TRUE ]; then echowarn "Overwriting configs in 11 seconds!" sleep 11 @@ -5960,7 +5966,8 @@ config_salt() { CONFIGURED_ANYTHING=$BS_TRUE fi - if [ "$_INSTALL_MINION" -eq $BS_TRUE ] || [ "$_CONFIG_ONLY" -eq $BS_TRUE ] || [ "$_CUSTOM_MINION_CONFIG" != "null" ]; then + if [ "$_INSTALL_MINION" -eq $BS_TRUE ] || \ + [ "$_CONFIG_ONLY" -eq $BS_TRUE ] || [ "$_CUSTOM_MINION_CONFIG" != "null" ]; then # Create the PKI directory [ -d "$_PKI_DIR/minion" ] || (mkdir -p "$_PKI_DIR/minion" && chmod 700 "$_PKI_DIR/minion") || return 1 @@ -6053,12 +6060,14 @@ config_salt() { # Recursively copy salt-cloud configs with overwriting if necessary for file in "$_TEMP_CONFIG_DIR"/cloud*; do if [ -f "$file" ]; then - __copyfile "$file" "$_SALT_ETC_DIR" + __copyfile "$file" "$_SALT_ETC_DIR" || return 1 elif [ -d "$file" ]; then subdir="$(basename "$file")" mkdir -p "$_SALT_ETC_DIR/$subdir" for file_d in "$_TEMP_CONFIG_DIR/$subdir"/*; do - [ -f "$file_d" ] && __copyfile "$file_d" "$_SALT_ETC_DIR/$subdir" + if [ -f "$file_d" ]; then + __copyfile "$file_d" "$_SALT_ETC_DIR/$subdir" || return 1 + fi done fi done From 692fbdf65c1a5c2b45a6a8f2751069691989a58f Mon Sep 17 00:00:00 2001 From: Tobias Jungel Date: Wed, 3 Aug 2016 09:17:32 +0200 Subject: [PATCH 25/30] missing python dependency for salt-cloud added python-netaddr is not installed in case -L is used --- bootstrap-salt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index b6136b7..73caaf7 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -3305,7 +3305,7 @@ install_fedora_git_deps() { fi if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then - __PACKAGES="${__PACKAGES} python-libcloud" + __PACKAGES="${__PACKAGES} python-libcloud python-netaddr" fi # shellcheck disable=SC2086 From 17560c2c425d9fa88f29d73a4ff8e899313c4878 Mon Sep 17 00:00:00 2001 From: Denys Havrysh Date: Fri, 12 Aug 2016 13:08:04 +0300 Subject: [PATCH 26/30] Fix grep pattern in `__check_services_sysvinit` --- bootstrap-salt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 73caaf7..148e1cc 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -2023,7 +2023,7 @@ __check_services_sysvinit() { servicename=$1 echodebug "Checking if service ${servicename} is enabled" - if [ "$(LC_ALL=C /sbin/chkconfig --list | grep salt-"$fname" | grep '[2-5]:on')" != "" ]; then + if [ "$(LC_ALL=C /sbin/chkconfig --list | grep "\<${servicename}\>" | grep '[2-5]:on')" != "" ]; then echodebug "Service ${servicename} is enabled" return 0 else From 3da25985cd66a9b368dd25923821001c3eb937b8 Mon Sep 17 00:00:00 2001 From: rallytime Date: Fri, 12 Aug 2016 10:10:48 -0600 Subject: [PATCH 27/30] Disable the '--enablerepo=${_EPEL_REPO}' part of yum install cmds when passing -R/-r Fixes #924 --- bootstrap-salt.sh | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 148e1cc..bc540bf 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -1599,13 +1599,19 @@ __apt_get_upgrade_noinput() { # DESCRIPTION: (DRY) apt-get install with noinput options #---------------------------------------------------------------------------------------------------------------------- __yum_install_noinput() { + + ENABLE_EPEL_CMD="" + if [ $_DISABLE_REPOS -eq $BS_TRUE ]; then + ENABLE_EPEL_CMD="--enablerepo=${_EPEL_REPO}" + fi + if [ "$DISTRO_NAME_L" = "oracle_linux" ]; then # We need to install one package at a time because --enablerepo=X disables ALL OTHER REPOS!!!! for package in "${@}"; do - yum -y install "${package}" || yum -y install "${package}" --enablerepo="${_EPEL_REPO}" || return $? + yum -y install "${package}" || yum -y install "${package}" ${ENABLE_EPEL_CMD} || return $? done else - yum -y install "${@}" --enablerepo=${_EPEL_REPO} || return $? + yum -y install "${@}" ${ENABLE_EPEL_CMD} || return $? fi } @@ -4099,6 +4105,11 @@ install_scientific_linux_check_services() { install_amazon_linux_ami_deps() { + ENABLE_EPEL_CMD="" + if [ $_DISABLE_REPOS -eq $BS_TRUE ]; then + ENABLE_EPEL_CMD="--enablerepo=${_EPEL_REPO}" + fi + if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then # enable the EPEL repo /usr/bin/yum-config-manager --enable epel || return 1 @@ -4128,20 +4139,25 @@ _eof __PACKAGES="PyYAML m2crypto python-crypto python-msgpack python-zmq python26-ordereddict python-jinja2 python-requests" # shellcheck disable=SC2086 - yum -y install ${__PACKAGES} --enablerepo=${_EPEL_REPO}"" || return 1 + yum -y install ${__PACKAGES} ${ENABLE_EPEL_CMD} || return 1 if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - yum install -y ${_EXTRA_PACKAGES} --enablerepo=${_EPEL_REPO} || return 1 + yum install -y ${_EXTRA_PACKAGES} ${ENABLE_EPEL_CMD} || return 1 fi } install_amazon_linux_ami_git_deps() { install_amazon_linux_ami_deps || return 1 + ENABLE_EPEL_CMD="" + if [ $_DISABLE_REPOS -eq $BS_TRUE ]; then + ENABLE_EPEL_CMD="--enablerepo=${_EPEL_REPO}" + fi + if ! __check_command_exists git; then - yum -y install git --enablerepo=${_EPEL_REPO} || return 1 + yum -y install git ${ENABLE_EPEL_CMD} || return 1 fi __git_clone_and_checkout || return 1 @@ -4165,7 +4181,7 @@ install_amazon_linux_ami_git_deps() { if [ "${__PACKAGES}" != "" ]; then # shellcheck disable=SC2086 - yum -y install ${__PACKAGES} --enablerepo="${_EPEL_REPO}" || return 1 + yum -y install ${__PACKAGES} ${ENABLE_EPEL_CMD} || return 1 fi if [ "${__PIP_PACKAGES}" != "" ]; then From e0c5b4208347e33b4e886fb267828ba3028dbc0d Mon Sep 17 00:00:00 2001 From: rallytime Date: Fri, 12 Aug 2016 12:15:50 -0600 Subject: [PATCH 28/30] Remove chris-lea python-zmq repo python-zmq is provided by repo.saltstack.com now, for platforms that do not have a recent enough version. Fixes #926 --- bootstrap-salt.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index bc540bf..fba6919 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -2316,12 +2316,6 @@ install_ubuntu_deps() { fi fi - if [ "$DISTRO_MAJOR_VERSION" -gt 12 ] || ([ "$DISTRO_MAJOR_VERSION" -eq 12 ] && [ "$DISTRO_MINOR_VERSION" -gt 03 ]); then - if ([ "$DISTRO_MAJOR_VERSION" -lt 15 ] && [ "$_ENABLE_EXTERNAL_ZMQ_REPOS" -eq $BS_TRUE ]); then - echoinfo "Installing ZMQ>=4/PyZMQ>=14 from Chris Lea's PPA repository" - add-apt-repository -y ppa:chris-lea/zeromq || return 1 - fi - fi fi fi From 96efc3aec5dd8e45dc260ab58e4a41fefa9298e2 Mon Sep 17 00:00:00 2001 From: rallytime Date: Mon, 15 Aug 2016 12:56:27 -0600 Subject: [PATCH 29/30] Update changelog with recent PRs --- ChangeLog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index c1dd062..1a80e94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Version 2016.08.15: + * Remove chris-lea python-zmq repo. (rallytime) #929 + * Disable the '--enablerepo=${_EPEL_REPO}' part of yum install cmds when passing -R/-r. (rallytime) #928 + * Fix grep pattern in `__check_services_sysvinit`. (vutny) #927 + * Missing python dependency for salt-cloud added. (toanju) #925 + * Fix git install mode when using commit hash with `-g` option. (vutny) #922 + * Install `salt-cloud` package with `-L` option in `stable` mode. (vutny) #919 + * Fix bootstrapping from Git on CentOS7 when `systemd` is not running. (vutny) #915 + Version 2016.07.07: * Add new contributors to authors list. (rallytime) #910 * Split up python-requests and python-msgpack packages for newer Fedora. (rallytime) #909 From 5ffa2d043077e7a7a0ff55b6834fb4b793b2b305 Mon Sep 17 00:00:00 2001 From: rallytime Date: Mon, 15 Aug 2016 12:58:57 -0600 Subject: [PATCH 30/30] Update stable version number to 2016.08.15 --- bootstrap-salt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index fba6919..73e60f8 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -18,7 +18,7 @@ #====================================================================================================================== set -o nounset # Treat unset variables as an error -__ScriptVersion="2016.07.07" +__ScriptVersion="2016.08.15" __ScriptName="bootstrap-salt.sh" __ScriptFullName="$0"