Merge branch 'master' into win_task_repeat

This commit is contained in:
Charles McMarrow 2020-01-29 14:59:05 -08:00 committed by GitHub
commit 4b80301338
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 377 additions and 86 deletions

View file

@ -6,6 +6,26 @@ Salt package
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import warnings
import sys
import importlib
class TornadoImporter(object):
def find_module(self, module_name, package_path):
if module_name.startswith('tornado'):
return self
return None
def load_module(self, name):
mod = importlib.import_module('salt.ext.{}'.format(name))
sys.modules[name] = mod
return mod
# Try our importer first
sys.meta_path = [TornadoImporter()] + sys.meta_path
# All salt related deprecation warnings should be shown once each!
warnings.filterwarnings(

View file

@ -23,7 +23,7 @@
#======================================================================================================================
set -o nounset # Treat unset variables as an error
__ScriptVersion="2020.01.21"
__ScriptVersion="2020.01.29"
__ScriptName="bootstrap-salt.sh"
__ScriptFullName="$0"
@ -271,6 +271,7 @@ _REPO_URL="repo.saltstack.com"
_PY_EXE=""
_INSTALL_PY="$BS_FALSE"
_TORNADO_MAX_PY3_VERSION="5.0"
_POST_NEON_INSTALL=$BS_FALSE
# Defaults for install arguments
ITYPE="stable"
@ -293,7 +294,7 @@ __usage() {
- stable [version] Install a specific version. Only supported for
packages available at repo.saltstack.com
- testing RHEL-family specific: configure EPEL testing repo
- git Install from the head of the develop branch
- git Install from the head of the master branch
- git [ref] Install from any git ref (such as a branch, tag, or
commit)
@ -584,7 +585,7 @@ fi
# If doing a git install, check what branch/tag/sha will be checked out
if [ "$ITYPE" = "git" ]; then
if [ "$#" -eq 0 ];then
GIT_REV="develop"
GIT_REV="master"
else
GIT_REV="$1"
shift
@ -1687,10 +1688,9 @@ __check_end_of_life_versions() {
;;
freebsd)
# FreeBSD versions lower than 9.1 are not supported.
if { [ "$DISTRO_MAJOR_VERSION" -eq 9 ] && [ "$DISTRO_MINOR_VERSION" -lt 01 ]; } || \
[ "$DISTRO_MAJOR_VERSION" -lt 9 ]; then
echoerror "Versions lower than FreeBSD 9.1 are not supported."
# FreeBSD versions lower than 11 are EOL
if [ "$DISTRO_MAJOR_VERSION" -lt 11 ]; then
echoerror "Versions lower than FreeBSD 11 are EOL and no longer supported."
exit 1
fi
;;
@ -1817,6 +1817,61 @@ if [ "${DISTRO_NAME_L}" != "ubuntu" ] && [ $_PIP_ALL -eq $BS_TRUE ]; then
exit 1
fi
if [ "$ITYPE" = "git" ]; then
if [ "${GIT_REV}" = "master" ]; then
_POST_NEON_INSTALL=$BS_TRUE
__TAG_REGEX_MATCH="MATCH"
else
case ${OS_NAME_L} in
openbsd|freebsd|netbsd|darwin )
__NEW_VS_TAG_REGEX_MATCH=$(echo "${GIT_REV}" | sed -E 's/^(v?3[0-9]{3}(\.[0-9]{1,2})?).*$/MATCH/')
if [ "$__NEW_VS_TAG_REGEX_MATCH" = "MATCH" ]; then
_POST_NEON_INSTALL=$BS_TRUE
__TAG_REGEX_MATCH="${__NEW_VS_TAG_REGEX_MATCH}"
if [ "$(echo "${GIT_REV}" | cut -c -1)" != "v" ]; then
# We do this to properly clone tags
GIT_REV="v${GIT_REV}"
fi
echodebug "Post Neon Tag Regex Match On: ${GIT_REV}"
else
__TAG_REGEX_MATCH=$(echo "${GIT_REV}" | sed -E 's/^(v?[0-9]{1,4}\.[0-9]{1,2})(\.[0-9]{1,2})?.*$/MATCH/')
echodebug "Pre Neon Tag Regex Match On: ${GIT_REV}"
fi
;;
* )
__NEW_VS_TAG_REGEX_MATCH=$(echo "${GIT_REV}" | sed 's/^.*\(v\?3[[:digit:]]\{3\}\(\.[[:digit:]]\{1,2\}\)\?\).*$/MATCH/')
if [ "$__NEW_VS_TAG_REGEX_MATCH" = "MATCH" ]; then
_POST_NEON_INSTALL=$BS_TRUE
__TAG_REGEX_MATCH="${__NEW_VS_TAG_REGEX_MATCH}"
if [ "$(echo "${GIT_REV}" | cut -c -1)" != "v" ]; then
# We do this to properly clone tags
GIT_REV="v${GIT_REV}"
fi
echodebug "Post Neon Tag Regex Match On: ${GIT_REV}"
else
__TAG_REGEX_MATCH=$(echo "${GIT_REV}" | sed 's/^.*\(v\?[[:digit:]]\{1,4\}\.[[:digit:]]\{1,2\}\)\(\.[[:digit:]]\{1,2\}\)\?.*$/MATCH/')
echodebug "Pre Neon Tag Regex Match On: ${GIT_REV}"
fi
;;
esac
fi
if [ "$_POST_NEON_INSTALL" -eq $BS_TRUE ]; then
echo
echowarn "Post Neon git based installations will always install salt and it's dependencies using pip"
echowarn "You have 10 seconds to cancel and stop the bootstrap process"
echo
sleep 10
_PIP_ALLOWED=$BS_TRUE
# 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
fi
fi
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __function_defined
@ -1981,15 +2036,6 @@ __git_clone_and_checkout() {
export GIT_SSL_NO_VERIFY=1
fi
case ${OS_NAME_L} in
openbsd|freebsd|netbsd|darwin )
__TAG_REGEX_MATCH=$(echo "${GIT_REV}" | sed -E 's/^(v?[0-9]{1,4}\.[0-9]{1,2})(\.[0-9]{1,2})?.*$/MATCH/')
;;
* )
__TAG_REGEX_MATCH=$(echo "${GIT_REV}" | sed 's/^.*\(v\?[[:digit:]]\{1,4\}\.[[:digit:]]\{1,2\}\)\(\.[[:digit:]]\{1,2\}\)\?.*$/MATCH/')
;;
esac
__SALT_GIT_CHECKOUT_PARENT_DIR=$(dirname "${_SALT_GIT_CHECKOUT_DIR}" 2>/dev/null)
__SALT_GIT_CHECKOUT_PARENT_DIR="${__SALT_GIT_CHECKOUT_PARENT_DIR:-/tmp/git}"
__SALT_CHECKOUT_REPONAME="$(basename "${_SALT_GIT_CHECKOUT_DIR}" 2>/dev/null)"
@ -2583,6 +2629,48 @@ __install_pip_deps() {
pip install -U -r ${requirements_file} ${__PIP_PACKAGES}
} # ---------- end of function __install_pip_deps ----------
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __install_salt_from_repo_post_neon
# DESCRIPTION: Return 0 or 1 if successfully able to install. Can provide a different python version to
# install pip packages with. If $py_exe is not specified it will use the default python version.
# PARAMETERS: py_exe
#----------------------------------------------------------------------------------------------------------------------
__install_salt_from_repo_post_neon() {
_py_exe="$1"
if [ "${_py_exe}" = "" ]; then
_py_exe='python'
fi
echodebug "__install_salt_from_repo_post_neon py_exe=$_py_exe"
_py_pkg=$(echo "$_py_exe" | sed -E "s/\\.//g")
_pip_cmd="${_py_exe} -m pip"
__check_pip_allowed
# Install pip and pip dependencies
if ! __check_command_exists "${_pip_cmd} --version"; then
__PACKAGES="${_py_pkg}-pip gcc"
# shellcheck disable=SC2086
if [ "$DISTRO_NAME_L" = "debian" ];then
__PACKAGES="${__PACKAGES} ${_py_pkg}-dev"
__apt_get_install_noinput ${__PACKAGES} || return 1
else
__PACKAGES="${__PACKAGES} ${_py_pkg}-devel"
__yum_install_noinput ${__PACKAGES} || return 1
fi
fi
${_pip_cmd} install -U pip
echoinfo "Installing salt using ${_py_exe}"
cd "${_SALT_GIT_CHECKOUT_DIR}" || return 1
${_pip_cmd} install . || return 1
} # ---------- end of function __install_salt_from_repo_post_neon ----------
#######################################################################################################################
#
@ -2824,6 +2912,10 @@ install_ubuntu_git_deps() {
__git_clone_and_checkout || return 1
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
return 0
fi
__PACKAGES=""
# See how we are installing packages
@ -2911,6 +3003,11 @@ install_ubuntu_git() {
_PYEXE=python2.7
fi
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
__install_salt_from_repo_post_neon "${_PY_EXE}" || return 1
return 0
fi
if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then
# shellcheck disable=SC2086
"${_PYEXE}" setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install --install-layout=deb || return 1
@ -3193,6 +3290,10 @@ install_debian_git_deps() {
__git_clone_and_checkout || return 1
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
return 0
fi
__PACKAGES="libzmq3 libzmq3-dev lsb-release python-apt python-backports.ssl-match-hostname"
__PACKAGES="${__PACKAGES} python-crypto python-jinja2 python-msgpack python-m2crypto"
__PACKAGES="${__PACKAGES} python-requests python-tornado python-yaml python-zmq"
@ -3234,6 +3335,10 @@ install_debian_8_git_deps() {
__git_clone_and_checkout || return 1
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
return 0
fi
__PACKAGES="libzmq3 libzmq3-dev lsb-release python-apt python-crypto python-jinja2"
__PACKAGES="${__PACKAGES} python-m2crypto python-msgpack python-requests python-systemd"
__PACKAGES="${__PACKAGES} python-yaml python-zmq python-concurrent.futures"
@ -3298,6 +3403,10 @@ install_debian_9_git_deps() {
__git_clone_and_checkout || return 1
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
return 0
fi
__PACKAGES="libzmq5 lsb-release"
if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then
@ -3333,6 +3442,10 @@ install_debian_9_git_deps() {
install_debian_10_git_deps() {
install_debian_git_pre || return 1
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
return 0
fi
if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then
_py=${_PY_EXE}
PY_PKG_VER=3
@ -3397,6 +3510,11 @@ install_debian_git() {
_PYEXE=python
fi
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
__install_salt_from_repo_post_neon "${_PY_EXE}" || return 1
return 0
fi
if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then
# shellcheck disable=SC2086
"${_PYEXE}" setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install --install-layout=deb || return 1
@ -3601,12 +3719,21 @@ install_fedora_git_deps() {
fi
__PACKAGES="${__PACKAGES:=}"
if [ "$_INSECURE_DL" -eq $BS_FALSE ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then
__PACKAGES="${__PACKAGES} ca-certificates"
fi
if ! __check_command_exists git; then
__PACKAGES="${__PACKAGES} git"
fi
install_fedora_deps || return 1
__git_clone_and_checkout || return 1
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
return 0
fi
__PACKAGES="${__PACKAGES:=}"
if [ "$_INSECURE_DL" -eq $BS_FALSE ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then
__PACKAGES="${__PACKAGES} ca-certificates"
fi
if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then
__PACKAGES="${__PACKAGES} python${PY_PKG_VER}-libcloud python${PY_PKG_VER}-netaddr"
fi
@ -3620,8 +3747,6 @@ install_fedora_git_deps() {
install_fedora_deps || return 1
__git_clone_and_checkout || return 1
# Fedora 28+ needs tornado <5.0 from pip
# https://github.com/saltstack/salt-bootstrap/issues/1220
if [ "${PY_PKG_VER}" -eq 3 ] && [ "$DISTRO_MAJOR_VERSION" -ge 28 ]; then
@ -3649,6 +3774,11 @@ install_fedora_git() {
_PYEXE='python2'
fi
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
__install_salt_from_repo_post_neon "${_PY_EXE}" || return 1
return 0
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
@ -3809,26 +3939,28 @@ install_centos_stable_deps() {
__PACKAGES="yum-utils chkconfig"
fi
if [ "$DISTRO_MAJOR_VERSION" -ge 8 ]; then
# YAML module is used for generating custom master/minion configs
if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then
__PACKAGES="${__PACKAGES} python3-pyyaml"
if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then
if [ "$DISTRO_MAJOR_VERSION" -ge 8 ]; then
# YAML module is used for generating custom master/minion configs
if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then
__PACKAGES="${__PACKAGES} python3-pyyaml"
else
__PACKAGES="${__PACKAGES} python2-pyyaml"
fi
elif [ "$DISTRO_MAJOR_VERSION" -eq 7 ]; then
# YAML module is used for generating custom master/minion configs
if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then
__PACKAGES="${__PACKAGES} python36-PyYAML"
else
__PACKAGES="${__PACKAGES} PyYAML"
fi
else
__PACKAGES="${__PACKAGES} python2-pyyaml"
fi
elif [ "$DISTRO_MAJOR_VERSION" -eq 7 ]; then
# YAML module is used for generating custom master/minion configs
if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then
__PACKAGES="${__PACKAGES} python36-PyYAML"
else
__PACKAGES="${__PACKAGES} PyYAML"
fi
else
# YAML module is used for generating custom master/minion configs
if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then
__PACKAGES="${__PACKAGES} python34-PyYAML"
else
__PACKAGES="${__PACKAGES} PyYAML"
# YAML module is used for generating custom master/minion configs
if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then
__PACKAGES="${__PACKAGES} python34-PyYAML"
else
__PACKAGES="${__PACKAGES} PyYAML"
fi
fi
fi
@ -3911,6 +4043,9 @@ install_centos_git_deps() {
__git_clone_and_checkout || return 1
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
return 0
fi
__PACKAGES=""
_install_m2crypto_req=false
@ -4009,6 +4144,12 @@ install_centos_git() {
_PYEXE='python2'
fi
echodebug "_PY_EXE: $_PY_EXE"
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
__install_salt_from_repo_post_neon "${_PY_EXE}" || return 1
return 0
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
@ -4539,18 +4680,24 @@ install_alpine_linux_stable_deps() {
install_alpine_linux_git_deps() {
install_alpine_linux_stable_deps || return 1
apk -U add python2 py-virtualenv py2-crypto py2-m2crypto py2-setuptools \
py2-jinja2 py2-yaml py2-markupsafe py2-msgpack py2-psutil \
py2-zmq zeromq py2-requests || return 1
if ! __check_command_exists git; then
apk -U add git || return 1
fi
__git_clone_and_checkout || return 1
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
apk -U add python2 py2-pip || return 1
_PY_EXE=python2
return 0
fi
apk -U add python2 py-virtualenv py2-crypto py2-m2crypto py2-setuptools \
py2-jinja2 py2-yaml py2-markupsafe py2-msgpack py2-psutil \
py2-zmq zeromq py2-requests || 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
# We're on the master branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")"
if [ "${__REQUIRED_TORNADO}" != "" ]; then
apk -U add py2-tornado || return 1
@ -4586,6 +4733,12 @@ install_alpine_linux_stable() {
}
install_alpine_linux_git() {
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
__install_salt_from_repo_post_neon "${_PY_EXE}" || return 1
return 0
fi
if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then
python2 setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install || return 1
else
@ -4603,7 +4756,7 @@ install_alpine_linux_post() {
[ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue
if [ -f /sbin/rc-update ]; then
script_url="${_SALTSTACK_REPO_URL%.git}/raw/develop/pkg/alpine/salt-$fname"
script_url="${_SALTSTACK_REPO_URL%.git}/raw/master/pkg/alpine/salt-$fname"
[ -f "/etc/init.d/salt-$fname" ] || __fetch_url "/etc/init.d/salt-$fname" "$script_url"
# shellcheck disable=SC2181
@ -4794,6 +4947,10 @@ install_amazon_linux_ami_git_deps() {
__git_clone_and_checkout || return 1
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
return 0
fi
__PACKAGES=""
__PIP_PACKAGES=""
@ -4804,7 +4961,7 @@ install_amazon_linux_ami_git_deps() {
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
# We're on the master branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")"
if [ "${__REQUIRED_TORNADO}" != "" ]; then
__PACKAGES="${__PACKAGES} ${pkg_append}-tornado"
@ -4859,6 +5016,10 @@ install_amazon_linux_ami_2_git_deps() {
__git_clone_and_checkout || return 1
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
return 0
fi
__PACKAGES=""
__PIP_PACKAGES=""
@ -4878,7 +5039,7 @@ install_amazon_linux_ami_2_git_deps() {
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
# We're on the master branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")"
if [ "${__REQUIRED_TORNADO}" != "" ]; then
__PACKAGES="${__PACKAGES} ${pkg_append}${PY_PKG_VER}-tornado"
@ -5117,15 +5278,20 @@ install_arch_linux_git_deps() {
if ! __check_command_exists git; then
pacman -Sy --noconfirm --needed git || return 1
fi
__git_clone_and_checkout || return 1
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
return 0
fi
pacman -R --noconfirm python2-distribute
pacman -Su --noconfirm --needed python2-crypto python2-setuptools python2-jinja \
python2-m2crypto python2-futures python2-markupsafe python2-msgpack python2-psutil \
python2-pyzmq zeromq python2-requests python2-systemd || return 1
__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
# We're on the master branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")"
if [ "${__REQUIRED_TORNADO}" != "" ]; then
pacman -Su --noconfirm --needed python2-tornado
@ -5159,6 +5325,12 @@ install_arch_linux_stable() {
}
install_arch_linux_git() {
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
__install_salt_from_repo_post_neon "${_PY_EXE}" || return 1
return 0
fi
if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then
python2 setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install || return 1
else
@ -5296,21 +5468,24 @@ install_freebsd_deps() {
}
install_freebsd_git_deps() {
install_freebsd_stable_deps || return 1
install_freebsd_deps || return 1
SALT_DEPENDENCIES=$(/usr/local/sbin/pkg search -R -d py36-salt | grep 'origin:' \
| tail -n +2 | awk -F\" '{print $2}' | sed 's#.*/py-#py36-#g')
SALT_DEPENDENCIES=$(/usr/local/sbin/pkg search -R -d py37-salt | grep 'origin:' \
| tail -n +2 | awk -F\" '{print $2}')
# shellcheck disable=SC2086
/usr/local/sbin/pkg install -y ${SALT_DEPENDENCIES} || return 1
/usr/local/sbin/pkg install -y ${SALT_DEPENDENCIES} python || return 1
if ! __check_command_exists git; then
/usr/local/sbin/pkg install -y git || return 1
fi
/usr/local/sbin/pkg install -y py36-requests || return 1
__git_clone_and_checkout || return 1
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
return 0
fi
/usr/local/sbin/pkg install -y py37-requests || return 1
echodebug "Adapting paths to FreeBSD"
# The list of files was taken from Salt's BSD port Makefile
for file in doc/man/salt-key.1 doc/man/salt-cp.1 doc/man/salt-minion.1 \
@ -5354,17 +5529,22 @@ install_freebsd_stable() {
# installing latest version of salt from FreeBSD CURRENT ports repo
#
# shellcheck disable=SC2086
/usr/local/sbin/pkg install -y py36-salt || return 1
/usr/local/sbin/pkg install -y py37-salt || return 1
return 0
}
install_freebsd_git() {
# /usr/local/bin/python2 in FreeBSD is a symlink to /usr/local/bin/python2.7
__PYTHON_PATH=$(readlink -f "$(command -v python2)")
# /usr/local/bin/python3 in FreeBSD is a symlink to /usr/local/bin/python3.7
__PYTHON_PATH=$(readlink -f "$(command -v python3)")
__ESCAPED_PYTHON_PATH=$(echo "${__PYTHON_PATH}" | sed 's/\//\\\//g')
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
__install_salt_from_repo_post_neon "${__PYTHON_PATH}" || return 1
return 0
fi
# Install from git
if [ ! -f salt/syspaths.py ]; then
# We still can't provide the system paths, salt 0.16.x
@ -5470,6 +5650,11 @@ install_openbsd_git_deps() {
_TEMP_CONFIG_DIR="${_SALT_GIT_CHECKOUT_DIR}/conf/"
CONFIG_SALT_FUNC="config_salt"
fi
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
return 0
fi
return 0
}
@ -5477,6 +5662,11 @@ install_openbsd_git() {
#
# Install from git
#
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
__install_salt_from_repo_post_neon "${_PY_EXE}" || return 1
return 0
fi
if [ ! -f salt/syspaths.py ]; then
# We still can't provide the system paths, salt 0.16.x
/usr/local/bin/python2.7 setup.py ${SETUP_PY_INSTALL_ARGS} install || return 1
@ -5566,12 +5756,12 @@ install_smartos_deps() {
if [ ! -f "$_SALT_ETC_DIR/minion" ] && [ ! -f "$_TEMP_CONFIG_DIR/minion" ]; then
# shellcheck disable=SC2086
curl $_CURL_ARGS -s -o "$_TEMP_CONFIG_DIR/minion" -L \
https://raw.githubusercontent.com/saltstack/salt/develop/conf/minion || return 1
https://raw.githubusercontent.com/saltstack/salt/master/conf/minion || return 1
fi
if [ ! -f "$_SALT_ETC_DIR/master" ] && [ ! -f $_TEMP_CONFIG_DIR/master ]; then
# shellcheck disable=SC2086
curl $_CURL_ARGS -s -o "$_TEMP_CONFIG_DIR/master" -L \
https://raw.githubusercontent.com/saltstack/salt/develop/conf/master || return 1
https://raw.githubusercontent.com/saltstack/salt/master/conf/master || return 1
fi
fi
@ -5595,6 +5785,12 @@ install_smartos_git_deps() {
pkgin -y install git || return 1
fi
__git_clone_and_checkout || return 1
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
return 0
fi
if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then
# Install whichever tornado is in the requirements file
__REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")"
@ -5619,7 +5815,6 @@ install_smartos_git_deps() {
fi
fi
__git_clone_and_checkout || return 1
# Let's trigger config_salt()
if [ "$_TEMP_CONFIG_DIR" = "null" ]; then
_TEMP_CONFIG_DIR="${_SALT_GIT_CHECKOUT_DIR}/conf/"
@ -5635,6 +5830,12 @@ install_smartos_stable() {
}
install_smartos_git() {
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
__install_salt_from_repo_post_neon "${_PY_EXE}" || return 1
return 0
fi
# Use setuptools in order to also install dependencies
# lets force our config path on the setup for now, since salt/syspaths.py only got fixed in 2015.5.0
USE_SETUPTOOLS=1 /opt/local/bin/python setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install || return 1
@ -5658,7 +5859,7 @@ install_smartos_post() {
if [ ! -f "$_TEMP_CONFIG_DIR/salt-$fname.xml" ]; then
# shellcheck disable=SC2086
curl $_CURL_ARGS -s -o "$_TEMP_CONFIG_DIR/salt-$fname.xml" -L \
"https://raw.githubusercontent.com/saltstack/salt/develop/pkg/smartos/salt-$fname.xml"
"https://raw.githubusercontent.com/saltstack/salt/master/pkg/smartos/salt-$fname.xml"
fi
svccfg import "$_TEMP_CONFIG_DIR/salt-$fname.xml"
if [ "${VIRTUAL_TYPE}" = "global" ]; then
@ -5862,14 +6063,18 @@ install_opensuse_git_deps() {
__zypper_install git || return 1
fi
__zypper_install patch || return 1
__git_clone_and_checkout || return 1
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
return 0
fi
__zypper_install patch || return 1
__PACKAGES="libzmq5 python-Jinja2 python-m2crypto python-msgpack-python python-pycrypto python-pyzmq python-xml python-futures"
if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then
# We're on the develop branch, install whichever tornado is on the requirements file
# We're on the master branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")"
if [ "${__REQUIRED_TORNADO}" != "" ]; then
__PACKAGES="${__PACKAGES} python-tornado"
@ -5915,6 +6120,12 @@ install_opensuse_stable() {
}
install_opensuse_git() {
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
__install_salt_from_repo_post_neon "${_PY_EXE}" || return 1
return 0
fi
python setup.py ${SETUP_PY_INSTALL_ARGS} install --prefix=/usr || return 1
return 0
}
@ -6071,6 +6282,10 @@ install_opensuse_15_git_deps() {
__git_clone_and_checkout || return 1
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
return 0
fi
# Py3 is the default bootstrap install for Leap 15
# However, git installs might specify "-x python2"
if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 2 ]; then
@ -6088,7 +6303,7 @@ install_opensuse_15_git_deps() {
__PACKAGES="${__PACKAGES} python${PY_PKG_VER}-xml"
if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then
# We're on the develop branch, install whichever tornado is on the requirements file
# We're on the master branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")"
if [ "${__REQUIRED_TORNADO}" != "" ]; then
__PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
@ -6120,6 +6335,11 @@ install_opensuse_15_git() {
_PYEXE=python3
fi
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
__install_salt_from_repo_post_neon "${_PY_EXE}" || return 1
return 0
fi
${_PYEXE} setup.py ${SETUP_PY_INSTALL_ARGS} install --prefix=/usr || return 1
return 0
}
@ -6178,7 +6398,7 @@ install_suse_12_git_deps() {
__PACKAGES="${__PACKAGES} python-pyzmq python-xml"
if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then
# We're on the develop branch, install whichever tornado is on the requirements file
# We're on the master branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")"
if [ "${__REQUIRED_TORNADO}" != "" ]; then
__PACKAGES="${__PACKAGES} python-tornado"
@ -6274,7 +6494,7 @@ install_suse_11_git_deps() {
__PACKAGES="${__PACKAGES} python-pyzmq python-xml python-zypp"
if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then
# We're on the develop branch, install whichever tornado is on the requirements file
# We're on the master branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")"
if [ "${__REQUIRED_TORNADO}" != "" ]; then
__PACKAGES="${__PACKAGES} python-tornado"
@ -6646,6 +6866,10 @@ install_macosx_git_deps() {
__git_clone_and_checkout || return 1
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
return 0
fi
__PIP_REQUIREMENTS="dev_python27.txt"
if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then
__PIP_REQUIREMENTS="dev_python34.txt"
@ -6675,6 +6899,11 @@ install_macosx_git() {
_PYEXE=python2.7
fi
if [ "${_POST_NEON_INSTALL}" -eq $BS_TRUE ]; then
__install_salt_from_repo_post_neon "${_PY_EXE}" || return 1
return 0
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=/opt/salt || return 1
else

View file

@ -484,9 +484,8 @@ class WaitIterator(object):
self.current_future = done
self.current_index = self._unfinished.pop(done)
@coroutine
def __aiter__(self):
raise Return(self)
raise self
def __anext__(self):
if self.done():

View file

@ -23,7 +23,7 @@ loops.
from __future__ import absolute_import, division, print_function
import functools
import tornado.concurrent
import salt.ext.tornado.concurrent
from salt.ext.tornado.gen import convert_yielded
from salt.ext.tornado.ioloop import IOLoop
from salt.ext.tornado import stack_context
@ -199,8 +199,8 @@ def to_tornado_future(asyncio_future):
.. versionadded:: 4.1
"""
tf = tornado.concurrent.Future()
tornado.concurrent.chain_future(asyncio_future, tf)
tf = salt.ext.tornado.concurrent.Future()
salt.ext.tornado.concurrent.chain_future(asyncio_future, tf)
return tf
@ -215,7 +215,7 @@ def to_asyncio_future(tornado_future):
"""
tornado_future = convert_yielded(tornado_future)
af = asyncio.Future()
tornado.concurrent.chain_future(tornado_future, af)
salt.ext.tornado.concurrent.chain_future(tornado_future, af)
return af

View file

@ -254,7 +254,6 @@ class Queue(object):
"""
return self._finished.wait(timeout)
@gen.coroutine
def __aiter__(self):
return _QueueIterator(self)

View file

@ -47,7 +47,8 @@ class AsyncIOLoopTest(AsyncTestCase):
if hasattr(asyncio, 'ensure_future'):
ensure_future = asyncio.ensure_future
else:
ensure_future = asyncio.async
# async is a reserved word in Python 3.7
ensure_future = getattr(asyncio, "async")
x = yield ensure_future(
asyncio.get_event_loop().run_in_executor(None, lambda: 42))

View file

@ -34,7 +34,7 @@ Ensure a Linux ACL list is present
acl.list_present:
- name: /root
- acl_type: user
- acl_name:
- acl_names:
- damian
- homer
- perms: rwx
@ -47,7 +47,7 @@ Ensure a Linux ACL list does not exist
acl.list_absent:
- name: /root
- acl_type: user
- acl_name:
- acl_names:
- damian
- homer
- perms: rwx
@ -233,7 +233,7 @@ def absent(name, acl_type, acl_name='', perms='', recurse=False):
acl_type
The type of the acl is used for, it can be 'user' or 'group'
acl_names
acl_name
The user or group
perms
@ -390,11 +390,11 @@ def list_present(name, acl_type, acl_names=None, perms='', recurse=False, force=
# The getfacl execution module lists default with empty names as being
# applied to the user/group that owns the file, e.g.,
# default:group::rwx would be listed as default:group:root:rwx
# In this case, if acl_name is empty, we really want to search for root
# In this case, if acl_names is empty, we really want to search for root
# but still uses '' for other
# We search through the dictionary getfacl returns for the owner of the
# file if acl_name is empty.
# file if acl_names is empty.
if acl_names == '':
_search_names = __current_perms[name].get('comment').get(_acl_type, '')
else:
@ -553,11 +553,11 @@ def list_absent(name, acl_type, acl_names=None, recurse=False):
# The getfacl execution module lists default with empty names as being
# applied to the user/group that owns the file, e.g.,
# default:group::rwx would be listed as default:group:root:rwx
# In this case, if acl_name is empty, we really want to search for root
# In this case, if acl_names is empty, we really want to search for root
# but still uses '' for other
# We search through the dictionary getfacl returns for the owner of the
# file if acl_name is empty.
# file if acl_names is empty.
if not acl_names:
_search_names = set(__current_perms[name].get('comment').get(_acl_type, ''))
else:

View file

@ -1,16 +1,23 @@
# -*- coding: utf-8 -*-
# Import Python libs
from __future__ import absolute_import, unicode_literals
import os
import sys
import logging
import subprocess
import tempfile
# Import Salt Testing libs
from tests.support.unit import TestCase, skipIf
from tests.support.runtests import RUNTIME_VARS
import tests.support.helpers
# Import Salt libs
import salt.ext.six
import salt.modules.cmdmod
import salt.utils.platform
import salt.utils.files
log = logging.getLogger(__name__)
@ -21,6 +28,42 @@ class VendorTornadoTest(TestCase):
Ensure we are not using any non vendor'ed tornado
'''
def test_import_override(self):
tmp = tempfile.mkdtemp()
test_source = tests.support.helpers.dedent('''
from __future__ import absolute_import, print_function
import salt
import tornado
print(tornado.__name__)
''')
test_source_path = os.path.join(tmp, 'test.py')
tornado_source = tests.support.helpers.dedent('''
foo = 'bar'
''')
tornado_source_path = os.path.join(tmp, 'tornado.py')
with salt.utils.files.fopen(test_source_path, 'w') as fp:
fp.write(test_source)
with salt.utils.files.fopen(tornado_source_path, 'w') as fp:
fp.write(tornado_source)
# Preserve the virtual environment
env = os.environ.copy()
if salt.utils.platform.is_windows():
if salt.ext.six.PY2:
env[b'PYTHONPATH'] = b';'.join([a.encode() for a in sys.path])
else:
env['PYTHONPATH'] = ';'.join(sys.path)
else:
env['PYTHONPATH'] = ':'.join(sys.path)
p = subprocess.Popen(
[sys.executable, test_source_path],
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
env=env
)
p.wait()
pout = p.stdout.read().strip().decode()
assert pout == 'salt.ext.tornado', pout
def test_vendored_tornado_import(self):
grep_call = salt.modules.cmdmod.run_stdout(
cmd='bash -c \'grep -r "import tornado" ./salt/*\'',