mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #45019 from rallytime/merge-oxygen
[oxygen] Merge forward from 2017.7 to oxygen
This commit is contained in:
commit
04a2ea8cd1
10 changed files with 51 additions and 35 deletions
|
@ -1646,13 +1646,13 @@ Example:
|
|||
|
||||
.. code-block:: jinja
|
||||
|
||||
regex_escape = {{ 'https://example.com?foo=bar%20baz' | regex_escape }}
|
||||
regex_escape = {{ 'https://example.com?foo=bar%20baz' | regex_escape }}
|
||||
|
||||
will be rendered as:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
regex_escape = https\:\/\/example\.com\?foo\=bar\%20baz
|
||||
regex_escape = https\:\/\/example\.com\?foo\=bar\%20baz
|
||||
|
||||
Set Theory Filters
|
||||
------------------
|
||||
|
@ -1670,13 +1670,13 @@ Example:
|
|||
|
||||
.. code-block:: jinja
|
||||
|
||||
unique = {{ ['foo', 'foo', 'bar'] | unique }}
|
||||
unique = {{ ['foo', 'foo', 'bar'] | unique }}
|
||||
|
||||
will be rendered as:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
unique = ['foo', 'bar']
|
||||
unique = ['foo', 'bar']
|
||||
|
||||
Jinja in Files
|
||||
==============
|
||||
|
|
|
@ -10,6 +10,7 @@ import socket
|
|||
import ctypes
|
||||
import os
|
||||
import ipaddress
|
||||
import salt.ext.six as six
|
||||
|
||||
|
||||
class sockaddr(ctypes.Structure):
|
||||
|
@ -36,7 +37,7 @@ def inet_pton(address_family, ip_string):
|
|||
# This will catch IP Addresses such as 10.1.2
|
||||
if address_family == socket.AF_INET:
|
||||
try:
|
||||
ipaddress.ip_address(ip_string.decode())
|
||||
ipaddress.ip_address(six.u(ip_string))
|
||||
except ValueError:
|
||||
raise socket.error('illegal IP address string passed to inet_pton')
|
||||
return socket.inet_aton(ip_string)
|
||||
|
|
|
@ -144,17 +144,17 @@ def _parse_acl(acl, user, group):
|
|||
# Set the permissions fields
|
||||
octal = 0
|
||||
vals['permissions'] = {}
|
||||
if 'r' in comps[2]:
|
||||
if 'r' in comps[-1]:
|
||||
octal += 4
|
||||
vals['permissions']['read'] = True
|
||||
else:
|
||||
vals['permissions']['read'] = False
|
||||
if 'w' in comps[2]:
|
||||
if 'w' in comps[-1]:
|
||||
octal += 2
|
||||
vals['permissions']['write'] = True
|
||||
else:
|
||||
vals['permissions']['write'] = False
|
||||
if 'x' in comps[2]:
|
||||
if 'x' in comps[-1]:
|
||||
octal += 1
|
||||
vals['permissions']['execute'] = True
|
||||
else:
|
||||
|
|
|
@ -247,7 +247,7 @@ def install_ruby(ruby, runas=None):
|
|||
|
||||
ret = {}
|
||||
ret = _rbenv_exec(['install', ruby], env=env, runas=runas, ret=ret)
|
||||
if ret['retcode'] == 0:
|
||||
if ret is not False and ret['retcode'] == 0:
|
||||
rehash(runas=runas)
|
||||
return ret['stderr']
|
||||
else:
|
||||
|
|
|
@ -317,7 +317,7 @@ def get_site_packages(venv):
|
|||
ret = __salt__['cmd.exec_code_all'](
|
||||
bin_path,
|
||||
'from distutils import sysconfig; '
|
||||
'print sysconfig.get_python_lib()'
|
||||
'print(sysconfig.get_python_lib())'
|
||||
)
|
||||
|
||||
if ret['retcode'] != 0:
|
||||
|
|
|
@ -278,10 +278,9 @@ def list_available(*names, **kwargs):
|
|||
|
||||
saltenv = kwargs.get('saltenv', 'base')
|
||||
refresh = salt.utils.data.is_true(kwargs.get('refresh', False))
|
||||
return_dict_always = \
|
||||
salt.utils.data.is_true(kwargs.get('return_dict_always', False))
|
||||
|
||||
_refresh_db_conditional(saltenv, force=refresh)
|
||||
return_dict_always = \
|
||||
salt.utils.is_true(kwargs.get('return_dict_always', False))
|
||||
if len(names) == 1 and not return_dict_always:
|
||||
pkginfo = _get_package_info(names[0], saltenv=saltenv)
|
||||
if not pkginfo:
|
||||
|
@ -358,6 +357,7 @@ def list_pkgs(versions_as_list=False, **kwargs):
|
|||
List the packages currently installed
|
||||
|
||||
Args:
|
||||
version_as_list (bool): Returns the versions as a list
|
||||
|
||||
Kwargs:
|
||||
saltenv (str): The salt environment to use. Default ``base``.
|
||||
|
@ -1255,6 +1255,7 @@ def install(name=None, refresh=False, pkgs=None, **kwargs):
|
|||
log.debug('Source hash matches package hash.')
|
||||
|
||||
# Get install flags
|
||||
|
||||
install_flags = pkginfo[version_num].get('install_flags', '')
|
||||
if options and options.get('extra_install_flags'):
|
||||
install_flags = '{0} {1}'.format(
|
||||
|
@ -1329,14 +1330,12 @@ def install(name=None, refresh=False, pkgs=None, **kwargs):
|
|||
log.error('Scheduled Task failed to run')
|
||||
ret[pkg_name] = {'install status': 'failed'}
|
||||
else:
|
||||
|
||||
# Launch the command
|
||||
result = __salt__['cmd.run_all'](
|
||||
'"{0}" /s /c "{1}"'.format(cmd_shell, arguments),
|
||||
cache_path,
|
||||
output_loglevel='trace',
|
||||
python_shell=False,
|
||||
redirect_stderr=True)
|
||||
result = __salt__['cmd.run_all']('"{0}" /s /c "{1}"'.format(cmd_shell, arguments),
|
||||
cache_path,
|
||||
output_loglevel='trace',
|
||||
python_shell=False,
|
||||
redirect_stderr=True)
|
||||
if not result['retcode']:
|
||||
ret[pkg_name] = {'install status': 'success'}
|
||||
changed.append(pkg_name)
|
||||
|
@ -1513,7 +1512,6 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
|
|||
removal_targets.append(version_num)
|
||||
|
||||
for target in removal_targets:
|
||||
|
||||
# Get the uninstaller
|
||||
uninstaller = pkginfo[target].get('uninstaller', '')
|
||||
cache_dir = pkginfo[target].get('cache_dir', False)
|
||||
|
@ -1538,6 +1536,7 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
|
|||
# If true, the entire directory will be cached instead of the
|
||||
# individual file. This is useful for installations that are not
|
||||
# single files
|
||||
|
||||
if cache_dir and uninstaller.startswith('salt:'):
|
||||
path, _ = os.path.split(uninstaller)
|
||||
__salt__['cp.cache_dir'](path,
|
||||
|
@ -1578,15 +1577,13 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
|
|||
else:
|
||||
# Run the uninstaller directly
|
||||
# (not hosted on salt:, https:, etc.)
|
||||
cached_pkg = uninstaller
|
||||
cached_pkg = os.path.expandvars(uninstaller)
|
||||
|
||||
# Fix non-windows slashes
|
||||
cached_pkg = cached_pkg.replace('/', '\\')
|
||||
cache_path, _ = os.path.split(cached_pkg)
|
||||
|
||||
# Get parameters for cmd
|
||||
expanded_cached_pkg = str(os.path.expandvars(cached_pkg))
|
||||
expanded_cache_path = str(os.path.expandvars(cache_path))
|
||||
# os.path.expandvars is not required as we run everything through cmd.exe /s /c
|
||||
|
||||
# Get uninstall flags
|
||||
uninstall_flags = pkginfo[target].get('uninstall_flags', '')
|
||||
|
@ -1602,9 +1599,11 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
|
|||
# Build cmd and arguments
|
||||
# cmd and arguments must be separated for use with the task scheduler
|
||||
if use_msiexec:
|
||||
arguments = '"{0}" /X "{1}"'.format(msiexec, uninstaller if uninstaller else expanded_cached_pkg)
|
||||
# Check if uninstaller is set to {guid}, if not we assume its a remote msi file.
|
||||
# which has already been downloaded.
|
||||
arguments = '"{0}" /X "{1}"'.format(msiexec, cached_pkg)
|
||||
else:
|
||||
arguments = '"{0}"'.format(expanded_cached_pkg)
|
||||
arguments = '"{0}"'.format(cached_pkg)
|
||||
|
||||
if uninstall_flags:
|
||||
arguments = '{0} {1}'.format(arguments, uninstall_flags)
|
||||
|
@ -1619,7 +1618,7 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
|
|||
action_type='Execute',
|
||||
cmd=cmd_shell,
|
||||
arguments='/s /c "{0}"'.format(arguments),
|
||||
start_in=expanded_cache_path,
|
||||
start_in=cache_path,
|
||||
trigger_type='Once',
|
||||
start_date='1975-01-01',
|
||||
start_time='01:00',
|
||||
|
@ -1634,7 +1633,6 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
|
|||
# Launch the command
|
||||
result = __salt__['cmd.run_all'](
|
||||
'"{0}" /s /c "{1}"'.format(cmd_shell, arguments),
|
||||
expanded_cache_path,
|
||||
output_loglevel='trace',
|
||||
python_shell=False,
|
||||
redirect_stderr=True)
|
||||
|
|
|
@ -40,7 +40,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
def _ping(tgt, tgt_type, timeout, gather_job_timeout):
|
||||
client = salt.client.get_local_client(__opts__['conf_file'])
|
||||
pub_data = client.run_job(tgt, 'test.ping', (), tgt_type, '', timeout, '')
|
||||
pub_data = client.run_job(tgt, 'test.ping', (), tgt_type, '', timeout, '', listen=True)
|
||||
|
||||
if not pub_data:
|
||||
return pub_data
|
||||
|
|
|
@ -232,12 +232,12 @@ def get_pidfile(pidfile):
|
|||
'''
|
||||
Return the pid from a pidfile as an integer
|
||||
'''
|
||||
with salt.utils.files.fopen(pidfile) as pdf:
|
||||
pid = pdf.read()
|
||||
if pid:
|
||||
try:
|
||||
with salt.utils.files.fopen(pidfile) as pdf:
|
||||
pid = pdf.read().strip()
|
||||
return int(pid)
|
||||
else:
|
||||
return
|
||||
except (OSError, IOError, TypeError, ValueError):
|
||||
return None
|
||||
|
||||
|
||||
def clean_proc(proc, wait_for_kill=10):
|
||||
|
|
|
@ -63,6 +63,22 @@ class LinuxAclTestCase(TestCase, LoaderModuleMockMixin):
|
|||
linux_acl.getfacl(*self.files, recursive=True)
|
||||
self.cmdrun.assert_called_once_with('getfacl --absolute-names -R ' + ' '.join(self.quoted_files), python_shell=False)
|
||||
|
||||
def test_getfacl__effective_acls(self):
|
||||
line = 'group:webmaster:r-x #effective:---'
|
||||
user = 'root'
|
||||
group = 'root'
|
||||
expected = {
|
||||
'type': 'acl',
|
||||
'group': 'webmaster',
|
||||
'permissions': {
|
||||
'read': False,
|
||||
'write': False,
|
||||
'execute': False
|
||||
},
|
||||
'octal': 0,
|
||||
}
|
||||
self.assertEqual(linux_acl._parse_acl(line, user, group), expected)
|
||||
|
||||
def test_wipefacls_wo_args(self):
|
||||
self.assertRaises(CommandExecutionError, linux_acl.wipefacls)
|
||||
|
||||
|
|
|
@ -489,6 +489,7 @@ class LogSettingsParserTests(TestCase):
|
|||
# Check log file logger
|
||||
self.assertEqual(self.log_setup.log_level_logfile, log_level_logfile)
|
||||
|
||||
@skipIf(salt.utils.is_windows(), 'Windows uses a logging listener')
|
||||
def test_log_created(self):
|
||||
'''
|
||||
Tests that log file is created
|
||||
|
|
Loading…
Add table
Reference in a new issue