Skip to content

Commit

Permalink
Merge pull request #25564 from basepi/merge-forward-2015.8
Browse files Browse the repository at this point in the history
[2015.8] Merge forward from 2015.5 to 2015.8
  • Loading branch information
basepi committed Jul 21, 2015
2 parents 4696626 + 0592c4a commit cf317b4
Show file tree
Hide file tree
Showing 31 changed files with 438 additions and 197 deletions.
2 changes: 1 addition & 1 deletion doc/ref/configuration/minion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ to enable set grains_cache to ``True``.

.. code-block:: yaml
cache_jobs: False
grains_cache: False
.. conf_minion:: sock_dir
Expand Down
5 changes: 2 additions & 3 deletions doc/ref/states/highstate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ Extend declaration
------------------

Extends a :ref:`name-declaration` from an included ``SLS module``. The
keys of the extend declaration always define existing :ref`ID declaration`
which have been defined in included
``SLS modules``.
keys of the extend declaration always refer to an existing
:ref:`id-declaration` which have been defined in included ``SLS modules``.

Occurs only in the top level and defines a dictionary.

Expand Down
2 changes: 1 addition & 1 deletion doc/topics/best_practices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ accessible by the appropriate hosts:
.. code-block:: yaml
testdb:
mysql_database.present::
mysql_database.present:
- name: testerdb
``/srv/salt/mysql/user.sls``:
Expand Down
2 changes: 1 addition & 1 deletion doc/topics/cloud/vmware.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Getting Started With VMware
===========================

.. versionadded:: 2015.8.0
.. versionadded:: 2015.5.4

**Author**: Nitin Madhok <nmadhok@clemson.edu>

Expand Down
17 changes: 17 additions & 0 deletions doc/topics/releases/2015.5.4.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
===========================
Salt 2015.5.4 Release Notes
===========================

:release: TBA

Version 2015.5.4 is a bugfix release for :doc:`2015.5.0
</topics/releases/2015.5.0>`.

Changes:

- When querying for VMs in ``ditigal_ocean_v2.py``, the number of VMs to include in a page was changed from 20
(default) to 200 to reduce the number of API calls to Digital Ocean.

- The ``vmware`` Salt-Cloud driver was back-ported from the develop branch in order for installations of Salt
that are older than 2015.8.0 to be able to use the ``vmware`` driver without stack-tracing on various
deprecation paths that were implemented in the 2015.8.0 release.
2 changes: 2 additions & 0 deletions salt/cloud/clouds/opennebula.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
The OpenNebula cloud module is used to control access to an OpenNebula
cloud.
:depends: lxml
Use of this module requires the ``xml_rpc``, ``user`` and
``password`` parameter to be set. Set up the cloud configuration
at ``/etc/salt/cloud.providers`` or
Expand Down
2 changes: 1 addition & 1 deletion salt/cloud/clouds/vmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
VMware Cloud Module
===================
.. versionadded:: 2015.8.0
.. versionadded:: 2015.5.4
The VMware cloud module allows you to manage VMware ESX, ESXi, and vCenter.
Expand Down
10 changes: 5 additions & 5 deletions salt/fileclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,6 @@ def get_url(self, url, dest, makedirs=False, saltenv='base', env=None, no_cache=
else:
return ''
elif not no_cache:
if salt.utils.is_windows():
netloc = salt.utils.sanitize_win_path_string(url_data.netloc)
else:
netloc = url_data.netloc
dest = self._extrn_path(url, saltenv)
destdir = os.path.dirname(dest)
if not os.path.isdir(destdir):
Expand Down Expand Up @@ -697,12 +693,16 @@ def _extrn_path(self, url, saltenv):
Return the extn_filepath for a given url
'''
url_data = urlparse(url)
if salt.utils.is_windows():
netloc = salt.utils.sanitize_win_path_string(url_data.netloc)
else:
netloc = url_data.netloc

return salt.utils.path_join(
self.opts['cachedir'],
'extrn_files',
saltenv,
url_data.netloc,
netloc,
url_data.path
)

Expand Down
51 changes: 26 additions & 25 deletions salt/grains/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,32 +1065,33 @@ def os_data():
os.stat('/run/systemd/system')
grains['init'] = 'systemd'
except OSError:
with salt.utils.fopen('/proc/1/cmdline') as fhr:
init_cmdline = fhr.read().replace('\x00', ' ').split()
init_bin = salt.utils.which(init_cmdline[0])
if init_bin:
supported_inits = ('upstart', 'sysvinit', 'systemd')
edge_len = max(len(x) for x in supported_inits) - 1
buf_size = __opts__['file_buffer_size']
try:
with open(init_bin, 'rb') as fp_:
buf = True
edge = ''
buf = fp_.read(buf_size).lower()
while buf:
buf = edge + buf
for item in supported_inits:
if item in buf:
grains['init'] = item
buf = ''
break
edge = buf[-edge_len:]
if os.path.exists('/proc/1/cmdline'):
with salt.utils.fopen('/proc/1/cmdline') as fhr:
init_cmdline = fhr.read().replace('\x00', ' ').split()
init_bin = salt.utils.which(init_cmdline[0])
if init_bin:
supported_inits = ('upstart', 'sysvinit', 'systemd')
edge_len = max(len(x) for x in supported_inits) - 1
buf_size = __opts__['file_buffer_size']
try:
with open(init_bin, 'rb') as fp_:
buf = True
edge = ''
buf = fp_.read(buf_size).lower()
except (IOError, OSError) as exc:
log.error(
'Unable to read from init_bin ({0}): {1}'
.format(init_bin, exc)
)
while buf:
buf = edge + buf
for item in supported_inits:
if item in buf:
grains['init'] = item
buf = ''
break
edge = buf[-edge_len:]
buf = fp_.read(buf_size).lower()
except (IOError, OSError) as exc:
log.error(
'Unable to read from init_bin ({0}): {1}'
.format(init_bin, exc)
)

# Add lsb grains on any distro with lsb-release
try:
Expand Down
3 changes: 2 additions & 1 deletion salt/modules/dig.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
Compendium of generic DNS utilities.
The 'dig' command line tool must be installed in order to use this module.
'''
from __future__ import absolute_import

Expand Down
2 changes: 1 addition & 1 deletion salt/modules/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3593,7 +3593,7 @@ def check_file_meta(
if contents is not None:
# Write a tempfile with the static contents
tmp = salt.utils.mkstemp(text=True)
with salt.utils.fopen(tmp, 'w') as tmp_:
with salt.utils.fopen(tmp, 'wb') as tmp_:
tmp_.write(str(contents))
# Compare the static contents with the named file
with contextlib.nested(
Expand Down
3 changes: 3 additions & 0 deletions salt/modules/hipchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ def _query(function,
headers['Authorization'] = 'Bearer {0}'.format(api_key)
if data:
data = json.dumps(data)

if method == 'POST':
headers['Content-Type'] = 'application/json'
else:
log.error('Unsupported HipChat API version')
return False
Expand Down
45 changes: 23 additions & 22 deletions salt/modules/lxc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3146,7 +3146,7 @@ def set_dns(name, dnsservers=None, searchdomains=None, path=None):
path=path, python_shell=True)
# blindly delete the setter file
run_all(name,
'if [ -f "{0}" ];then rm -f "{0}";fi'.format(script),
'sh -c \'if [ -f "{0}" ];then rm -f "{0}";fi\''.format(script),
path=path, python_shell=True)
if result['retcode'] != 0:
error = ('Unable to write to /etc/resolv.conf in container \'{0}\''
Expand Down Expand Up @@ -3187,7 +3187,7 @@ def running_systemd(name, cache=True, path=None):
'''\
#!/usr/bin/env bash
set -x
if ! which systemctl 1>/dev/nulll 2>/dev/null;then exit 2;fi
if ! which systemctl 1>/dev/null 2>/dev/null;then exit 2;fi
for i in \\
/run/systemd/journal/dev-log\\
/run/systemd/journal/flushed\\
Expand Down Expand Up @@ -3513,26 +3513,21 @@ def bootstrap(name,
if install:
rstr = __salt__['test.rand_str']()
configdir = '/tmp/.c_{0}'.format(rstr)
run(name,
'install -m 0700 -d {0}'.format(configdir),
path=path,
python_shell=False)

cmd = 'install -m 0700 -d {0}'.format(configdir)
if run(name, cmd, python_shell=False):
log.error('tmpdir {0} creation failed ({1}'
.format(configdir, cmd))
return False

bs_ = __salt__['config.gather_bootstrap_script'](
bootstrap=bootstrap_url)
dest_dir = os.path.join('/tmp', rstr)
for cmd in [
'mkdir -p {0}'.format(dest_dir),
'chmod 700 {0}'.format(dest_dir),
]:
if run_stdout(name, cmd, path=path):
log.error(
('tmpdir {0} creation'
' failed ({1}').format(dest_dir, cmd))
return False
copy_to(name,
bs_,
'{0}/bootstrap.sh'.format(dest_dir),
path=path)
script = '/sbin/{0}_bootstrap.sh'.format(rstr)
copy_to(name, bs_, script, path=path)
result = run_all(name,
'sh -c "chmod +x {0};{0}"'''.format(script),
python_shell=True)

copy_to(name, cfg_files['config'],
os.path.join(configdir, 'minion'),
path=path)
Expand All @@ -3543,16 +3538,22 @@ def bootstrap(name,
os.path.join(configdir, 'minion.pub'),
path=path)
bootstrap_args = bootstrap_args.format(configdir)
cmd = ('{0} {2}/bootstrap.sh {1}'
cmd = ('{0} {2} {1}'
.format(bootstrap_shell,
bootstrap_args.replace("'", "''"),
dest_dir))
script))
# log ASAP the forged bootstrap command which can be wrapped
# out of the output in case of unexpected problem
log.info('Running {0} in LXC container \'{1}\''
.format(cmd, name))
ret = retcode(name, cmd, output_loglevel='info',
path=path, use_vt=True) == 0

run_all(name,
'sh -c \'if [ -f "{0}" ];then rm -f "{0}";fi\''
''.format(script),
ignore_retcode=True,
python_shell=True)
else:
ret = False
else:
Expand Down
1 change: 1 addition & 0 deletions salt/modules/mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ def set_fstab(
# Try to guess right criteria for auto....
# NOTE: missing some special fstypes here
specialFSes = frozenset([
'none',
'tmpfs',
'sysfs',
'proc',
Expand Down
16 changes: 15 additions & 1 deletion salt/modules/rbenv.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# -*- coding: utf-8 -*-
'''
Manage ruby installations with rbenv.
Manage ruby installations with rbenv. Rbenv is supported on Linux and Mac OS X.
Rbenv doesn't work on Windows (and isn't really necessary on Windows as there is
no system Ruby on Windows). On Windows, the RubyInstaller and/or Pik are both
good alternatives to work with multiple versions of Ruby on the same box.
http://misheska.com/blog/2013/06/15/using-rbenv-to-manage-multiple-versions-of-ruby/
.. versionadded:: 0.16.0
'''
Expand Down Expand Up @@ -32,6 +37,15 @@
}


def __virtual__():
"""
Only work on POSIX-like systems
"""
if salt.utils.is_windows():
return False
return True


def _shlex_split(s):
# from python:shlex.split: passing None for s will read
# the string to split from standard input.
Expand Down
12 changes: 6 additions & 6 deletions salt/modules/sysrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ def get(**kwargs):

cmd = 'sysrc -v'

if 'file' in kwargs:
cmd += ' -f '+kwargs['file']

if 'jail' in kwargs:
cmd += ' -j '+kwargs['jail']

if 'name' in kwargs:
cmd += ' '+kwargs['name']
elif kwargs.get('includeDefaults', False):
cmd += ' -A'
else:
cmd += ' -a'

if 'file' in kwargs:
cmd += ' -f '+kwargs['file']

if 'jail' in kwargs:
cmd += ' -j '+kwargs['jail']

sysrcs = __salt__['cmd.run'](cmd)
if "sysrc: unknown variable" in sysrcs:
# raise CommandExecutionError(sysrcs)
Expand Down

0 comments on commit cf317b4

Please sign in to comment.