Skip to content

Commit

Permalink
Merge pull request #33866 from rallytime/merge-2016.3
Browse files Browse the repository at this point in the history
[2016.3] Merge forward from 2015.8 to 2016.3
  • Loading branch information
Nicole Thomas committed Jun 8, 2016
2 parents 669aa92 + 595d4f2 commit be20ce1
Show file tree
Hide file tree
Showing 22 changed files with 1,436 additions and 434 deletions.
92 changes: 1 addition & 91 deletions doc/topics/installation/debian.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Debian GNU/Linux / Raspbian
===========================

Debian GNU/Linux distribution and some devariatives such as Raspbian already
Debian GNU/Linux distribution and some derivatives such as Raspbian already
have included Salt packages to their repositories. However, current stable
release codenamed "Jessie" contains old outdated Salt release. It is
recommended to use SaltStack repository for Debian as described
Expand All @@ -23,96 +23,6 @@ Official SaltStack repository.

Instructions are at http://repo.saltstack.com/#debian.

Installation from the Community-Maintained Repository
=====================================================

The SaltStack community maintains a Debian repository at debian.saltstack.com.
Packages for Debian Old Stable, Stable, and Unstable (Wheezy, Jessie, and Sid)
for Salt 0.16 and later are published in this repository.

.. note::
Packages in this repository are community built, and it can
take a little while until the latest SaltStack release is available
in this repository.

Jessie (Stable)
---------------

For Jessie, the following line is needed in either
``/etc/apt/sources.list`` or a file in ``/etc/apt/sources.list.d``:

.. code-block:: bash
deb http://debian.saltstack.com/debian jessie-saltstack main
Wheezy (Old Stable)
-------------------

For Wheezy, the following line is needed in either
``/etc/apt/sources.list`` or a file in ``/etc/apt/sources.list.d``:

.. code-block:: bash
deb http://debian.saltstack.com/debian wheezy-saltstack main
Squeeze (Old Old Stable)
------------------------

For Squeeze, you will need to enable the Debian backports repository
as well as the debian.saltstack.com repository. To do so, add the
following to ``/etc/apt/sources.list`` or a file in
``/etc/apt/sources.list.d``:

.. code-block:: bash
deb http://debian.saltstack.com/debian squeeze-saltstack main
deb http://backports.debian.org/debian-backports squeeze-backports main
Stretch (Testing)
-----------------

For Stretch, the following line is needed in either
``/etc/apt/sources.list`` or a file in ``/etc/apt/sources.list.d``:

.. code-block:: bash
deb http://debian.saltstack.com/debian stretch-saltstack main
Sid (Unstable)
--------------

For Sid, the following line is needed in either
``/etc/apt/sources.list`` or a file in ``/etc/apt/sources.list.d``:

.. code-block:: bash
deb http://debian.saltstack.com/debian unstable main
Import the repository key
-------------------------

You will need to import the key used for signing.

.. code-block:: bash
wget -q -O- "http://debian.saltstack.com/debian-salt-team-joehealy.gpg.key" | apt-key add -
.. note::

You can optionally verify the key integrity with ``sha512sum`` using the
public key signature shown here. E.g:

.. code-block:: bash
echo "b702969447140d5553e31e9701be13ca11cc0a7ed5fe2b30acb8491567560ee62f834772b5095d735dfcecb2384a5c1a20045f52861c417f50b68dd5ff4660e6 debian-salt-team-joehealy.gpg.key" | sha512sum -c
Update the package database
---------------------------

.. code-block:: bash
apt-get update
.. _installation-debian-raspbian:

Installation from the Debian / Raspbian Official Repository
Expand Down
5 changes: 4 additions & 1 deletion salt/cli/salt.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ def _run_batch(self):
if not self.options.batch:
self.config['batch'] = '100%'

batch = salt.cli.batch.Batch(self.config, eauth=eauth, quiet=True)
try:
batch = salt.cli.batch.Batch(self.config, eauth=eauth, quiet=True)
except salt.exceptions.SaltClientError as exc:
sys.exit(2)

ret = {}

Expand Down
11 changes: 11 additions & 0 deletions salt/modules/groupadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,13 @@ def adduser(name, username, root=None):
if not then adds it.
'''
on_redhat_5 = __grains__.get('os_family') == 'RedHat' and __grains__.get('osmajorrelease') == '5'
on_suse_11 = __grains__.get('os_family') == 'Suse' and __grains__.get('osrelease_info')[0] == 11

if __grains__['kernel'] == 'Linux':
if on_redhat_5:
cmd = ('gpasswd', '-a', username, name)
elif on_suse_11:
cmd = ('usermod', '-A', name, username)
else:
cmd = ('gpasswd', '--add', username, name)
if root is not None:
Expand Down Expand Up @@ -198,13 +201,16 @@ def deluser(name, username, root=None):
then returns True.
'''
on_redhat_5 = __grains__.get('os_family') == 'RedHat' and __grains__.get('osmajorrelease') == '5'
on_suse_11 = __grains__.get('os_family') == 'Suse' and __grains__.get('osrelease_info')[0] == 11

grp_info = __salt__['group.info'](name)
try:
if username in grp_info['members']:
if __grains__['kernel'] == 'Linux':
if on_redhat_5:
cmd = ('gpasswd', '-d', username, name)
elif on_suse_11:
cmd = ('usermod', '-R', name, username)
else:
cmd = ('gpasswd', '--del', username, name)
if root is not None:
Expand Down Expand Up @@ -239,10 +245,15 @@ def members(name, members_list, root=None):
foo:x:1234:user1,user2,user3,...
'''
on_redhat_5 = __grains__.get('os_family') == 'RedHat' and __grains__.get('osmajorrelease') == '5'
on_suse_11 = __grains__.get('os_family') == 'Suse' and __grains__.get('osrelease_info')[0] == 11

if __grains__['kernel'] == 'Linux':
if on_redhat_5:
cmd = ('gpasswd', '-M', members_list, name)
elif on_suse_11:
for old_member in __salt__['group.info'](name).get('members'):
__salt__['cmd.run']('groupmod -R {0} {1}'.format(old_member, name), python_shell=False)
cmd = ('groupmod', '-A', members_list, name)
else:
cmd = ('gpasswd', '--members', members_list, name)
if root is not None:
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/locate.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def locate(pattern, database='', limit=0, **kwargs):
'wholename': 'w',
}
for option in kwargs:
if bool(kwargs[option]) is True:
if bool(kwargs[option]) is True and option in toggles:
options += toggles[option]
if options:
options = '-{0}'.format(options)
Expand Down
2 changes: 1 addition & 1 deletion salt/modules/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ def get_bufsize(iface):
.. code-block:: bash
salt '*' network.get_bufsize
salt '*' network.get_bufsize eth0
'''
if __grains__['kernel'] == 'Linux':
if os.path.exists('/sbin/ethtool'):
Expand Down
6 changes: 6 additions & 0 deletions salt/modules/timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,12 @@ def set_hwclock(clock):
elif clock == 'localtime':
__salt__['file.sed']('/etc/default/rcS', '^UTC=.*', 'UTC=no')
elif 'Gentoo' in __grains__['os_family']:
if clock not in ('UTC', 'localtime'):
raise SaltInvocationError(
'Only \'UTC\' and \'localtime\' are allowed'
)
if clock == 'localtime':
clock = 'local'
__salt__['file.sed'](
'/etc/conf.d/hwclock', '^clock=.*', 'clock="{0}"'.format(clock))

Expand Down
79 changes: 66 additions & 13 deletions salt/modules/win_servermanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ def list_available():
salt '*' win_servermanager.list_available
'''
cmd = 'Import-Module ServerManager; ' \
'Get-WindowsFeature -erroraction silentlycontinue ' \
'-warningaction silentlycontinue'
'Get-WindowsFeature ' \
'-ErrorAction SilentlyContinue ' \
'-WarningAction SilentlyContinue'
return __salt__['cmd.shell'](cmd, shell='powershell')


Expand All @@ -102,9 +103,10 @@ def list_installed():
salt '*' win_servermanager.list_installed
'''
cmd = 'Get-WindowsFeature -erroraction silentlycontinue ' \
'-warningaction silentlycontinue | ' \
'Select DisplayName,Name,Installed'
cmd = 'Get-WindowsFeature ' \
'-ErrorAction SilentlyContinue ' \
'-WarningAction SilentlyContinue ' \
'| Select DisplayName,Name,Installed'
features = _pshell_json(cmd)

ret = {}
Expand All @@ -115,7 +117,7 @@ def list_installed():
return ret


def install(feature, recurse=False):
def install(feature, recurse=False, source=None, restart=False, exclude=None):
'''
Install a feature
Expand All @@ -129,7 +131,21 @@ def install(feature, recurse=False):
:param str feature: The name of the feature to install
:param bool recurse: Install all sub-features
:param bool recurse: Install all sub-features. Default is False
:param str source: Path to the source files if missing from the target
system. None means that the system will use windows update services to
find the required files. Default is None
:param bool restart: Restarts the computer when installation is complete, if
required by the role/feature installed. Default is False
:param str exclude: The name of the feature to exclude when installing the
named feature.
..note:: As there is no exclude option for the ``Add-WindowsFeature``
command, the feature will be installed with other sub-features and
will then be removed.
:return: A dictionary containing the results of the install
:rtype: dict
Expand All @@ -140,16 +156,33 @@ def install(feature, recurse=False):
salt '*' win_servermanager.install Telnet-Client
salt '*' win_servermanager.install SNMP-Service True
salt '*' win_servermanager.install TFTP-Client source=d:\\side-by-side
'''
mgmt_tools = ''
if salt.utils.version_cmp(__grains__['osversion'], '6.2') >= 0:
mgmt_tools = '-IncludeManagementTools'

sub = ''
if recurse:
sub = '-IncludeAllSubFeature'

cmd = 'Add-WindowsFeature -Name {0} {1} ' \
rst = ''
if restart:
rst = '-Restart'

src = ''
if source is not None:
src = '-Source {0}'.format(source)

cmd = 'Add-WindowsFeature -Name {0} {1} {2} {3} {4} ' \
'-ErrorAction SilentlyContinue ' \
'-WarningAction SilentlyContinue'.format(_cmd_quote(feature), sub)
'-WarningAction SilentlyContinue'\
.format(_cmd_quote(feature), mgmt_tools, sub, src, rst)
out = _pshell_json(cmd)

if exclude is not None:
remove(exclude, restart=restart)

if out['FeatureResult']:
return {'ExitCode': out['ExitCode'],
'DisplayName': out['FeatureResult'][0]['DisplayName'],
Expand All @@ -162,8 +195,8 @@ def install(feature, recurse=False):
'Success': out['Success']}


def remove(feature):
'''
def remove(feature, remove_payload=False, restart=False):
r'''
Remove an installed feature
.. note::
Expand All @@ -175,6 +208,13 @@ def remove(feature):
:param str feature: The name of the feature to remove
:param bool remove_payload: True will cause the feature to be removed from
the side-by-side store (``%SystemDrive%:\Windows\WinSxS``). Default is
False
:param bool restart: Restarts the computer when uninstall is complete, if
required by the role/feature removed. Default is False
:return: A dictionary containing the results of the uninstall
:rtype: dict
Expand All @@ -184,9 +224,22 @@ def remove(feature):
salt -t 600 '*' win_servermanager.remove Telnet-Client
'''
cmd = 'Remove-WindowsFeature -Name {0} ' \
mgmt_tools = ''
if salt.utils.version_cmp(__grains__['osversion'], '6.2') >= 0:
mgmt_tools = '-IncludeManagementTools'

rmv = ''
if remove_payload:
rmv = '-Remove'

rst = ''
if restart:
rst = '-Restart'

cmd = 'Remove-WindowsFeature -Name {0} {1} {2} {3} ' \
'-ErrorAction SilentlyContinue ' \
'-WarningAction SilentlyContinue'.format(_cmd_quote(feature))
'-WarningAction SilentlyContinue'\
.format(_cmd_quote(feature), mgmt_tools, rmv, rst)
out = _pshell_json(cmd)

if out['FeatureResult']:
Expand Down
5 changes: 5 additions & 0 deletions salt/returners/local_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ def save_minions(jid, minions, syndic_id=None):
minions_path = os.path.join(jid_dir, MINIONS_P)

try:
if not os.path.exists(jid_dir):
try:
os.makedirs(jid_dir)
except OSError:
pass
serial.dump(minions, salt.utils.fopen(minions_path, 'w+b'))
except IOError as exc:
log.error(
Expand Down
Loading

0 comments on commit be20ce1

Please sign in to comment.