Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[2016.3] Merge forward from 2015.8 to 2016.3 #34619

Merged
merged 19 commits into from
Jul 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
07368fa
Accept ignore_epoch argument for salt.utils.compare_versions()
terminalmage Jul 7, 2016
5b123b4
Pass ignore_epoch to salt.utils.compare_versions()
terminalmage Jul 7, 2016
4ee8e8f
salt/modules/aptpkg.py: accept ignore_epoch argument
terminalmage Jul 7, 2016
c5de8b8
salt/modules/ebuild.py: accept ignore_epoch argument
terminalmage Jul 7, 2016
c279111
salt/modules/rpm.py: accept ignore_epoch argument
terminalmage Jul 7, 2016
5ae9463
salt/modules/yumpkg.py: accept ignore_epoch argument
terminalmage Jul 7, 2016
d0fec1b
salt/modules/zypper.py: accept ignore_epoch argument
terminalmage Jul 7, 2016
dd5838e
Handle cases where Docker Remote API returns an empty ExecutionDriver
terminalmage Jul 8, 2016
e99befa
Merge pull request #34545 from terminalmage/docker-exec-driver
Jul 8, 2016
91e0656
Merge pull request #34531 from terminalmage/issue34397
Jul 8, 2016
ae38c87
Add a bunch of documentation on getting files from other environments…
Jul 8, 2016
7dd8035
Gate docker unit test to check for docker (#34591)
Jul 12, 2016
2e10072
Avoid circular imports when calling salt.utils functions (#34584)
Jul 12, 2016
12b579c
When sorting list actual_data, make it a list (#34590)
oeuftete Jul 12, 2016
57df38e
Update github IP for ssh state integration tests (#34592)
Jul 12, 2016
b90ae40
Add support for edge case when Cmd and Entrypoint can't be blanked (#…
Jul 12, 2016
3026df3
Merge branch '2015.5' into '2015.8'
Jul 12, 2016
9f12354
Merge pull request #34617 from rallytime/merge-2015.8
Jul 12, 2016
f734afd
Merge branch '2015.8' into '2016.3'
Jul 12, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/ref/configuration/master.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,10 @@ Example:
- roots
- git

.. note::
For masterless Salt, this parameter must be specified in the minion config
file.

.. conf_master:: fileserver_followsymlinks

``fileserver_followsymlinks``
Expand Down Expand Up @@ -1399,6 +1403,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
-----------------------------------

Expand Down
1 change: 0 additions & 1 deletion doc/ref/file_server/all/salt.fileserver.azurefs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ salt.fileserver.azurefs
=======================

.. automodule:: salt.fileserver.azurefs
:members:
1 change: 0 additions & 1 deletion doc/ref/file_server/all/salt.fileserver.gitfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ salt.fileserver.gitfs
=====================

.. automodule:: salt.fileserver.gitfs
:members:
1 change: 0 additions & 1 deletion doc/ref/file_server/all/salt.fileserver.hgfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ salt.fileserver.hgfs
====================

.. automodule:: salt.fileserver.hgfs
:members:
1 change: 0 additions & 1 deletion doc/ref/file_server/all/salt.fileserver.minionfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ salt.fileserver.minionfs
========================

.. automodule:: salt.fileserver.minionfs
:members:
1 change: 0 additions & 1 deletion doc/ref/file_server/all/salt.fileserver.roots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ salt.fileserver.roots
=====================

.. automodule:: salt.fileserver.roots
:members:
1 change: 0 additions & 1 deletion doc/ref/file_server/all/salt.fileserver.s3fs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ salt.fileserver.s3fs
====================

.. automodule:: salt.fileserver.s3fs
:members:
1 change: 0 additions & 1 deletion doc/ref/file_server/all/salt.fileserver.svnfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ salt.fileserver.svnfs
=====================

.. automodule:: salt.fileserver.svnfs
:members:
4 changes: 2 additions & 2 deletions doc/ref/file_server/backends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
89 changes: 89 additions & 0 deletions doc/ref/file_server/environments.rst
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 6 additions & 1 deletion doc/topics/reactor/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +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
- 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.
Expand Down
6 changes: 6 additions & 0 deletions doc/topics/tutorials/states_pt4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=================

Expand Down
14 changes: 13 additions & 1 deletion salt/modules/aptpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1293,18 +1293,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
Expand Down
52 changes: 52 additions & 0 deletions salt/modules/cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
25 changes: 17 additions & 8 deletions salt/modules/dockerng.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,18 @@
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
---------
Expand Down Expand Up @@ -802,6 +803,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 '
Expand Down
12 changes: 11 additions & 1 deletion salt/modules/ebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
Loading