Skip to content

Commit

Permalink
Merge branch '2019.2' into merge-2019.2
Browse files Browse the repository at this point in the history
Conflicts:
  - doc/topics/index.rst
  - salt/grains/core.py
  - salt/minion.py
  - salt/version.py
  • Loading branch information
garethgreenaway committed Feb 23, 2019
2 parents 837097f + 1894082 commit 8d51bc9
Show file tree
Hide file tree
Showing 31 changed files with 803 additions and 100 deletions.
17 changes: 17 additions & 0 deletions doc/ref/configuration/minion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,23 @@ A value of 10 minutes is a reasonable default.
grains_refresh_every: 0
.. conf_minion:: metadata_server_grains

``metadata_server_grains``
--------------------------

.. versionadded:: 2017.7.0

Default: ``False``

Set this option to enable gathering of cloud metadata from
``http://169.254.169.254/latest`` for use in grains (see :py:mod:`here
<salt.grains.metadata>` for more information).

.. code-block:: yaml
metadata_server_grains: True
.. conf_minion:: fibre_channel_grains

``fibre_channel_grains``
Expand Down
2 changes: 1 addition & 1 deletion doc/topics/cloud/azure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ services. For more information on service certificates, see the following link:

* `Manage Certificates`__

.. __: https://msdn.microsoft.com/en-us/library/azure/gg981929.aspx
.. __: https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-certs-create

The following functions are available.

Expand Down
7 changes: 4 additions & 3 deletions doc/topics/community/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ A few examples of salt states from the community:
* https://github.com/bclermont/states
* https://github.com/pcrews/salt-data

Follow on ohloh
===============
Follow on Open Hub
==================

https://www.ohloh.net/p/salt
https://www.openhub.net/p/salt

Other community links
=====================
Expand All @@ -87,6 +87,7 @@ Other community links
- `Facebook <https://www.facebook.com/SaltStack>`_
- `Twitter <https://twitter.com/SaltStackInc>`_
- `Wikipedia page <http://en.wikipedia.org/wiki/Salt_(software)>`_
- `Stack Overflow <https://stackoverflow.com/questions/tagged/salt-stack>`_

Hack the Source
===============
Expand Down
14 changes: 14 additions & 0 deletions doc/topics/development/modules/developing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,17 @@ Defined in: State
__sdb__
-------
Defined in: SDB


Additional Globals
==================

Defined for: Runners, Execution Modules, Wheels

* ``__jid__``: The job ID
* ``__user__``: The user
* ``__tag__``: The jid tag
* ``__jid_event__``: A :py:class:`salt.utils.event.NamespacedEvent`.

:py:class:`NamespacedEvent <salt.utils.event.NamespacedEvent>` defines a single
method :py:meth:`fire_event <salt.utils.event.NamespacedEvent.fire_event>`, that takes data and tag. The :ref:`Runner docs <runners>` has examples.
2 changes: 1 addition & 1 deletion salt/client/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def low(self, fun, low, print_event=True, full_return=False):
print_func=print_func
)

# TODO: document these, and test that they exist
# TODO: test that they exist
# TODO: Other things to inject??
func_globals = {'__jid__': jid,
'__user__': data['user'],
Expand Down
20 changes: 10 additions & 10 deletions salt/grains/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import zlib
from errno import EACCES, EPERM
import datetime
import warnings

# pylint: disable=import-error
try:
Expand All @@ -41,16 +42,15 @@
'slamd64', 'ovs', 'system', 'mint', 'oracle', 'void')

# linux_distribution deprecated in py3.7
LINUX_DIST_AVAIL = True
if sys.version_info[:2] >= (3, 7):
USE_DISTRO_LINUX_DIST = True
try:
from distro import linux_distribution
except ImportError:
LINUX_DIST_AVAIL = False
else:
USE_DISTRO_LINUX_DIST = False
from platform import linux_distribution
try:
from platform import linux_distribution as _deprecated_linux_distribution

def linux_distribution(**kwargs):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
return _deprecated_linux_distribution(**kwargs)
except ImportError:
from distro import linux_distribution

# Import salt libs
import salt.exceptions
Expand Down
2 changes: 2 additions & 0 deletions salt/minion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2255,6 +2255,8 @@ def pillar_refresh(self, force_refresh=False, notify=False):
finally:
async_pillar.destroy()
self.module_refresh(force_refresh, notify)
self.matchers_refresh()
self.beacons_refresh()

def manage_schedule(self, tag, data):
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/cmdmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def _run(cmd,
'''
if 'pillar' in kwargs and not pillar_override:
pillar_override = kwargs['pillar']
if _is_valid_shell(shell) is False:
if output_loglevel != 'quiet' and _is_valid_shell(shell) is False:
log.warning(
'Attempt to run a shell command with what may be an invalid shell! '
'Check to ensure that the shell <%s> is valid for this user.',
Expand Down
61 changes: 55 additions & 6 deletions salt/modules/gem.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ def install(gems, # pylint: disable=C0103
Doesn't play nice with multiple gems at once
:param rdoc: boolean : False
Generate RDoc documentation for the gem(s).
For rubygems > 3 this is interpreted as the --no-document arg and the
ri option will then be ignored
:param ri: boolean : False
Generate RI documentation for the gem(s).
For rubygems > 3 this is interpreted as the --no-document arg and the
rdoc option will then be ignored
:param pre_releases: boolean : False
Include pre-releases in the available versions
:param proxy: string : None
Expand All @@ -119,12 +123,18 @@ def install(gems, # pylint: disable=C0103
options = []
if version:
options.extend(['--version', version])
if not rdoc:
options.append('--no-rdoc')
if not ri:
options.append('--no-ri')
if pre_releases:
options.append('--pre')
if _has_rubygems_3(ruby=ruby, runas=runas, gem_bin=gem_bin):
if not rdoc or not ri:
options.append('--no-document')
if pre_releases:
options.append('--prerelease')
else:
if not rdoc:
options.append('--no-rdoc')
if not ri:
options.append('--no-ri')
if pre_releases:
options.append('--pre')
if proxy:
options.extend(['-p', proxy])
if source:
Expand Down Expand Up @@ -224,6 +234,45 @@ def update_system(version='', ruby=None, runas=None, gem_bin=None):
runas=runas)


def version(ruby=None, runas=None, gem_bin=None):
'''
Print out the version of gem
:param gem_bin: string : None
Full path to ``gem`` binary to use.
:param ruby: string : None
If RVM or rbenv are installed, the ruby version and gemset to use.
Ignored if ``gem_bin`` is specified.
:param runas: string : None
The user to run gem as.
CLI Example:
.. code-block:: bash
salt '*' gem.version
'''
cmd = ['--version']
stdout = _gem(cmd,
ruby,
gem_bin=gem_bin,
runas=runas)
ret = {}
for line in salt.utils.itertools.split(stdout, '\n'):
match = re.match(r'[.0-9]+', line)
if match:
ret = line
break
return ret


def _has_rubygems_3(ruby=None, runas=None, gem_bin=None):
match = re.match(r'^3\..*', version(ruby=ruby, runas=runas, gem_bin=gem_bin))
if match:
return True
return False


def list_(prefix='', ruby=None, runas=None, gem_bin=None):
'''
List locally installed gems.
Expand Down
7 changes: 3 additions & 4 deletions salt/modules/pillar.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# Import third party libs
import copy
import os
import copy
import logging
from salt.ext import six

Expand Down Expand Up @@ -157,7 +156,7 @@ def get(key,
'skipped.', default, ret, type(ret).__name__
)
elif isinstance(default, list):
ret = salt.utils.data.traverse_dict_and_list(
ret = salt.utils.data.traverse_dict_and_list( # pylint: disable=redefined-variable-type
pillar_dict,
key,
[],
Expand Down Expand Up @@ -345,7 +344,7 @@ def ls(*args):
salt '*' pillar.ls
'''

return list(items(*args).keys())
return list(items(*args))


def item(*args, **kwargs):
Expand Down Expand Up @@ -544,7 +543,7 @@ def keys(key, delimiter=DEFAULT_TARGET_DELIM):
if not isinstance(ret, dict):
raise ValueError("Pillar value in key {0} is not a dict".format(key))

return ret.keys()
return list(ret)


def file_exists(path, saltenv=None):
Expand Down
18 changes: 13 additions & 5 deletions salt/modules/solarisips.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import salt.utils.functools
import salt.utils.path
import salt.utils.pkg
from salt.ext.six import string_types
from salt.exceptions import CommandExecutionError
from salt.ext import six
from salt.ext.six.moves import zip # pylint: disable=redefined-builtin
Expand Down Expand Up @@ -527,12 +528,16 @@ def install(name=None, refresh=False, pkgs=None, version=None, test=False, **kwa

pkg2inst = ''
if pkgs: # multiple packages specified
pkg2inst = []
for pkg in pkgs:
if list(pkg.items())[0][1]: # version specified
pkg2inst += '{0}@{1} '.format(list(pkg.items())[0][0],
list(pkg.items())[0][1])
if getattr(pkg, 'items', False):
if list(pkg.items())[0][1]: # version specified
pkg2inst.append('{0}@{1}'.format(list(pkg.items())[0][0],
list(pkg.items())[0][1]))
else:
pkg2inst.append(list(pkg.items())[0][0])
else:
pkg2inst += '{0} '.format(list(pkg.items())[0][0])
pkg2inst.append("{0}".format(pkg))
log.debug('Installing these packages instead of %s: %s',
name, pkg2inst)

Expand All @@ -552,7 +557,10 @@ def install(name=None, refresh=False, pkgs=None, version=None, test=False, **kwa

# Install or upgrade the package
# If package is already installed
cmd.append(pkg2inst)
if isinstance(pkg2inst, string_types):
cmd.append(pkg2inst)
elif isinstance(pkg2inst, list):
cmd = cmd + pkg2inst

out = __salt__['cmd.run_all'](cmd, output_loglevel='trace')

Expand Down
20 changes: 10 additions & 10 deletions salt/modules/win_lgpo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5083,7 +5083,7 @@ def _findOptionValueAdvAudit(option):
field_names = _get_audit_defaults('fieldnames')
# If the file doesn't exist anywhere, create it with default
# fieldnames
__salt__['file.mkdir'](os.path.dirname(f_audit))
__salt__['file.makedirs'](f_audit)
__salt__['file.write'](f_audit, ','.join(field_names))

audit_settings = {}
Expand Down Expand Up @@ -5187,7 +5187,7 @@ def _set_audit_file_data(option, value):
# Copy the temporary csv file over the existing audit.csv in both
# locations if a value was written
__salt__['file.copy'](f_temp.name, f_audit, remove_existing=True)
__salt__['file.mkdir'](os.path.dirname(f_audit_gpo))
__salt__['file.makedirs'](f_audit_gpo)
__salt__['file.copy'](f_temp.name, f_audit_gpo, remove_existing=True)
finally:
f_temp.close()
Expand Down Expand Up @@ -5605,7 +5605,7 @@ def _getDataFromRegPolData(search_string, policy_data, return_value_name=False):
)
].split(encoded_semicolon)
if len(pol_entry) >= 2:
valueName = pol_entry[1]
valueName = pol_entry[1].decode('utf-16-le').rstrip(chr(0))
if len(pol_entry) >= 5:
value = pol_entry[4]
if vtype == 'REG_DWORD' or vtype == 'REG_QWORD':
Expand Down Expand Up @@ -5857,7 +5857,7 @@ def _processValueItem(element, reg_key, reg_valuename, policy, parent_element,
check_deleted = True
if not check_deleted:
this_vtype = 'REG_DWORD'
this_element_value = chr(1).encode('utf-16-le')
this_element_value = struct.pack('I', 1)
standard_element_expected_string = False
elif etree.QName(element).localname == 'decimal':
# https://msdn.microsoft.com/en-us/library/dn605987(v=vs.85).aspx
Expand Down Expand Up @@ -5923,18 +5923,18 @@ def _processValueItem(element, reg_key, reg_valuename, policy, parent_element,
']'.encode('utf-16-le')])
if 'expandable' in element.attrib:
this_vtype = 'REG_EXPAND_SZ'
if 'explicitValue' in element.attrib and element.attrib['explicitValue'].lower() == 'true':
if element.attrib.get('explicitValue', 'false').lower() == 'true':
if this_element_value is not None:
element_valuenames = this_element_value.keys()
element_values = this_element_value.values()
if 'valuePrefix' in element.attrib:
element_valuenames = [str(k) for k in this_element_value.keys()]
element_values = [str(v) for v in this_element_value.values()]
elif 'valuePrefix' in element.attrib:
# if the valuePrefix attribute exists, the valuenames are <prefix><number>
# most prefixes attributes are empty in the admx files, so the valuenames
# end up being just numbers
if element.attrib['valuePrefix'] != '':
if this_element_value is not None:
element_valuenames = ['{0}{1}'.format(element.attrib['valuePrefix'],
k) for k in element_valuenames]
element_valuenames = ['{0}{1}'.format(
element.attrib['valuePrefix'], k) for k in element_valuenames]
else:
# if there is no valuePrefix attribute, the valuename is the value
if element_values is not None:
Expand Down
Loading

0 comments on commit 8d51bc9

Please sign in to comment.