mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #36004 from rallytime/merge-2016.3
[2016.3] Merge forward from 2015.8 to 2016.3
This commit is contained in:
commit
d248ab0120
22
COPYING
22
COPYING
@ -134,3 +134,25 @@ License: Apache-2.0
|
||||
`/usr/share/common-licenses/Apache-2.0'.
|
||||
.
|
||||
Files in this directory were created in-house.
|
||||
|
||||
Files: tests/utils/cptestcase.py
|
||||
Copyright: (c) 2014 Adam Hajari
|
||||
The MIT License (MIT)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
@ -261,7 +261,7 @@ def chshell(name, shell):
|
||||
return info(name).get('shell') == shell
|
||||
|
||||
|
||||
def chhome(name, home):
|
||||
def chhome(name, home, **kwargs):
|
||||
'''
|
||||
Change the home directory of the user
|
||||
|
||||
@ -271,6 +271,13 @@ def chhome(name, home):
|
||||
|
||||
salt '*' user.chhome foo /Users/foo
|
||||
'''
|
||||
kwargs = salt.utils.clean_kwargs(**kwargs)
|
||||
persist = kwargs.pop('persist', False)
|
||||
if kwargs:
|
||||
salt.utils.invalid_kwargs(kwargs)
|
||||
if persist:
|
||||
log.info('Ignoring unsupported \'persist\' argument to user.chhome')
|
||||
|
||||
pre_info = info(name)
|
||||
if not pre_info:
|
||||
raise CommandExecutionError('User \'{0}\' does not exist'.format(name))
|
||||
|
@ -131,30 +131,35 @@ def update_git_repos(clean=False):
|
||||
|
||||
|
||||
def show_sls(name, saltenv='base'):
|
||||
'''
|
||||
r'''
|
||||
.. versionadded:: 2015.8.0
|
||||
|
||||
Display the rendered software definition from a specific sls file in the
|
||||
local winrepo cache. This will parse all Jinja. Run pkg.refresh_db to pull
|
||||
the latest software definitions from the master.
|
||||
|
||||
.. note::
|
||||
This function does not ask a master for an sls file to render. Instead
|
||||
it directly processes the file specified in `name`
|
||||
|
||||
:param str name:
|
||||
The name of the package you want to view. Start from the local winrepo
|
||||
root. If you have ``.sls`` files organized in subdirectories you'll have
|
||||
to denote them with ``.``. For example, if I have a ``test`` directory
|
||||
in the winrepo root with a ``gvim.sls`` file inside, I would target that
|
||||
file like so: ``test.gvim``. Directories can be targeted as well as long
|
||||
as they contain an ``init.sls`` inside. For example, if I have a ``node``
|
||||
directory with an ``init.sls`` inside, I would target that like so:
|
||||
``node``.
|
||||
Args:
|
||||
name str: The name/path of the package you want to view. This can be the
|
||||
full path to a file on the minion file system or a file on the local
|
||||
minion cache.
|
||||
|
||||
:param str saltenv:
|
||||
The default environment is ``base``
|
||||
saltenv str: The default environment is ``base``
|
||||
|
||||
:return:
|
||||
Returns a dictionary containing the rendered data structure
|
||||
:rtype: dict
|
||||
Returns:
|
||||
dict: Returns a dictionary containing the rendered data structure
|
||||
|
||||
.. note::
|
||||
To use a file from the minion cache start from the local winrepo root
|
||||
(``C:\salt\var\cache\salt\minion\files\base\win\repo-ng``). If you have
|
||||
``.sls`` files organized in subdirectories you'll have to denote them
|
||||
with ``.``. For example, if you have a ``test`` directory in the winrepo
|
||||
root with a ``gvim.sls`` file inside, would target that file like so:
|
||||
``test.gvim``. Directories can be targeted as well as long as they
|
||||
contain an ``init.sls`` inside. For example, if you have a ``node``
|
||||
directory with an ``init.sls`` inside, target that like so: ``node``.
|
||||
|
||||
CLI Example:
|
||||
|
||||
@ -162,25 +167,32 @@ def show_sls(name, saltenv='base'):
|
||||
|
||||
salt '*' winrepo.show_sls gvim
|
||||
salt '*' winrepo.show_sls test.npp
|
||||
salt '*' winrepo.show_sls C:\test\gvim.sls
|
||||
'''
|
||||
# Get the location of the local repo
|
||||
repo = _get_local_repo_dir(saltenv)
|
||||
# Passed a filename
|
||||
if os.path.exists(name):
|
||||
sls_file = name
|
||||
|
||||
# Add the sls file name to the path
|
||||
repo = repo.split('\\')
|
||||
definition = name.split('.')
|
||||
repo.extend(definition)
|
||||
# Use a winrepo path
|
||||
else:
|
||||
# Get the location of the local repo
|
||||
repo = _get_local_repo_dir(saltenv)
|
||||
|
||||
# Check for the sls file by name
|
||||
sls_file = '{0}.sls'.format(os.sep.join(repo))
|
||||
if not os.path.exists(sls_file):
|
||||
# Add the sls file name to the path
|
||||
repo = repo.split('\\')
|
||||
definition = name.split('.')
|
||||
repo.extend(definition)
|
||||
|
||||
# Maybe it's a directory with an init.sls
|
||||
sls_file = '{0}\\init.sls'.format(os.sep.join(repo))
|
||||
# Check for the sls file by name
|
||||
sls_file = '{0}.sls'.format(os.sep.join(repo))
|
||||
if not os.path.exists(sls_file):
|
||||
|
||||
# It's neither, return
|
||||
return 'Software definition {0} not found'.format(name)
|
||||
# Maybe it's a directory with an init.sls
|
||||
sls_file = '{0}\\init.sls'.format(os.sep.join(repo))
|
||||
if not os.path.exists(sls_file):
|
||||
|
||||
# It's neither, return
|
||||
return 'Software definition {0} not found'.format(name)
|
||||
|
||||
# Load the renderer
|
||||
renderers = salt.loader.render(__opts__, __salt__)
|
||||
@ -191,9 +203,11 @@ def show_sls(name, saltenv='base'):
|
||||
config = salt.template.compile_template(
|
||||
sls_file,
|
||||
renderers,
|
||||
__opts__['renderer'])
|
||||
__opts__['renderer'],
|
||||
__opts__['renderer_blacklist'],
|
||||
__opts__['renderer_whitelist'])
|
||||
|
||||
# Dump return the error if any
|
||||
# Return the error if any
|
||||
except SaltRenderError as exc:
|
||||
log.debug('Failed to compile {0}.'.format(sls_file))
|
||||
log.debug('Error: {0}.'.format(exc))
|
||||
|
@ -263,10 +263,15 @@ def present(name,
|
||||
This also the location of the home directory to create if createhome is
|
||||
set to True.
|
||||
|
||||
createhome
|
||||
If False, the home directory will not be created if it doesn't exist.
|
||||
Please note that directories leading up to the home directory
|
||||
will NOT be created, Default is ``True``.
|
||||
createhome : True
|
||||
If set to ``False``, the home directory will not be created if it
|
||||
doesn't already exist.
|
||||
|
||||
.. warning::
|
||||
Not supported on Windows or Mac OS.
|
||||
|
||||
Additionally, parent directories will *not* be created. The parent
|
||||
directory for ``home`` must already exist.
|
||||
|
||||
password
|
||||
A password hash to set for the user. This field is only supported on
|
||||
|
Loading…
Reference in New Issue
Block a user