mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Merge branch '2016.3' into 'develop'
Conflicts: - doc/conf.py - doc/topics/reactor/index.rst - tests/integration/__init__.py
This commit is contained in:
commit
49f40e9d99
@ -144,6 +144,8 @@ MOCK_MODULES = [
|
||||
'netaddr.IPAddress',
|
||||
'netaddr.core',
|
||||
'netaddr.core.AddrFormatError',
|
||||
'pyroute2',
|
||||
'pyroute2.ipdb',
|
||||
]
|
||||
|
||||
for mod_name in MOCK_MODULES:
|
||||
|
@ -1264,6 +1264,10 @@ Example:
|
||||
- roots
|
||||
- git
|
||||
|
||||
.. note::
|
||||
For masterless Salt, this parameter must be specified in the minion config
|
||||
file.
|
||||
|
||||
.. conf_master:: fileserver_followsymlinks
|
||||
|
||||
``fileserver_followsymlinks``
|
||||
@ -1431,6 +1435,10 @@ Example:
|
||||
- /srv/salt/prod/services
|
||||
- /srv/salt/prod/states
|
||||
|
||||
.. note::
|
||||
For masterless Salt, this parameter must be specified in the minion config
|
||||
file.
|
||||
|
||||
git: Git Remote File Server Backend
|
||||
-----------------------------------
|
||||
|
||||
|
@ -3,4 +3,3 @@ salt.fileserver.azurefs
|
||||
=======================
|
||||
|
||||
.. automodule:: salt.fileserver.azurefs
|
||||
:members:
|
@ -3,4 +3,3 @@ salt.fileserver.gitfs
|
||||
=====================
|
||||
|
||||
.. automodule:: salt.fileserver.gitfs
|
||||
:members:
|
@ -3,4 +3,3 @@ salt.fileserver.hgfs
|
||||
====================
|
||||
|
||||
.. automodule:: salt.fileserver.hgfs
|
||||
:members:
|
@ -3,4 +3,3 @@ salt.fileserver.minionfs
|
||||
========================
|
||||
|
||||
.. automodule:: salt.fileserver.minionfs
|
||||
:members:
|
@ -3,4 +3,3 @@ salt.fileserver.roots
|
||||
=====================
|
||||
|
||||
.. automodule:: salt.fileserver.roots
|
||||
:members:
|
@ -3,4 +3,3 @@ salt.fileserver.s3fs
|
||||
====================
|
||||
|
||||
.. automodule:: salt.fileserver.s3fs
|
||||
:members:
|
@ -3,4 +3,3 @@ salt.fileserver.svnfs
|
||||
=====================
|
||||
|
||||
.. automodule:: salt.fileserver.svnfs
|
||||
:members:
|
@ -50,8 +50,8 @@ With this configuration, the environments and files defined in the
|
||||
not found then the git repositories defined in :conf_master:`gitfs_remotes`
|
||||
will be searched.
|
||||
|
||||
Environments
|
||||
------------
|
||||
Defining Environments
|
||||
---------------------
|
||||
|
||||
Just as the order of the values in :conf_master:`fileserver_backend` matters,
|
||||
so too does the order in which different sources are defined within a
|
||||
|
89
doc/ref/file_server/environments.rst
Normal file
89
doc/ref/file_server/environments.rst
Normal file
@ -0,0 +1,89 @@
|
||||
.. _file-server-environments:
|
||||
|
||||
===========================================
|
||||
Requesting Files from Specific Environments
|
||||
===========================================
|
||||
|
||||
The Salt fileserver supports multiple environments, allowing for SLS files and
|
||||
other files to be isolated for better organization.
|
||||
|
||||
For the default backend (called :py:mod:`roots <salt.fileserver.roots>`),
|
||||
environments are defined using the :conf_master:`roots <file_roots>` option.
|
||||
Other backends (such as :py:mod:`gitfs <salt.fileserver.gitfs>`) define
|
||||
environments in their own ways. For a list of available fileserver backends,
|
||||
see :ref:`here <all-salt.fileserver>`.
|
||||
|
||||
.. _querystring-syntax:
|
||||
|
||||
Querystring Syntax
|
||||
==================
|
||||
|
||||
Any ``salt://`` file URL can specify its fileserver environment using a
|
||||
querystring syntax, like so:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt://path/to/file?saltenv=foo
|
||||
|
||||
In :ref:`Reactor <reactor>` configurations, this method must be used to pull
|
||||
files from an environment other than ``base``.
|
||||
|
||||
In States
|
||||
=========
|
||||
|
||||
Minions can be instructed which environment to use both globally, and for a
|
||||
single state, and multiple methods for each are available:
|
||||
|
||||
Globally
|
||||
--------
|
||||
|
||||
A minion can be pinned to an environment using the :conf_minion:`environment`
|
||||
option in the minion config file.
|
||||
|
||||
Additionally, the environment can be set for a single call to the following
|
||||
functions:
|
||||
|
||||
- :py:mod:`state.apply <salt.modules.state.apply>`
|
||||
- :py:mod:`state.highstate <salt.modules.state.highstate>`
|
||||
- :py:mod:`state.sls <salt.modules.state.sls>`
|
||||
- :py:mod:`state.top <salt.modules.state.top>`
|
||||
|
||||
.. note::
|
||||
When the ``saltenv`` parameter is used to trigger a :ref:`highstate
|
||||
<running-highstate>` using either :py:mod:`state.apply
|
||||
<salt.modules.state.apply>` or :py:mod:`state.highstate
|
||||
<salt.modules.state.highstate>`, only states from that environment will be
|
||||
applied.
|
||||
|
||||
On a Per-State Basis
|
||||
--------------------
|
||||
|
||||
Within an individual state, there are two ways of specifying the environment.
|
||||
The first is to add a ``saltenv`` argument to the state. This example will pull
|
||||
the file from the ``config`` environment:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
/etc/foo/bar.conf:
|
||||
file.managed:
|
||||
- source: salt://foo/bar.conf
|
||||
- user: foo
|
||||
- mode: 600
|
||||
- saltenv: config
|
||||
|
||||
Another way of doing the same thing is to use the :ref:`querystring syntax
|
||||
<querystring-syntax>` described above:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
/etc/foo/bar.conf:
|
||||
file.managed:
|
||||
- source: salt://foo/bar.conf?saltenv=config
|
||||
- user: foo
|
||||
- mode: 600
|
||||
|
||||
.. note::
|
||||
Specifying the environment using either of the above methods is only
|
||||
necessary in cases where a state from one environment needs to access files
|
||||
from another environment. If the SLS file containing this state was in the
|
||||
``config`` environment, then it would look in that environment by default.
|
@ -57,10 +57,13 @@ and each event tag has a list of reactor SLS files to be run.
|
||||
- /srv/reactor/destroy/*.sls # Globs can be used to match file names
|
||||
|
||||
- 'myco/custom/event/tag': # React to custom event tags
|
||||
- salt://_reactor/mycustom.sls # Put reactor files under file_roots. Can be served from any filserver backend (GitFS, etc.)
|
||||
|
||||
|
||||
- salt://reactor/mycustom.sls # Reactor files can come from the salt fileserver
|
||||
|
||||
.. note::
|
||||
In the above example, ``salt://reactor/mycustom.sls`` refers to the
|
||||
``base`` environment. To pull this file from a different environment, use
|
||||
the :ref:`querystring syntax <querystring-syntax>` (e.g.
|
||||
``salt://reactor/mycustom.sls?saltenv=reactor``).
|
||||
|
||||
Reactor sls files are similar to state and pillar sls files. They are
|
||||
by default yaml + Jinja templates and are passed familiar context variables.
|
||||
|
@ -78,6 +78,12 @@ environments, allowing them to be pushed to QA hosts and tested.
|
||||
Finally, if moved to the same relative path within ``/srv/salt/prod``, the
|
||||
files are now available in all three environments.
|
||||
|
||||
Requesting files from specific fileserver environments
|
||||
======================================================
|
||||
|
||||
See :ref:`here <file-server-environments>` for documentation on how to request
|
||||
files from specific environments.
|
||||
|
||||
Practical Example
|
||||
=================
|
||||
|
||||
|
@ -18,11 +18,11 @@
|
||||
#======================================================================================================================
|
||||
set -o nounset # Treat unset variables as an error
|
||||
|
||||
__ScriptVersion="2016.06.27"
|
||||
__ScriptVersion="2016.07.07"
|
||||
__ScriptName="bootstrap-salt.sh"
|
||||
|
||||
__ScriptFullName="${0}"
|
||||
__ScriptArgs="${*}"
|
||||
__ScriptFullName="$0"
|
||||
__ScriptArgs="$*"
|
||||
|
||||
#======================================================================================================================
|
||||
# Environment variables taken into account.
|
||||
@ -630,7 +630,7 @@ fi
|
||||
|
||||
echoinfo "Running version: ${__ScriptVersion}"
|
||||
echoinfo "Executed by: ${CALLER}"
|
||||
echoinfo "Command line: \"${__ScriptFullName} ${__ScriptArgs}\""
|
||||
echoinfo "Command line: '${__ScriptFullName} ${__ScriptArgs}'"
|
||||
#echowarn "Running the unstable version of ${__ScriptName}"
|
||||
|
||||
#--- FUNCTION -------------------------------------------------------------------------------------------------------
|
||||
@ -1180,6 +1180,7 @@ __ubuntu_derivatives_translation() {
|
||||
|
||||
linuxmint_16_ubuntu_base="13.10"
|
||||
linuxmint_17_ubuntu_base="14.04"
|
||||
linuxmint_18_ubuntu_base="16.04"
|
||||
linaro_12_ubuntu_base="12.04"
|
||||
elementary_os_02_ubuntu_base="12.04"
|
||||
|
||||
@ -2366,6 +2367,11 @@ install_ubuntu_stable_deps() {
|
||||
set -o nounset
|
||||
fi
|
||||
|
||||
# Make sure https transport is available
|
||||
if [ "$HTTP_VAL" = "https" ] ; then
|
||||
__apt_get_install_noinput ca-certificates apt-transport-https || return 1
|
||||
fi
|
||||
|
||||
# Make sure wget is available
|
||||
__apt_get_install_noinput wget
|
||||
|
||||
@ -2714,6 +2720,8 @@ 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
|
||||
echoerror "repo.saltstack.com likely doesn't have 32-bit packages for Debian (yet?)"
|
||||
repo_arch="i386"
|
||||
@ -2790,6 +2798,8 @@ 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
|
||||
echoerror "repo.saltstack.com likely doesn't have 32-bit packages for Debian (yet?)"
|
||||
repo_arch="i386"
|
||||
@ -3113,7 +3123,13 @@ install_fedora_deps() {
|
||||
__install_saltstack_copr_salt_repository || return 1
|
||||
fi
|
||||
|
||||
__PACKAGES="yum-utils PyYAML libyaml m2crypto python-crypto python-jinja2 python-msgpack python-zmq python-requests"
|
||||
__PACKAGES="yum-utils PyYAML libyaml m2crypto python-crypto python-jinja2 python-zmq"
|
||||
|
||||
if [ "$DISTRO_MAJOR_VERSION" -ge 23 ]; then
|
||||
__PACKAGES="${__PACKAGES} python2-msgpack python2-requests"
|
||||
else
|
||||
__PACKAGES="${__PACKAGES} python-msgpack python-requests"
|
||||
fi
|
||||
|
||||
if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then
|
||||
__PACKAGES="${__PACKAGES} python-libcloud"
|
||||
@ -4082,6 +4098,14 @@ _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
|
||||
@ -4098,7 +4122,6 @@ install_amazon_linux_ami_git_deps() {
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Let's trigger config_salt()
|
||||
if [ "$_TEMP_CONFIG_DIR" = "null" ]; then
|
||||
_TEMP_CONFIG_DIR="${_SALT_GIT_CHECKOUT_DIR}/conf/"
|
||||
@ -4410,7 +4433,7 @@ __configure_freebsd_pkg_details() {
|
||||
echo " url: \"${SALTPKGCONFURL}\","
|
||||
echo " mirror_type: \"http\","
|
||||
echo " enabled: true"
|
||||
echo " prioroity: 10"
|
||||
echo " priority: 10"
|
||||
echo "}"
|
||||
} > $salt_conf_file
|
||||
FROM_SALTSTACK="-r SaltStack"
|
||||
@ -5204,7 +5227,16 @@ install_opensuse_git_post() {
|
||||
[ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue
|
||||
|
||||
if [ -f /bin/systemctl ]; then
|
||||
use_usr_lib=$BS_FALSE
|
||||
if [ "${DISTRO_MAJOR_VERSION}" -gt 13 ] || ([ "${DISTRO_MAJOR_VERSION}" -eq 13 ] && [ "${DISTRO_MINOR_VERSION}" -ge 2 ]); then
|
||||
use_usr_lib=$BS_TRUE
|
||||
fi
|
||||
|
||||
if [ "${DISTRO_MAJOR_VERSION}" -eq 12 ] && [ -d "/usr/lib/systemd/" ]; then
|
||||
use_usr_lib=$BS_TRUE
|
||||
fi
|
||||
|
||||
if [ "${use_usr_lib}" -eq $BS_TRUE ]; then
|
||||
__copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/salt-${fname}.service" "/usr/lib/systemd/system/salt-${fname}.service"
|
||||
else
|
||||
__copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/salt-${fname}.service" "/lib/systemd/system/salt-${fname}.service"
|
||||
@ -5371,7 +5403,7 @@ install_suse_12_stable_deps() {
|
||||
}
|
||||
|
||||
install_suse_12_git_deps() {
|
||||
install_suse_11_stable_deps || return 1
|
||||
install_suse_12_stable_deps || return 1
|
||||
|
||||
if ! __check_command_exists git; then
|
||||
__zypper_install git || return 1
|
||||
|
@ -1332,18 +1332,30 @@ def upgrade_available(name):
|
||||
return latest_version(name) != ''
|
||||
|
||||
|
||||
def version_cmp(pkg1, pkg2):
|
||||
def version_cmp(pkg1, pkg2, ignore_epoch=False):
|
||||
'''
|
||||
Do a cmp-style comparison on two packages. Return -1 if pkg1 < pkg2, 0 if
|
||||
pkg1 == pkg2, and 1 if pkg1 > pkg2. Return None if there was a problem
|
||||
making the comparison.
|
||||
|
||||
ignore_epoch : False
|
||||
Set to ``True`` to ignore the epoch when comparing versions
|
||||
|
||||
.. versionadded:: 2015.8.10,2016.3.2
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' pkg.version_cmp '0.2.4-0ubuntu1' '0.2.4.1-0ubuntu1'
|
||||
'''
|
||||
normalize = lambda x: str(x).split(':', 1)[-1] if ignore_epoch else str(x)
|
||||
# both apt_pkg.version_compare and _cmd_quote need string arguments.
|
||||
pkg1 = normalize(pkg1)
|
||||
pkg2 = normalize(pkg2)
|
||||
|
||||
# if we have apt_pkg, this will be quickier this way
|
||||
# and also do not rely on shell.
|
||||
if HAS_APTPKG:
|
||||
try:
|
||||
# the apt_pkg module needs to be manually initialized
|
||||
|
@ -195,6 +195,20 @@ def get_file(path,
|
||||
Use the *gzip* named argument to enable it. Valid values are 1..9, where 1
|
||||
is the lightest compression and 9 the heaviest. 1 uses the least CPU on
|
||||
the master (and minion), 9 uses the most.
|
||||
|
||||
There are two ways of defining the fileserver environment (a.k.a.
|
||||
``saltenv``) from which to retrieve the file. One is to use the ``saltenv``
|
||||
parameter, and the other is to use a querystring syntax in the ``salt://``
|
||||
URL. The below two examples are equivalent:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' cp.get_file salt://foo/bar.conf /etc/foo/bar.conf saltenv=config
|
||||
salt '*' cp.get_file salt://foo/bar.conf?saltenv=config /etc/foo/bar.conf
|
||||
|
||||
.. note::
|
||||
It may be necessary to quote the URL when using the querystring method,
|
||||
depending on the shell being used to run the command.
|
||||
'''
|
||||
if env is not None:
|
||||
salt.utils.warn_until(
|
||||
@ -357,6 +371,20 @@ def cache_file(path, saltenv='base', env=None):
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' cp.cache_file salt://path/to/file
|
||||
|
||||
There are two ways of defining the fileserver environment (a.k.a.
|
||||
``saltenv``) from which to cache the file. One is to use the ``saltenv``
|
||||
parameter, and the other is to use a querystring syntax in the ``salt://``
|
||||
URL. The below two examples are equivalent:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' cp.cache_file salt://foo/bar.conf saltenv=config
|
||||
salt '*' cp.cache_file salt://foo/bar.conf?saltenv=config
|
||||
|
||||
.. note::
|
||||
It may be necessary to quote the URL when using the querystring method,
|
||||
depending on the shell being used to run the command.
|
||||
'''
|
||||
if env is not None:
|
||||
salt.utils.warn_until(
|
||||
@ -415,6 +443,30 @@ def cache_files(paths, saltenv='base', env=None):
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' cp.cache_files salt://pathto/file1,salt://pathto/file1
|
||||
|
||||
There are two ways of defining the fileserver environment (a.k.a.
|
||||
``saltenv``) from which to cache the files. One is to use the ``saltenv``
|
||||
parameter, and the other is to use a querystring syntax in the ``salt://``
|
||||
URL. The below two examples are equivalent:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' cp.cache_files salt://foo/bar.conf,salt://foo/baz.conf saltenv=config
|
||||
salt '*' cp.cache_files salt://foo/bar.conf?saltenv=config,salt://foo/baz.conf?saltenv=config
|
||||
|
||||
The querystring method is less useful when all files are being cached from
|
||||
the same environment, but is a good way of caching files from multiple
|
||||
different environments in the same command. For example, the below command
|
||||
will cache the first file from the ``config1`` environment, and the second
|
||||
one from the ``config2`` environment.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' cp.cache_files salt://foo/bar.conf?saltenv=config1,salt://foo/bar.conf?saltenv=config2
|
||||
|
||||
.. note::
|
||||
It may be necessary to quote the URL when using the querystring method,
|
||||
depending on the shell being used to run the command.
|
||||
'''
|
||||
if env is not None:
|
||||
salt.utils.warn_until(
|
||||
|
@ -110,17 +110,18 @@ Both methods can be combined; any registry configured under
|
||||
Configuration Options
|
||||
---------------------
|
||||
|
||||
The following options can be set in the :ref:`minion config
|
||||
<configuration-salt-minion>`:
|
||||
The following configuration options can be set to fine-tune how Salt uses
|
||||
Docker:
|
||||
|
||||
- ``docker.url``: URL to the docker service (default: local socket).
|
||||
- ``docker.version``: API version to use (default: currently 1.4 API).
|
||||
- ``docker.exec_driver``: Execution driver to use, one of the following:
|
||||
- nsenter
|
||||
- lxc-attach
|
||||
- docker-exec
|
||||
- ``docker.version``: API version to use
|
||||
- ``docker.exec_driver``: Execution driver to use, one of ``nsenter``,
|
||||
``lxc-attach``, or ``docker-exec``. See the :ref:`Executing Commands Within a
|
||||
Running Container <docker-execution-driver>` section for more details on how
|
||||
this config parameter is used.
|
||||
|
||||
See :ref:`Executing Commands Within a Running Container <docker-execution-driver>`.
|
||||
These configuration options are retrieved using :py:mod:`config.get
|
||||
<salt.modules.config.get>` (click the link for further information).
|
||||
|
||||
Functions
|
||||
---------
|
||||
@ -823,6 +824,14 @@ def _get_exec_driver():
|
||||
__context__[contextkey] = 'lxc-attach'
|
||||
elif driver.startswith('native-') and HAS_NSENTER:
|
||||
__context__[contextkey] = 'nsenter'
|
||||
elif not driver.strip() and HAS_NSENTER:
|
||||
log.warning(
|
||||
'ExecutionDriver from \'docker info\' is blank, falling '
|
||||
'back to using \'nsenter\'. To squelch this warning, set '
|
||||
'docker.exec_driver. See the Salt documentation for the '
|
||||
'dockerng module for more information.'
|
||||
)
|
||||
__context__[contextkey] = 'nsenter'
|
||||
else:
|
||||
raise NotImplementedError(
|
||||
'Unknown docker ExecutionDriver \'{0}\', or didn\'t find '
|
||||
|
@ -992,7 +992,7 @@ def depclean(name=None, slot=None, fromrepo=None, pkgs=None):
|
||||
return salt.utils.compare_dicts(old, new)
|
||||
|
||||
|
||||
def version_cmp(pkg1, pkg2):
|
||||
def version_cmp(pkg1, pkg2, **kwargs):
|
||||
'''
|
||||
Do a cmp-style comparison on two packages. Return -1 if pkg1 < pkg2, 0 if
|
||||
pkg1 == pkg2, and 1 if pkg1 > pkg2. Return None if there was a problem
|
||||
@ -1004,6 +1004,16 @@ def version_cmp(pkg1, pkg2):
|
||||
|
||||
salt '*' pkg.version_cmp '0.2.4-0' '0.2.4.1-0'
|
||||
'''
|
||||
# ignore_epoch is not supported here, but has to be included for API
|
||||
# compatibility. Rather than putting this argument into the function
|
||||
# definition (and thus have it show up in the docs), we just pop it out of
|
||||
# the kwargs dict and then raise an exception if any kwargs other than
|
||||
# ignore_epoch were passed.
|
||||
kwargs = salt.utils.clean_kwargs(**kwargs)
|
||||
kwargs.pop('ignore_epoch', None)
|
||||
if kwargs:
|
||||
salt.utils.invalid_kwargs(kwargs)
|
||||
|
||||
regex = r'^~?([^:\[]+):?[^\[]*\[?.*$'
|
||||
ver1 = re.match(regex, pkg1)
|
||||
ver2 = re.match(regex, pkg2)
|
||||
|
@ -497,7 +497,7 @@ def retention_policy_exists(database,
|
||||
|
||||
salt '*' influxdb.retention_policy_exists metrics default
|
||||
'''
|
||||
policy = retention_policy_get(name, database, user, password, host, port)
|
||||
policy = retention_policy_get(database, name, user, password, host, port)
|
||||
return policy is not None
|
||||
|
||||
|
||||
|
@ -608,7 +608,7 @@ def info(*packages, **attr):
|
||||
return ret
|
||||
|
||||
|
||||
def version_cmp(ver1, ver2):
|
||||
def version_cmp(ver1, ver2, ignore_epoch=False):
|
||||
'''
|
||||
.. versionadded:: 2015.8.9
|
||||
|
||||
@ -616,12 +616,21 @@ def version_cmp(ver1, ver2):
|
||||
ver1 == ver2, and 1 if ver1 > ver2. Return None if there was a problem
|
||||
making the comparison.
|
||||
|
||||
ignore_epoch : False
|
||||
Set to ``True`` to ignore the epoch when comparing versions
|
||||
|
||||
.. versionadded:: 2015.8.10,2016.3.2
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' pkg.version_cmp '0.2-001' '0.2.0.1-002'
|
||||
'''
|
||||
normalize = lambda x: str(x).split(':', 1)[-1] if ignore_epoch else str(x)
|
||||
ver1 = normalize(ver1)
|
||||
ver2 = normalize(ver2)
|
||||
|
||||
try:
|
||||
cmp_func = None
|
||||
if HAS_RPM:
|
||||
@ -694,7 +703,10 @@ def version_cmp(ver1, ver2):
|
||||
ver1, ver2, exc
|
||||
)
|
||||
|
||||
return salt.utils.version_cmp(ver1, ver2)
|
||||
# We would already have normalized the versions at the beginning of this
|
||||
# function if ignore_epoch=True, so avoid unnecessary work and just pass
|
||||
# False for this value.
|
||||
return salt.utils.version_cmp(ver1, ver2, ignore_epoch=False)
|
||||
|
||||
|
||||
def checksum(*paths):
|
||||
|
@ -520,7 +520,7 @@ def version(*names, **kwargs):
|
||||
return __salt__['pkg_resource.version'](*names, **kwargs)
|
||||
|
||||
|
||||
def version_cmp(pkg1, pkg2):
|
||||
def version_cmp(pkg1, pkg2, ignore_epoch=False):
|
||||
'''
|
||||
.. versionadded:: 2015.5.4
|
||||
|
||||
@ -528,6 +528,11 @@ def version_cmp(pkg1, pkg2):
|
||||
pkg1 == pkg2, and 1 if pkg1 > pkg2. Return None if there was a problem
|
||||
making the comparison.
|
||||
|
||||
ignore_epoch : False
|
||||
Set to ``True`` to ignore the epoch when comparing versions
|
||||
|
||||
.. versionadded:: 2015.8.10,2016.3.2
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
@ -535,7 +540,7 @@ def version_cmp(pkg1, pkg2):
|
||||
salt '*' pkg.version_cmp '0.2-001' '0.2.0.1-002'
|
||||
'''
|
||||
|
||||
return __salt__['lowpkg.version_cmp'](pkg1, pkg2)
|
||||
return __salt__['lowpkg.version_cmp'](pkg1, pkg2, ignore_epoch=ignore_epoch)
|
||||
|
||||
|
||||
def list_pkgs(versions_as_list=False, **kwargs):
|
||||
@ -1322,10 +1327,10 @@ def install(name=None,
|
||||
return ret
|
||||
|
||||
|
||||
def upgrade(refresh=True,
|
||||
skip_verify=False,
|
||||
name=None,
|
||||
def upgrade(name=None,
|
||||
pkgs=None,
|
||||
refresh=True,
|
||||
skip_verify=False,
|
||||
normalize=True,
|
||||
**kwargs):
|
||||
'''
|
||||
@ -1408,7 +1413,7 @@ def upgrade(refresh=True,
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt -G role:nsd pkg.install gpfs.gplbin-2.6.32-279.31.1.el6.x86_64 normalize=False
|
||||
salt -G role:nsd pkg.upgrade gpfs.gplbin-2.6.32-279.31.1.el6.x86_64 normalize=False
|
||||
|
||||
.. versionadded:: 2016.3.0
|
||||
|
||||
@ -1421,20 +1426,23 @@ def upgrade(refresh=True,
|
||||
refresh_db(**kwargs)
|
||||
|
||||
old = list_pkgs()
|
||||
try:
|
||||
pkg_params = __salt__['pkg_resource.parse_targets'](
|
||||
name=name,
|
||||
pkgs=pkgs,
|
||||
sources=None,
|
||||
normalize=normalize,
|
||||
**kwargs)[0]
|
||||
except MinionError as exc:
|
||||
raise CommandExecutionError(exc)
|
||||
|
||||
if pkg_params:
|
||||
targets = [x for x in pkg_params]
|
||||
else:
|
||||
targets = None
|
||||
targets = []
|
||||
if name or pkgs:
|
||||
try:
|
||||
pkg_params = __salt__['pkg_resource.parse_targets'](
|
||||
name=name,
|
||||
pkgs=pkgs,
|
||||
sources=None,
|
||||
normalize=normalize,
|
||||
**kwargs)[0]
|
||||
except MinionError as exc:
|
||||
raise CommandExecutionError(exc)
|
||||
|
||||
if pkg_params:
|
||||
# Calling list.extend() on a dict will extend it using the
|
||||
# dictionary's keys.
|
||||
targets.extend(pkg_params)
|
||||
|
||||
cmd = [_yum(), '--quiet', '-y']
|
||||
for args in (repo_arg, exclude_arg, branch_arg):
|
||||
@ -1443,8 +1451,7 @@ def upgrade(refresh=True,
|
||||
if skip_verify:
|
||||
cmd.append('--nogpgcheck')
|
||||
cmd.append('upgrade')
|
||||
if targets:
|
||||
cmd.extend(targets)
|
||||
cmd.extend(targets)
|
||||
|
||||
__salt__['cmd.run'](cmd, output_loglevel='trace', python_shell=False)
|
||||
__context__.pop('pkg.list_pkgs', None)
|
||||
|
@ -526,7 +526,7 @@ def version(*names, **kwargs):
|
||||
return __salt__['pkg_resource.version'](*names, **kwargs) or {}
|
||||
|
||||
|
||||
def version_cmp(ver1, ver2):
|
||||
def version_cmp(ver1, ver2, ignore_epoch=False):
|
||||
'''
|
||||
.. versionadded:: 2015.5.4
|
||||
|
||||
@ -534,13 +534,18 @@ def version_cmp(ver1, ver2):
|
||||
ver1 == ver2, and 1 if ver1 > ver2. Return None if there was a problem
|
||||
making the comparison.
|
||||
|
||||
ignore_epoch : False
|
||||
Set to ``True`` to ignore the epoch when comparing versions
|
||||
|
||||
.. versionadded:: 2015.8.10,2016.3.2
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' pkg.version_cmp '0.2-001' '0.2.0.1-002'
|
||||
'''
|
||||
return __salt__['lowpkg.version_cmp'](str(ver1), str(ver2))
|
||||
return __salt__['lowpkg.version_cmp'](ver1, ver2, ignore_epoch=ignore_epoch)
|
||||
|
||||
|
||||
def list_pkgs(versions_as_list=False, **kwargs):
|
||||
|
@ -440,6 +440,8 @@ def _compare(actual, create_kwargs, defaults_from_image):
|
||||
# "actual" dict sorted(somedict) still just gives you a sorted
|
||||
# list of the dictionary's keys. And we don't care about the
|
||||
# value for "volumes", just its keys.
|
||||
if actual_data is None:
|
||||
actual_data = []
|
||||
actual_data = sorted(actual_data)
|
||||
desired_data = sorted(data)
|
||||
log.trace('dockerng.running ({0}): munged actual value: {1}'
|
||||
|
@ -151,13 +151,13 @@ def _fulfills_version_spec(versions, oper, desired_version,
|
||||
Returns True if any of the installed versions match the specified version,
|
||||
otherwise returns False
|
||||
'''
|
||||
normalize = lambda x: x.split(':', 1)[-1] if ignore_epoch else x
|
||||
cmp_func = __salt__.get('pkg.version_cmp')
|
||||
for ver in versions:
|
||||
if salt.utils.compare_versions(ver1=normalize(ver),
|
||||
if salt.utils.compare_versions(ver1=ver,
|
||||
oper=oper,
|
||||
ver2=normalize(desired_version),
|
||||
cmp_func=cmp_func):
|
||||
ver2=desired_version,
|
||||
cmp_func=cmp_func,
|
||||
ignore_epoch=ignore_epoch):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -52,7 +52,7 @@ def present(name,
|
||||
'''
|
||||
Ensure that the named group is present with the specified privileges
|
||||
Please note that the user/group notion in postgresql is just abstract, we
|
||||
have roles, where users can be seens as roles with the LOGIN privilege
|
||||
have roles, where users can be seen as roles with the ``LOGIN`` privilege
|
||||
and groups the others.
|
||||
|
||||
name
|
||||
@ -84,14 +84,13 @@ def present(name,
|
||||
Should the new group be allowed to initiate streaming replication
|
||||
|
||||
password
|
||||
The Group's password
|
||||
The group's password
|
||||
It can be either a plain string or a md5 postgresql hashed password::
|
||||
|
||||
'md5{MD5OF({password}{role}}'
|
||||
|
||||
If encrypted is None or True, the password will be automatically
|
||||
encrypted to the previous
|
||||
format if it is not already done.
|
||||
If encrypted is ``None`` or ``True``, the password will be automatically
|
||||
encrypted to the previous format if it is not already done.
|
||||
|
||||
refresh_password
|
||||
Password refresh flag
|
||||
@ -114,7 +113,7 @@ def present(name,
|
||||
.. versionadded:: 0.17.0
|
||||
|
||||
db_user
|
||||
database username if different from config or defaul
|
||||
database username if different from config or default
|
||||
|
||||
db_password
|
||||
user password if any password for a specified user
|
||||
|
@ -2325,7 +2325,7 @@ def kwargs_warn_until(kwargs,
|
||||
)
|
||||
|
||||
|
||||
def version_cmp(pkg1, pkg2):
|
||||
def version_cmp(pkg1, pkg2, ignore_epoch=False):
|
||||
'''
|
||||
Compares two version strings using distutils.version.LooseVersion. This is
|
||||
a fallback for providers which don't have a version comparison utility
|
||||
@ -2333,6 +2333,10 @@ def version_cmp(pkg1, pkg2):
|
||||
version2, and 1 if version1 > version2. Return None if there was a problem
|
||||
making the comparison.
|
||||
'''
|
||||
normalize = lambda x: str(x).split(':', 1)[-1] if ignore_epoch else str(x)
|
||||
pkg1 = normalize(pkg1)
|
||||
pkg2 = normalize(pkg2)
|
||||
|
||||
try:
|
||||
# pylint: disable=no-member
|
||||
if distutils.version.LooseVersion(pkg1) < \
|
||||
@ -2349,22 +2353,25 @@ def version_cmp(pkg1, pkg2):
|
||||
return None
|
||||
|
||||
|
||||
def compare_versions(ver1='', oper='==', ver2='', cmp_func=None):
|
||||
def compare_versions(ver1='',
|
||||
oper='==',
|
||||
ver2='',
|
||||
cmp_func=None,
|
||||
ignore_epoch=False):
|
||||
'''
|
||||
Compares two version numbers. Accepts a custom function to perform the
|
||||
cmp-style version comparison, otherwise uses version_cmp().
|
||||
'''
|
||||
cmp_map = {'<': (-1,), '<=': (-1, 0), '==': (0,),
|
||||
'>=': (0, 1), '>': (1,)}
|
||||
if oper not in ['!='] and oper not in cmp_map:
|
||||
log.error('Invalid operator "{0}" for version '
|
||||
'comparison'.format(oper))
|
||||
if oper not in ('!=',) and oper not in cmp_map:
|
||||
log.error('Invalid operator \'%s\' for version comparison', oper)
|
||||
return False
|
||||
|
||||
if cmp_func is None:
|
||||
cmp_func = version_cmp
|
||||
|
||||
cmp_result = cmp_func(ver1, ver2)
|
||||
cmp_result = cmp_func(ver1, ver2, ignore_epoch=ignore_epoch)
|
||||
if cmp_result is None:
|
||||
return False
|
||||
|
||||
|
@ -489,9 +489,9 @@ class SaltEvent(object):
|
||||
break
|
||||
mtag, data = self.unpack(raw, self.serial)
|
||||
ret = {'data': data, 'tag': mtag}
|
||||
except (KeyboardInterrupt, RuntimeError):
|
||||
except KeyboardInterrupt:
|
||||
return {'tag': 'salt/event/exit', 'data': {}}
|
||||
except tornado.iostream.StreamClosedError:
|
||||
except (tornado.iostream.StreamClosedError, RuntimeError):
|
||||
return None
|
||||
|
||||
if not match_func(ret['tag'], tag):
|
||||
|
@ -29,7 +29,7 @@ from salt.ext.six.moves import range
|
||||
from salt.config import minion_config
|
||||
# pylint: enable=no-name-in-module,redefined-builtin
|
||||
|
||||
from salt.loader import LazyLoader, _module_dirs, grains
|
||||
from salt.loader import LazyLoader, _module_dirs, grains, utils, proxy, minion_mods
|
||||
|
||||
loader_template = '''
|
||||
import os
|
||||
@ -249,9 +249,15 @@ class LazyLoaderReloadingTest(TestCase):
|
||||
|
||||
dirs = _module_dirs(self.opts, 'modules', 'module')
|
||||
dirs.append(self.tmp_dir)
|
||||
self.utils = utils(self.opts)
|
||||
self.proxy = proxy(self.opts)
|
||||
self.minion_mods = minion_mods(self.opts)
|
||||
self.loader = LazyLoader(dirs,
|
||||
self.opts,
|
||||
tag='module')
|
||||
tag='module',
|
||||
pack={'__utils__': self.utils,
|
||||
'__proxy__': self.proxy,
|
||||
'__salt__': self.minion_mods})
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tmp_dir)
|
||||
@ -376,9 +382,16 @@ class LazyLoaderSubmodReloadingTest(TestCase):
|
||||
|
||||
dirs = _module_dirs(self.opts, 'modules', 'module')
|
||||
dirs.append(self.tmp_dir)
|
||||
self.utils = utils(self.opts)
|
||||
self.proxy = proxy(self.opts)
|
||||
self.minion_mods = minion_mods(self.opts)
|
||||
self.loader = LazyLoader(dirs,
|
||||
self.opts,
|
||||
tag='module')
|
||||
tag='module',
|
||||
pack={'__utils__': self.utils,
|
||||
'__proxy__': self.proxy,
|
||||
'__salt__': self.minion_mods}
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tmp_dir)
|
||||
@ -620,9 +633,16 @@ class LazyLoaderDeepSubmodReloadingTest(TestCase):
|
||||
|
||||
dirs = _module_dirs(self.opts, 'modules', 'module')
|
||||
dirs.append(self.tmp_dir)
|
||||
self.utils = utils(self.opts)
|
||||
self.proxy = proxy(self.opts)
|
||||
self.minion_mods = minion_mods(self.opts)
|
||||
self.loader = LazyLoader(dirs,
|
||||
self.opts,
|
||||
tag='module')
|
||||
tag='module',
|
||||
pack={'__utils__': self.utils,
|
||||
'__proxy__': self.proxy,
|
||||
'__salt__': self.minion_mods}
|
||||
)
|
||||
|
||||
@property
|
||||
def module_dir(self):
|
||||
|
@ -567,16 +567,23 @@ class PkgTest(integration.ModuleCase,
|
||||
|
||||
# Now look for updates and try to run the state on a package which is
|
||||
# already up-to-date.
|
||||
installed_pkgs = self.run_function('pkg.list_pkgs')
|
||||
updates = self.run_function('pkg.list_upgrades', refresh=False)
|
||||
try:
|
||||
target = next(iter(updates))
|
||||
except StopIteration:
|
||||
log.warning(
|
||||
'No available upgrades, skipping only_upgrade=True test with '
|
||||
'already-installed package. For best results run this test '
|
||||
'on a machine with upgrades available.'
|
||||
)
|
||||
|
||||
for pkgname in updates:
|
||||
if pkgname in installed_pkgs:
|
||||
target = pkgname
|
||||
break
|
||||
else:
|
||||
target = ''
|
||||
log.warning(
|
||||
'No available upgrades to installed packages, skipping '
|
||||
'only_upgrade=True test with already-installed package. For '
|
||||
'best results run this test on a machine with upgrades '
|
||||
'available.'
|
||||
)
|
||||
|
||||
if target:
|
||||
ret = self.run_state('pkg.latest', name=target, refresh=False,
|
||||
only_upgrade=True)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
@ -24,7 +24,7 @@ import salt.utils
|
||||
|
||||
KNOWN_HOSTS = os.path.join(integration.TMP, 'known_hosts')
|
||||
GITHUB_FINGERPRINT = '16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48'
|
||||
GITHUB_IP = '192.30.252.129'
|
||||
GITHUB_IP = '192.30.253.113'
|
||||
|
||||
|
||||
@skip_if_binaries_missing(['ssh', 'ssh-keygen'], check_all=True)
|
||||
|
@ -63,6 +63,7 @@ class DockerngTestCase(TestCase):
|
||||
all=True,
|
||||
filters={'label': 'KEY'})
|
||||
|
||||
@skipIf(_docker_py_version() is None, 'docker-py needs to be installed for this test to run')
|
||||
@patch.object(dockerng_mod, '_get_exec_driver')
|
||||
def test_check_mine_cache_is_refreshed_on_container_change_event(self, _):
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user