mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Merge pull request #7378 from s0undt3ch/hotfix/6961-deprecate-state-runas
Deprecate runas in state modules
This commit is contained in:
commit
33b75182c7
@ -11,10 +11,13 @@ you can specify what ruby version and gemset to target.
|
||||
|
||||
addressable:
|
||||
gem.installed:
|
||||
- runas: rvm
|
||||
- user: rvm
|
||||
- ruby: jruby@jgemset
|
||||
'''
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
@ -26,6 +29,7 @@ def __virtual__():
|
||||
def installed(name, # pylint: disable=C0103
|
||||
ruby=None,
|
||||
runas=None,
|
||||
user=None,
|
||||
version=None,
|
||||
rdoc=False,
|
||||
ri=False): # pylint: disable=C0103
|
||||
@ -34,21 +38,57 @@ def installed(name, # pylint: disable=C0103
|
||||
|
||||
name
|
||||
The name of the gem to install
|
||||
ruby : None
|
||||
|
||||
ruby: None
|
||||
For RVM installations: the ruby version and gemset to target.
|
||||
runas : None
|
||||
|
||||
runas: None
|
||||
The user to run gem as.
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
name: None
|
||||
The user to run gem as
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
|
||||
version : None
|
||||
Specify the version to install for the gem.
|
||||
Doesn't play nice with multiple gems at once
|
||||
|
||||
rdoc : False
|
||||
Generate RDoc documentation for the gem(s).
|
||||
|
||||
ri : False
|
||||
Generate RI documentation for the gem(s).
|
||||
'''
|
||||
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
|
||||
|
||||
gems = __salt__['gem.list'](name, ruby, runas=runas)
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
gems = __salt__['gem.list'](name, ruby, runas=user)
|
||||
if name in gems and version and version in gems[name]:
|
||||
ret['result'] = True
|
||||
ret['comment'] = 'Gem is already installed.'
|
||||
@ -63,7 +103,7 @@ def installed(name, # pylint: disable=C0103
|
||||
return ret
|
||||
if __salt__['gem.install'](name,
|
||||
ruby=ruby,
|
||||
runas=runas,
|
||||
runas=user,
|
||||
version=version,
|
||||
rdoc=rdoc,
|
||||
ri=ri):
|
||||
@ -77,19 +117,52 @@ def installed(name, # pylint: disable=C0103
|
||||
return ret
|
||||
|
||||
|
||||
def removed(name, ruby=None, runas=None):
|
||||
def removed(name, ruby=None, runas=None, user=None):
|
||||
'''
|
||||
Make sure that a gem is not installed.
|
||||
|
||||
name
|
||||
The name of the gem to uninstall
|
||||
ruby : None
|
||||
|
||||
ruby: None
|
||||
For RVM installations: the ruby version and gemset to target.
|
||||
runas : None
|
||||
runas: None
|
||||
The user to run gem as.
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user: None
|
||||
The user to run gem as
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
'''
|
||||
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
|
||||
if name not in __salt__['gem.list'](name, ruby, runas=runas):
|
||||
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
if name not in __salt__['gem.list'](name, ruby, runas=user):
|
||||
ret['result'] = True
|
||||
ret['comment'] = 'Gem is not installed.'
|
||||
return ret
|
||||
@ -97,7 +170,7 @@ def removed(name, ruby=None, runas=None):
|
||||
if __opts__['test']:
|
||||
ret['comment'] = 'The gem {0} would have been removed'.format(name)
|
||||
return ret
|
||||
if __salt__['gem.uninstall'](name, ruby, runas=runas):
|
||||
if __salt__['gem.uninstall'](name, ruby, runas=user):
|
||||
ret['result'] = True
|
||||
ret['changes'][name] = 'Removed'
|
||||
ret['comment'] = 'Gem was successfully removed.'
|
||||
|
@ -18,10 +18,14 @@ authentication, it is also possible to pass private keys to use explicitly.
|
||||
- target: /tmp/salt
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -36,6 +40,7 @@ def latest(name,
|
||||
rev=None,
|
||||
target=None,
|
||||
runas=None,
|
||||
user=None,
|
||||
force=None,
|
||||
force_checkout=False,
|
||||
submodules=False,
|
||||
@ -51,39 +56,59 @@ def latest(name,
|
||||
|
||||
name
|
||||
Address of the remote repository as passed to "git clone"
|
||||
|
||||
rev
|
||||
The remote branch, tag, or revision ID to checkout after
|
||||
clone / before update
|
||||
|
||||
target
|
||||
Name of the target directory where repository is about to be cloned
|
||||
|
||||
runas
|
||||
Name of the user performing repository management operations
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user
|
||||
Name of the user performing repository management operations
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
|
||||
force
|
||||
Force git to clone into pre-existing directories (deletes contents)
|
||||
|
||||
force_checkout
|
||||
Force a checkout even if there might be overwritten changes
|
||||
(Default: False)
|
||||
|
||||
submodules
|
||||
Update submodules on clone or branch change (Default: False)
|
||||
|
||||
mirror
|
||||
True if the repository is to be a mirror of the remote repository.
|
||||
This implies bare, and thus is incompatible with rev.
|
||||
|
||||
bare
|
||||
True if the repository is to be a bare clone of the remote repository.
|
||||
This is incompatible with rev, as nothing will be checked out.
|
||||
|
||||
remote_name
|
||||
defines a different remote name.
|
||||
For the first clone the given name is set to the default remote,
|
||||
else it is just a additional remote. (Default: 'origin')
|
||||
|
||||
always_fetch
|
||||
If a tag or branch name is used as the rev a fetch will not occur
|
||||
until the tag or branch name changes. Setting this to true will force
|
||||
a fetch to occur. Only applies when rev is set. (Default: False)
|
||||
|
||||
identity
|
||||
A path to a private key to use over SSH
|
||||
|
||||
onlyif
|
||||
A command to run as a check, run the named command only if the command
|
||||
passed to the ``onlyif`` option returns true
|
||||
|
||||
unless
|
||||
A command to run as a check, only run the named command if the command
|
||||
passed to the ``unless`` option returns false
|
||||
@ -92,7 +117,31 @@ def latest(name,
|
||||
if not target:
|
||||
return _fail(ret, '"target" option is required')
|
||||
|
||||
run_check_cmd_kwargs = {'runas': runas}
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
run_check_cmd_kwargs = {'runas': user}
|
||||
|
||||
# check if git.latest should be applied
|
||||
cret = _run_check(
|
||||
@ -111,7 +160,7 @@ def latest(name,
|
||||
log.debug(('target {0} is found, "git pull" '
|
||||
'is probably required'.format(target)))
|
||||
try:
|
||||
current_rev = __salt__['git.revision'](target, user=runas)
|
||||
current_rev = __salt__['git.revision'](target, user=user)
|
||||
|
||||
branch = __salt__['git.current_branch'](target, user=runas)
|
||||
if len(branch) > 0:
|
||||
@ -138,55 +187,54 @@ def latest(name,
|
||||
# check remote if fetch_url not == name set it
|
||||
remote = __salt__['git.remote_get'](target,
|
||||
remote=remote_name,
|
||||
user=runas)
|
||||
user=user)
|
||||
if remote is None or remote[0] != name:
|
||||
__salt__['git.remote_set'](target,
|
||||
name=remote_name,
|
||||
url=name,
|
||||
user=runas)
|
||||
user=user)
|
||||
ret['changes']['remote/{0}'.format(remote_name)] = "{0} => {1}".format(str(remote), name)
|
||||
|
||||
# check if rev is already present in repo, git-fetch otherwise
|
||||
if bare:
|
||||
__salt__['git.fetch'](target,
|
||||
opts=fetch_opts,
|
||||
user=runas,
|
||||
user=user,
|
||||
identity=identity)
|
||||
elif rev:
|
||||
|
||||
cmd = "git rev-parse " + rev
|
||||
retcode = __salt__['cmd.retcode'](cmd,
|
||||
cwd=target,
|
||||
runas=runas)
|
||||
runas=user)
|
||||
# there is a issues #3938 addressing this
|
||||
if 0 != retcode or always_fetch:
|
||||
__salt__['git.fetch'](target,
|
||||
opts=fetch_opts,
|
||||
user=runas,
|
||||
user=user,
|
||||
identity=identity)
|
||||
|
||||
__salt__['git.checkout'](target,
|
||||
rev,
|
||||
force=force_checkout,
|
||||
user=runas)
|
||||
user=user)
|
||||
|
||||
# check if we are on a branch to merge changes
|
||||
cmd = "git symbolic-ref -q HEAD > /dev/null"
|
||||
retcode = __salt__['cmd.retcode'](cmd, cwd=target, runas=runas)
|
||||
retcode = __salt__['cmd.retcode'](cmd, cwd=target, runas=user)
|
||||
if 0 == retcode:
|
||||
__salt__['git.fetch' if bare else 'git.pull'](target,
|
||||
opts=fetch_opts,
|
||||
user=runas,
|
||||
user=user,
|
||||
identity=identity)
|
||||
|
||||
if submodules:
|
||||
__salt__['git.submodule'](target,
|
||||
user=runas,
|
||||
user=user,
|
||||
identity=identity,
|
||||
opts='--recursive')
|
||||
|
||||
new_rev = __salt__['git.revision'](cwd=target, user=runas)
|
||||
|
||||
new_rev = __salt__['git.revision'](cwd=target, user=user)
|
||||
except Exception as exc:
|
||||
return _fail(
|
||||
ret,
|
||||
@ -233,21 +281,21 @@ def latest(name,
|
||||
# do the clone
|
||||
__salt__['git.clone'](target,
|
||||
name,
|
||||
user=runas,
|
||||
user=user,
|
||||
opts=opts,
|
||||
identity=identity)
|
||||
|
||||
if rev and not bare:
|
||||
__salt__['git.checkout'](target, rev, user=runas)
|
||||
__salt__['git.checkout'](target, rev, user=user)
|
||||
|
||||
if submodules:
|
||||
__salt__['git.submodule'](target,
|
||||
user=runas,
|
||||
user=user,
|
||||
identity=identity,
|
||||
opts='--recursive')
|
||||
|
||||
new_rev = None if bare else (
|
||||
__salt__['git.revision'](cwd=target, user=runas))
|
||||
__salt__['git.revision'](cwd=target, user=user))
|
||||
|
||||
except Exception as exc:
|
||||
return _fail(
|
||||
@ -263,22 +311,56 @@ def latest(name,
|
||||
return ret
|
||||
|
||||
|
||||
def present(name, bare=True, runas=None, force=False):
|
||||
def present(name, bare=True, runas=None, user=None, force=False):
|
||||
'''
|
||||
Make sure the repository is present in the given directory
|
||||
|
||||
name
|
||||
Name of the directory where the repository is about to be created
|
||||
|
||||
bare
|
||||
Create a bare repository (Default: True)
|
||||
|
||||
runas
|
||||
Name of the user performing repository management operations
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user
|
||||
Name of the user performing repository management operations
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
|
||||
force
|
||||
Force-create a new repository into an pre-existing non-git directory
|
||||
(deletes contents)
|
||||
'''
|
||||
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
|
||||
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
# If the named directory is a git repo return True
|
||||
if os.path.isdir(name):
|
||||
if bare and os.path.isfile('{0}/HEAD'.format(name)):
|
||||
@ -307,7 +389,7 @@ def present(name, bare=True, runas=None, force=False):
|
||||
shutil.rmtree(name)
|
||||
|
||||
opts = '--bare' if bare else ''
|
||||
__salt__['git.init'](cwd=name, user=runas, opts=opts)
|
||||
__salt__['git.init'](cwd=name, user=user, opts=opts)
|
||||
|
||||
message = 'Initialized repository {0}'.format(name)
|
||||
log.info(message)
|
||||
|
@ -23,12 +23,12 @@ import os
|
||||
import shutil
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
from salt.states.git import _fail, _neutral_test
|
||||
from salt import utils
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
if utils.is_windows():
|
||||
if salt.utils.is_windows():
|
||||
hg_binary = "hg.exe"
|
||||
else:
|
||||
hg_binary = "hg"
|
||||
@ -45,22 +45,59 @@ def latest(name,
|
||||
rev=None,
|
||||
target=None,
|
||||
runas=None,
|
||||
user=None,
|
||||
force=False):
|
||||
'''
|
||||
Make sure the repository is cloned to the given directory and is up to date
|
||||
|
||||
name
|
||||
Address of the remote repository as passed to "hg clone"
|
||||
|
||||
rev
|
||||
The remote branch, tag, or revision hash to clone/pull
|
||||
|
||||
target
|
||||
Name of the target directory where repository is about to be cloned
|
||||
|
||||
runas
|
||||
Name of the user performing repository management operations
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user
|
||||
Name of the user performing repository management operations
|
||||
|
||||
.. versionadded: 0.17.0
|
||||
|
||||
force
|
||||
Force hg to clone into pre-existing directories (deletes contents)
|
||||
'''
|
||||
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
|
||||
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
if not target:
|
||||
return _fail(ret, '"target option is required')
|
||||
|
||||
@ -69,7 +106,7 @@ def latest(name,
|
||||
os.path.isdir('{0}/.hg'.format(target)))
|
||||
|
||||
if is_repository:
|
||||
ret = _update_repo(ret, target, runas, rev)
|
||||
ret = _update_repo(ret, target, user, rev)
|
||||
else:
|
||||
if os.path.isdir(target):
|
||||
fail = _handle_existing(ret, target, force)
|
||||
@ -84,17 +121,17 @@ def latest(name,
|
||||
ret,
|
||||
'Repository {0} is about to be cloned to {1}'.format(
|
||||
name, target))
|
||||
_clone_repo(ret, target, name, runas, rev)
|
||||
_clone_repo(ret, target, name, user, rev)
|
||||
return ret
|
||||
|
||||
|
||||
def _update_repo(ret, target, runas, rev):
|
||||
def _update_repo(ret, target, user, rev):
|
||||
log.debug(
|
||||
'target {0} is found, '
|
||||
'"hg pull && hg up is probably required"'.format(target)
|
||||
)
|
||||
|
||||
current_rev = __salt__['hg.revision'](target, user=runas)
|
||||
current_rev = __salt__['hg.revision'](target, user=user)
|
||||
if not current_rev:
|
||||
return _fail(
|
||||
ret,
|
||||
@ -108,14 +145,14 @@ def _update_repo(ret, target, runas, rev):
|
||||
ret,
|
||||
test_result)
|
||||
|
||||
pull_out = __salt__['hg.pull'](target, user=runas)
|
||||
pull_out = __salt__['hg.pull'](target, user=user)
|
||||
|
||||
if rev:
|
||||
__salt__['hg.update'](target, rev, user=runas)
|
||||
__salt__['hg.update'](target, rev, user=user)
|
||||
else:
|
||||
__salt__['hg.update'](target, 'tip', user=runas)
|
||||
__salt__['hg.update'](target, 'tip', user=user)
|
||||
|
||||
new_rev = __salt__['hg.revision'](cwd=target, user=runas)
|
||||
new_rev = __salt__['hg.revision'](cwd=target, user=user)
|
||||
|
||||
if current_rev != new_rev:
|
||||
revision_text = '{0} => {1}'.format(current_rev, new_rev)
|
||||
@ -149,16 +186,16 @@ def _handle_existing(ret, target, force):
|
||||
return _fail(ret, 'Directory exists, and is not empty')
|
||||
|
||||
|
||||
def _clone_repo(ret, target, name, runas, rev):
|
||||
result = __salt__['hg.clone'](target, name, user=runas)
|
||||
def _clone_repo(ret, target, name, user, rev):
|
||||
result = __salt__['hg.clone'](target, name, user=user)
|
||||
|
||||
if not os.path.isdir(target):
|
||||
return _fail(ret, result)
|
||||
|
||||
if rev:
|
||||
__salt__['hg.update'](target, rev, user=runas)
|
||||
__salt__['hg.update'](target, rev, user=user)
|
||||
|
||||
new_rev = __salt__['hg.revision'](cwd=target, user=runas)
|
||||
new_rev = __salt__['hg.revision'](cwd=target, user=user)
|
||||
message = 'Repository {0} cloned to {1}'.format(name, target)
|
||||
log.info(message)
|
||||
ret['comment'] = message
|
||||
|
@ -20,6 +20,7 @@ for the package which provides npm (simply ``npm`` in most cases). Example:
|
||||
'''
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
from salt.exceptions import CommandExecutionError, CommandNotFoundError
|
||||
|
||||
|
||||
@ -33,6 +34,7 @@ def __virtual__():
|
||||
def installed(name,
|
||||
dir=None,
|
||||
runas=None,
|
||||
user=None,
|
||||
force_reinstall=False,
|
||||
**kwargs):
|
||||
'''
|
||||
@ -46,11 +48,42 @@ def installed(name,
|
||||
runas
|
||||
The user to run NPM with
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user
|
||||
The user to run NPM with
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
|
||||
force_reinstall
|
||||
Install the package even if it is already installed
|
||||
'''
|
||||
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
|
||||
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
prefix = name.split('@')[0].strip()
|
||||
|
||||
try:
|
||||
@ -78,7 +111,7 @@ def installed(name,
|
||||
call = __salt__['npm.install'](
|
||||
pkg=name,
|
||||
dir=dir,
|
||||
runas=runas
|
||||
runas=user
|
||||
)
|
||||
except (CommandNotFoundError, CommandExecutionError) as err:
|
||||
ret['result'] = False
|
||||
@ -101,6 +134,7 @@ def installed(name,
|
||||
def removed(name,
|
||||
dir=None,
|
||||
runas=None,
|
||||
user=None,
|
||||
**kwargs):
|
||||
'''
|
||||
Verify that the given package is not installed.
|
||||
@ -111,9 +145,40 @@ def removed(name,
|
||||
|
||||
runas
|
||||
The user to run NPM with
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user
|
||||
The user to run NPM with
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
'''
|
||||
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
|
||||
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
try:
|
||||
installed_pkgs = __salt__['npm.list'](dir=dir)
|
||||
except (CommandExecutionError, CommandNotFoundError) as err:
|
||||
@ -131,9 +196,7 @@ def removed(name,
|
||||
ret['comment'] = 'Package {0} is set to be removed'.format(name)
|
||||
return ret
|
||||
|
||||
if __salt__['npm.uninstall'](pkg=name,
|
||||
dir=dir,
|
||||
runas=runas):
|
||||
if __salt__['npm.uninstall'](pkg=name, dir=dir, runas=user):
|
||||
ret['result'] = True
|
||||
ret['changes'][name] = 'Removed'
|
||||
ret['comment'] = 'Package was successfully removed.'
|
||||
@ -144,9 +207,9 @@ def removed(name,
|
||||
return ret
|
||||
|
||||
|
||||
def bootstrap(
|
||||
name,
|
||||
runas=None):
|
||||
def bootstrap(name,
|
||||
runas=None,
|
||||
user=None):
|
||||
'''
|
||||
Bootstraps a node.js application.
|
||||
|
||||
@ -156,17 +219,42 @@ def bootstrap(
|
||||
runas
|
||||
The user to run NPM with
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user
|
||||
The user to run NPM with
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
|
||||
|
||||
'''
|
||||
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
try:
|
||||
call = __salt__['npm.install'](
|
||||
dir=name,
|
||||
runas=runas,
|
||||
pkg=None
|
||||
)
|
||||
|
||||
call = __salt__['npm.install'](dir=name, runas=user, pkg=None)
|
||||
except (CommandNotFoundError, CommandExecutionError) as err:
|
||||
ret['result'] = False
|
||||
ret['comment'] = 'Error Bootstrapping \'{0}\': {1}'.format(name, err)
|
||||
|
@ -12,6 +12,9 @@ Databases can be set as either absent or present
|
||||
postgres_database.present
|
||||
'''
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
@ -27,7 +30,8 @@ def present(name,
|
||||
lc_ctype=None,
|
||||
owner=None,
|
||||
template=None,
|
||||
runas=None):
|
||||
runas=None,
|
||||
user=None):
|
||||
'''
|
||||
Ensure that the named database is present with the specified properties.
|
||||
For more information about all of these options see man createdb(1)
|
||||
@ -55,13 +59,44 @@ def present(name,
|
||||
|
||||
runas
|
||||
System user all operations should be performed on behalf of
|
||||
|
||||
.. derecated:: 0.17.0
|
||||
|
||||
user
|
||||
System user all operations should be performed on behalf of
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
'''
|
||||
ret = {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': 'Database {0} is already present'.format(name)}
|
||||
|
||||
dbs = __salt__['postgres.db_list'](runas=runas)
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
dbs = __salt__['postgres.db_list'](runas=user)
|
||||
db_params = dbs.get(name, {})
|
||||
|
||||
if name in dbs and all((
|
||||
@ -92,14 +127,14 @@ def present(name,
|
||||
'need to be changed'.format(name)
|
||||
return ret
|
||||
if name not in dbs and __salt__['postgres.db_create'](
|
||||
name,
|
||||
tablespace=tablespace,
|
||||
encoding=encoding,
|
||||
lc_collate=lc_collate,
|
||||
lc_ctype=lc_ctype,
|
||||
owner=owner,
|
||||
template=template,
|
||||
runas=runas):
|
||||
name,
|
||||
tablespace=tablespace,
|
||||
encoding=encoding,
|
||||
lc_collate=lc_collate,
|
||||
lc_ctype=lc_ctype,
|
||||
owner=owner,
|
||||
template=template,
|
||||
runas=user):
|
||||
ret['comment'] = 'The database {0} has been created'.format(name)
|
||||
ret['changes'][name] = 'Present'
|
||||
elif name in dbs and __salt__['postgres.db_alter'](name,
|
||||
@ -119,7 +154,7 @@ def present(name,
|
||||
return ret
|
||||
|
||||
|
||||
def absent(name, runas=None):
|
||||
def absent(name, runas=None, user=None):
|
||||
'''
|
||||
Ensure that the named database is absent
|
||||
|
||||
@ -128,19 +163,49 @@ def absent(name, runas=None):
|
||||
|
||||
runas
|
||||
System user all operations should be performed on behalf of
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user
|
||||
System user all operations should be performed on behalf of
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
'''
|
||||
ret = {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': ''}
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
#check if db exists and remove it
|
||||
if __salt__['postgres.db_exists'](name, runas=runas):
|
||||
if __salt__['postgres.db_exists'](name, runas=user):
|
||||
if __opts__['test']:
|
||||
ret['result'] = None
|
||||
ret['comment'] = 'Database {0} is set to be removed'.format(name)
|
||||
return ret
|
||||
if __salt__['postgres.db_remove'](name, runas=runas):
|
||||
if __salt__['postgres.db_remove'](name, runas=user):
|
||||
ret['comment'] = 'Database {0} has been removed'.format(name)
|
||||
ret['changes'][name] = 'Absent'
|
||||
return ret
|
||||
|
@ -11,6 +11,8 @@ The postgres_group module is used to create and manage Postgres groups.
|
||||
postgres_group.present
|
||||
'''
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
@ -27,7 +29,8 @@ def present(name,
|
||||
replication=False,
|
||||
password=None,
|
||||
groups=None,
|
||||
runas=None):
|
||||
runas=None,
|
||||
user=None):
|
||||
'''
|
||||
Ensure that the named group is present with the specified privileges
|
||||
|
||||
@ -57,14 +60,45 @@ def present(name,
|
||||
|
||||
runas
|
||||
System user all operations should be performed on behalf of
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user
|
||||
System user all operations should be performed on behalf of
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
'''
|
||||
ret = {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': 'Group {0} is already present'.format(name)}
|
||||
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
# check if user exists
|
||||
if __salt__['postgres.user_exists'](name, runas=runas):
|
||||
if __salt__['postgres.user_exists'](name, runas=user):
|
||||
return ret
|
||||
|
||||
# The user is not present, make it!
|
||||
@ -80,7 +114,7 @@ def present(name,
|
||||
replication=replication,
|
||||
rolepassword=password,
|
||||
groups=groups,
|
||||
runas=runas):
|
||||
runas=user):
|
||||
ret['comment'] = 'The group {0} has been created'.format(name)
|
||||
ret['changes'][name] = 'Present'
|
||||
else:
|
||||
@ -90,7 +124,7 @@ def present(name,
|
||||
return ret
|
||||
|
||||
|
||||
def absent(name, runas=None):
|
||||
def absent(name, runas=None, user=None):
|
||||
'''
|
||||
Ensure that the named group is absent
|
||||
|
||||
@ -99,19 +133,50 @@ def absent(name, runas=None):
|
||||
|
||||
runas
|
||||
System user all operations should be performed on behalf of
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user
|
||||
System user all operations should be performed on behalf of
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
'''
|
||||
ret = {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': ''}
|
||||
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
# check if group exists and remove it
|
||||
if __salt__['postgres.user_exists'](name, runas=runas):
|
||||
if __salt__['postgres.user_exists'](name, runas=user):
|
||||
if __opts__['test']:
|
||||
ret['result'] = None
|
||||
ret['comment'] = 'Group {0} is set to be removed'.format(name)
|
||||
return ret
|
||||
if __salt__['postgres.group_remove'](name, runas=runas):
|
||||
if __salt__['postgres.group_remove'](name, runas=user):
|
||||
ret['comment'] = 'Group {0} has been removed'.format(name)
|
||||
ret['changes'][name] = 'Absent'
|
||||
return ret
|
||||
|
@ -11,6 +11,9 @@ The postgres_users module is used to create and manage Postgres users.
|
||||
postgres_user.present
|
||||
'''
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
@ -27,7 +30,8 @@ def present(name,
|
||||
replication=False,
|
||||
password=None,
|
||||
groups=None,
|
||||
runas=None):
|
||||
runas=None,
|
||||
user=None):
|
||||
'''
|
||||
Ensure that the named user is present with the specified privileges
|
||||
|
||||
@ -57,14 +61,45 @@ def present(name,
|
||||
|
||||
runas
|
||||
System user all operations should be performed on behalf of
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user
|
||||
System user all operations should be performed on behalf of
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
'''
|
||||
ret = {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': 'User {0} is already present'.format(name)}
|
||||
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
# check if user exists
|
||||
if __salt__['postgres.user_exists'](name, runas=runas):
|
||||
if __salt__['postgres.user_exists'](name, runas=user):
|
||||
return ret
|
||||
|
||||
# The user is not present, make it!
|
||||
@ -80,7 +115,7 @@ def present(name,
|
||||
replication=replication,
|
||||
rolepassword=password,
|
||||
groups=groups,
|
||||
runas=runas):
|
||||
runas=user):
|
||||
ret['comment'] = 'The user {0} has been created'.format(name)
|
||||
ret['changes'][name] = 'Present'
|
||||
else:
|
||||
@ -90,7 +125,7 @@ def present(name,
|
||||
return ret
|
||||
|
||||
|
||||
def absent(name, runas=None):
|
||||
def absent(name, runas=None, user=None):
|
||||
'''
|
||||
Ensure that the named user is absent
|
||||
|
||||
@ -99,19 +134,50 @@ def absent(name, runas=None):
|
||||
|
||||
runas
|
||||
System user all operations should be performed on behalf of
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user
|
||||
System user all operations should be performed on behalf of
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
'''
|
||||
ret = {'name': name,
|
||||
'changes': {},
|
||||
'result': True,
|
||||
'comment': ''}
|
||||
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
# check if user exists and remove it
|
||||
if __salt__['postgres.user_exists'](name, runas=runas):
|
||||
if __salt__['postgres.user_exists'](name, runas=user):
|
||||
if __opts__['test']:
|
||||
ret['result'] = None
|
||||
ret['comment'] = 'User {0} is set to be removed'.format(name)
|
||||
return ret
|
||||
if __salt__['postgres.user_remove'](name, runas=runas):
|
||||
if __salt__['postgres.user_remove'](name, runas=user):
|
||||
ret['comment'] = 'User {0} has been removed'.format(name)
|
||||
ret['changes'][name] = 'Absent'
|
||||
return ret
|
||||
|
@ -15,6 +15,9 @@ Manage RabbitMQ Virtual Hosts.
|
||||
# Import python libs
|
||||
import logging
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -30,6 +33,7 @@ def __virtual__():
|
||||
|
||||
def present(name,
|
||||
user=None,
|
||||
owner=None,
|
||||
conf=None,
|
||||
write=None,
|
||||
read=None,
|
||||
@ -41,6 +45,9 @@ def present(name,
|
||||
VHost name
|
||||
user
|
||||
Initial user permission to set on the VHost, if present
|
||||
.. deprecated:: 0.17.0
|
||||
owner
|
||||
Initial owner permission to set on the VHost, if present
|
||||
conf
|
||||
Initial conf string to apply to the VHost and user. Defaults to .*
|
||||
write
|
||||
@ -54,6 +61,30 @@ def present(name,
|
||||
'''
|
||||
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
|
||||
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please start deprecating \'runas\' at this stage. Ping s0undt3ch for '
|
||||
'additional information or see #6961.',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if user:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'user\' argument is being deprecated in favor or \'owner\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and owner is not None:
|
||||
# owner wins over user but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'owner\' and \'user\' arguments. Please don\'t. '
|
||||
'\'user\' is being ignored in favor of \'owner\'.'
|
||||
)
|
||||
user = None
|
||||
elif user is not None:
|
||||
# Support old runas usage
|
||||
owner = user
|
||||
user = None
|
||||
|
||||
vhost_exists = __salt__['rabbitmq.vhost_exists'](name, runas=runas)
|
||||
|
||||
if __opts__['test']:
|
||||
@ -66,7 +97,7 @@ def present(name,
|
||||
if user is not None:
|
||||
ret['comment'] += (
|
||||
' Setting permissions for {0} {1} {2} {3}'.format(
|
||||
user,
|
||||
owner,
|
||||
conf or '.*',
|
||||
write or '.*',
|
||||
read or '.*'
|
||||
@ -82,12 +113,12 @@ def present(name,
|
||||
else:
|
||||
ret['comment'] = 'VHost {0} already exists'.format(name)
|
||||
|
||||
if user is not None:
|
||||
if owner is not None:
|
||||
conf = conf or '.*'
|
||||
write = write or '.*'
|
||||
read = read or '.*'
|
||||
result = __salt__['rabbitmq.set_permissions'](
|
||||
name, user, conf, write, read, runas=runas)
|
||||
name, owner, conf, write, read, runas=runas)
|
||||
|
||||
if 'Error' in result:
|
||||
ret['result'] = False
|
||||
|
@ -44,23 +44,26 @@ This is how a state configuration could look like:
|
||||
# Import python libs
|
||||
import re
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
|
||||
def _check_rbenv(ret, runas=None):
|
||||
|
||||
def _check_rbenv(ret, user=None):
|
||||
'''
|
||||
Check to see if rbenv is installed.
|
||||
'''
|
||||
if not __salt__['rbenv.is_installed'](runas):
|
||||
if not __salt__['rbenv.is_installed'](user):
|
||||
ret['result'] = False
|
||||
ret['comment'] = 'Rbenv is not installed.'
|
||||
return ret
|
||||
|
||||
|
||||
def _ruby_installed(ret, ruby, runas=None):
|
||||
def _ruby_installed(ret, ruby, user=None):
|
||||
'''
|
||||
Check to see if given ruby is installed.
|
||||
'''
|
||||
default = __salt__['rbenv.default'](runas=runas)
|
||||
for version in __salt__['rbenv.versions'](runas):
|
||||
default = __salt__['rbenv.default'](runas=user)
|
||||
for version in __salt__['rbenv.versions'](user):
|
||||
if version == ruby:
|
||||
ret['result'] = True
|
||||
ret['comment'] = 'Requested ruby exists.'
|
||||
@ -70,13 +73,13 @@ def _ruby_installed(ret, ruby, runas=None):
|
||||
return ret
|
||||
|
||||
|
||||
def _check_and_install_ruby(ret, ruby, default=False, runas=None):
|
||||
def _check_and_install_ruby(ret, ruby, default=False, user=None):
|
||||
'''
|
||||
Verify that ruby is installed, install if unavailable
|
||||
'''
|
||||
ret = _ruby_installed(ret, ruby, runas=runas)
|
||||
ret = _ruby_installed(ret, ruby, user=user)
|
||||
if not ret['result']:
|
||||
if __salt__['rbenv.install_ruby'](ruby, runas=runas):
|
||||
if __salt__['rbenv.install_ruby'](ruby, runas=user):
|
||||
ret['result'] = True
|
||||
ret['changes'][ruby] = 'Installed'
|
||||
ret['comment'] = 'Successfully installed ruby'
|
||||
@ -87,27 +90,60 @@ def _check_and_install_ruby(ret, ruby, default=False, runas=None):
|
||||
return ret
|
||||
|
||||
if default:
|
||||
__salt__['rbenv.default'](ruby, runas=runas)
|
||||
__salt__['rbenv.default'](ruby, runas=user)
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def installed(name, default=False, runas=None):
|
||||
def installed(name, default=False, runas=None, user=None):
|
||||
'''
|
||||
Verify that the specified ruby is installed with rbenv. Rbenv is
|
||||
installed if necessary.
|
||||
|
||||
name
|
||||
The version of ruby to install
|
||||
|
||||
default : False
|
||||
Whether to make this ruby the default.
|
||||
runas : None
|
||||
|
||||
runas: None
|
||||
The user to run rbenv as.
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user: None
|
||||
The user to run rbenv as.
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
|
||||
.. versionadded:: 0.16.0
|
||||
'''
|
||||
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
|
||||
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
if name.startswith('ruby-'):
|
||||
name = re.sub(r'^ruby-', '', name)
|
||||
|
||||
@ -115,27 +151,27 @@ def installed(name, default=False, runas=None):
|
||||
ret['comment'] = 'Ruby {0} is set to be installed'.format(name)
|
||||
return ret
|
||||
|
||||
ret = _check_rbenv(ret, runas)
|
||||
ret = _check_rbenv(ret, user)
|
||||
if ret['result'] is False:
|
||||
if not __salt__['rbenv.install'](runas):
|
||||
if not __salt__['rbenv.install'](user):
|
||||
ret['comment'] = 'Rbenv failed to install'
|
||||
return ret
|
||||
else:
|
||||
return _check_and_install_ruby(ret, name, default, runas=runas)
|
||||
return _check_and_install_ruby(ret, name, default, user=user)
|
||||
else:
|
||||
return _check_and_install_ruby(ret, name, default, runas=runas)
|
||||
return _check_and_install_ruby(ret, name, default, user=user)
|
||||
|
||||
|
||||
def _check_and_uninstall_ruby(ret, ruby, runas=None):
|
||||
def _check_and_uninstall_ruby(ret, ruby, user=None):
|
||||
'''
|
||||
Verify that ruby is uninstalled
|
||||
'''
|
||||
ret = _ruby_installed(ret, ruby, runas=runas)
|
||||
ret = _ruby_installed(ret, ruby, user=user)
|
||||
if ret['result']:
|
||||
if ret['default']:
|
||||
__salt__['rbenv.default']('system', runas=runas)
|
||||
__salt__['rbenv.default']('system', runas=user)
|
||||
|
||||
if __salt__['rbenv.uninstall_ruby'](ruby, runas=runas):
|
||||
if __salt__['rbenv.uninstall_ruby'](ruby, runas=user):
|
||||
ret['result'] = True
|
||||
ret['changes'][ruby] = 'Uninstalled'
|
||||
ret['comment'] = 'Successfully removed ruby'
|
||||
@ -151,20 +187,52 @@ def _check_and_uninstall_ruby(ret, ruby, runas=None):
|
||||
return ret
|
||||
|
||||
|
||||
def absent(name, runas=None):
|
||||
def absent(name, runas=None, user=None):
|
||||
'''
|
||||
Verify that the specified ruby is not installed with rbenv. Rbenv
|
||||
is installed if necessary.
|
||||
|
||||
name
|
||||
The version of ruby to uninstall
|
||||
runas : None
|
||||
|
||||
runas: None
|
||||
The user to run rbenv as.
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user: None
|
||||
The user to run rbenv as.
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
|
||||
.. versionadded:: 0.16.0
|
||||
'''
|
||||
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
|
||||
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
if name.startswith('ruby-'):
|
||||
name = re.sub(r'^ruby-', '', name)
|
||||
|
||||
@ -172,10 +240,10 @@ def absent(name, runas=None):
|
||||
ret['comment'] = 'Ruby {0} is set to be uninstalled'.format(name)
|
||||
return ret
|
||||
|
||||
ret = _check_rbenv(ret, runas)
|
||||
ret = _check_rbenv(ret, user)
|
||||
if ret['result'] is False:
|
||||
ret['result'] = True
|
||||
ret['comment'] = 'Rbenv not installed, {0} not either'.format(name)
|
||||
return ret
|
||||
else:
|
||||
return _check_and_uninstall_ruby(ret, name, runas=runas)
|
||||
return _check_and_uninstall_ruby(ret, name, user=user)
|
||||
|
@ -73,7 +73,7 @@ configuration could look like:
|
||||
ruby-1.9.2:
|
||||
rvm.installed:
|
||||
- default: True
|
||||
- runas: rvm
|
||||
- user: rvm
|
||||
- require:
|
||||
- pkg: rvm-deps
|
||||
- pkg: mri-deps
|
||||
@ -81,7 +81,7 @@ configuration could look like:
|
||||
|
||||
jruby:
|
||||
rvm.installed:
|
||||
- runas: rvm
|
||||
- user: rvm
|
||||
- require:
|
||||
- pkg: rvm-deps
|
||||
- pkg: jruby-deps
|
||||
@ -90,14 +90,14 @@ configuration could look like:
|
||||
jgemset:
|
||||
rvm.gemset_present:
|
||||
- ruby: jruby
|
||||
- runas: rvm
|
||||
- user: rvm
|
||||
- require:
|
||||
- rvm: jruby
|
||||
|
||||
mygemset:
|
||||
rvm.gemset_present:
|
||||
- ruby: ruby-1.9.2
|
||||
- runas: rvm
|
||||
- user: rvm
|
||||
- require:
|
||||
- rvm: ruby-1.9.2
|
||||
'''
|
||||
@ -105,24 +105,27 @@ configuration could look like:
|
||||
# Import python libs
|
||||
import re
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
|
||||
def _check_rvm(ret, runas=None):
|
||||
|
||||
def _check_rvm(ret, user=None):
|
||||
'''
|
||||
Check to see if rvm is installed.
|
||||
'''
|
||||
if not __salt__['rvm.is_installed'](runas):
|
||||
if not __salt__['rvm.is_installed'](user):
|
||||
ret['result'] = False
|
||||
ret['comment'] = 'RVM is not installed.'
|
||||
return ret
|
||||
|
||||
|
||||
def _check_and_install_ruby(ret, ruby, default=False, runas=None):
|
||||
def _check_and_install_ruby(ret, ruby, default=False, user=None):
|
||||
'''
|
||||
Verify that ruby is installed, install if unavailable
|
||||
'''
|
||||
ret = _check_ruby(ret, ruby, runas=runas)
|
||||
ret = _check_ruby(ret, ruby, user=user)
|
||||
if not ret['result']:
|
||||
if __salt__['rvm.install_ruby'](ruby, runas=runas):
|
||||
if __salt__['rvm.install_ruby'](ruby, runas=user):
|
||||
ret['result'] = True
|
||||
ret['changes'][ruby] = 'Installed'
|
||||
ret['comment'] = 'Successfully installed ruby.'
|
||||
@ -133,12 +136,12 @@ def _check_and_install_ruby(ret, ruby, default=False, runas=None):
|
||||
return ret
|
||||
|
||||
if default:
|
||||
__salt__['rvm.set_default'](ruby, runas=runas)
|
||||
__salt__['rvm.set_default'](ruby, runas=user)
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def _check_ruby(ret, ruby, runas=None):
|
||||
def _check_ruby(ret, ruby, user=None):
|
||||
'''
|
||||
Check that ruby is installed
|
||||
'''
|
||||
@ -151,7 +154,7 @@ def _check_ruby(ret, ruby, runas=None):
|
||||
match_version = False
|
||||
ruby = re.sub('^ruby-', '', ruby)
|
||||
|
||||
for impl, version, default in __salt__['rvm.list'](runas=runas):
|
||||
for impl, version, default in __salt__['rvm.list'](runas=user):
|
||||
if impl != 'ruby':
|
||||
version = '{impl}-{version}'.format(impl=impl, version=version)
|
||||
if not match_micro_version:
|
||||
@ -166,49 +169,115 @@ def _check_ruby(ret, ruby, runas=None):
|
||||
return ret
|
||||
|
||||
|
||||
def installed(name, default=False, runas=None):
|
||||
def installed(name, default=False, runas=None, user=None):
|
||||
'''
|
||||
Verify that the specified ruby is installed with RVM. RVM is
|
||||
installed when necessary.
|
||||
|
||||
name
|
||||
The version of ruby to install
|
||||
|
||||
default : False
|
||||
Whether to make this ruby the default.
|
||||
runas : None
|
||||
|
||||
runas: None
|
||||
The user to run rvm as.
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user: None
|
||||
The user to run rvm as.
|
||||
|
||||
..versionadded:: 0.17.0
|
||||
'''
|
||||
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
|
||||
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
if __opts__['test']:
|
||||
ret['comment'] = 'Ruby {0} is set to be installed'.format(name)
|
||||
return ret
|
||||
|
||||
ret = _check_rvm(ret, runas)
|
||||
ret = _check_rvm(ret, user)
|
||||
if ret['result'] is False:
|
||||
if not __salt__['rvm.install'](runas=runas):
|
||||
if not __salt__['rvm.install'](runas=user):
|
||||
ret['comment'] = 'RVM failed to install.'
|
||||
return ret
|
||||
else:
|
||||
return _check_and_install_ruby(ret, name, default, runas=runas)
|
||||
return _check_and_install_ruby(ret, name, default, user=user)
|
||||
else:
|
||||
return _check_and_install_ruby(ret, name, default, runas=runas)
|
||||
return _check_and_install_ruby(ret, name, default, user=user)
|
||||
|
||||
|
||||
def gemset_present(name, ruby='default', runas=None):
|
||||
def gemset_present(name, ruby='default', runas=None, user=None):
|
||||
'''
|
||||
Verify that the gemset is present.
|
||||
|
||||
name
|
||||
The name of the gemset.
|
||||
ruby : default
|
||||
|
||||
ruby: default
|
||||
The ruby version this gemset belongs to.
|
||||
runas : None
|
||||
|
||||
runas: None
|
||||
The user to run rvm as.
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user: None
|
||||
The user to run rvm as.
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
'''
|
||||
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
|
||||
|
||||
ret = _check_rvm(ret, runas)
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
ret = _check_rvm(ret, user)
|
||||
if ret['result'] is False:
|
||||
return ret
|
||||
|
||||
@ -220,7 +289,7 @@ def gemset_present(name, ruby='default', runas=None):
|
||||
ret['comment'] = 'Requested ruby implementation was not found.'
|
||||
return ret
|
||||
|
||||
if name in __salt__['rvm.gemset_list'](ruby, runas=runas):
|
||||
if name in __salt__['rvm.gemset_list'](ruby, runas=user):
|
||||
ret['result'] = True
|
||||
ret['comment'] = 'Gemset already exists.'
|
||||
else:
|
||||
@ -228,7 +297,7 @@ def gemset_present(name, ruby='default', runas=None):
|
||||
ret['result'] = None
|
||||
ret['comment'] = 'Set to install gemset {0}'.format(name)
|
||||
return ret
|
||||
if __salt__['rvm.gemset_create'](ruby, name, runas=runas):
|
||||
if __salt__['rvm.gemset_create'](ruby, name, runas=user):
|
||||
ret['result'] = True
|
||||
ret['comment'] = 'Gemset successfully created.'
|
||||
ret['changes'][name] = 'created'
|
||||
|
@ -17,6 +17,9 @@ Interaction with the Supervisor daemon.
|
||||
# Import python libs
|
||||
import logging
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -39,6 +42,7 @@ def _is_stopped_state(state):
|
||||
def running(name,
|
||||
restart=False,
|
||||
update=False,
|
||||
user=None,
|
||||
runas=None,
|
||||
conf_file=None,
|
||||
bin_env=None):
|
||||
@ -47,22 +51,58 @@ def running(name,
|
||||
|
||||
name
|
||||
Service name as defined in the supervisor configuration file
|
||||
|
||||
restart
|
||||
Whether to force a restart
|
||||
|
||||
update
|
||||
Whether to update the supervisor configuration.
|
||||
|
||||
runas
|
||||
Name of the user to run the supervisorctl command
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user
|
||||
Name of the user to run the supervisorctl command
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
|
||||
conf_file
|
||||
path to supervisorctl config file
|
||||
|
||||
bin_env
|
||||
path to supervisorctl bin or path to virtualenv with supervisor installed
|
||||
|
||||
'''
|
||||
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
|
||||
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
all_processes = __salt__['supervisord.status'](
|
||||
user=runas,
|
||||
user=user,
|
||||
conf_file=conf_file,
|
||||
bin_env=bin_env
|
||||
)
|
||||
@ -82,13 +122,13 @@ def running(name,
|
||||
if needs_update:
|
||||
comment = 'Adding service: {0}'.format(name)
|
||||
__salt__['supervisord.reread'](
|
||||
user=runas,
|
||||
user=user,
|
||||
conf_file=conf_file,
|
||||
bin_env=bin_env
|
||||
)
|
||||
result = __salt__['supervisord.add'](
|
||||
name,
|
||||
user=runas,
|
||||
user=user,
|
||||
conf_file=conf_file,
|
||||
bin_env=bin_env
|
||||
)
|
||||
@ -100,7 +140,7 @@ def running(name,
|
||||
elif update:
|
||||
comment = 'Updating supervisor'
|
||||
result = __salt__['supervisord.update'](
|
||||
user=runas,
|
||||
user=user,
|
||||
conf_file=conf_file,
|
||||
bin_env=bin_env
|
||||
)
|
||||
@ -117,7 +157,7 @@ def running(name,
|
||||
log.debug(comment)
|
||||
result = __salt__['supervisord.restart'](
|
||||
name,
|
||||
user=runas,
|
||||
user=user,
|
||||
conf_file=conf_file,
|
||||
bin_env=bin_env
|
||||
)
|
||||
@ -150,6 +190,7 @@ def running(name,
|
||||
|
||||
|
||||
def dead(name,
|
||||
user=None,
|
||||
runas=None,
|
||||
conf_file=None,
|
||||
bin_env=None):
|
||||
@ -158,16 +199,50 @@ def dead(name,
|
||||
|
||||
name
|
||||
Service name as defined in the supervisor configuration file
|
||||
|
||||
runas
|
||||
Name of the user to run the supervisorctl command
|
||||
|
||||
.. deprecated:: 0.17.0
|
||||
|
||||
user
|
||||
Name of the user to run the supervisorctl command
|
||||
|
||||
.. versionadded:: 0.17.0
|
||||
|
||||
conf_file
|
||||
path to supervisorctl config file
|
||||
|
||||
bin_env
|
||||
path to supervisorctl bin or path to virtualenv with supervisor installed
|
||||
|
||||
'''
|
||||
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
|
||||
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Please remove \'runas\' support at this stage. \'user\' support was '
|
||||
'added in 0.17.0',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
if __opts__['test']:
|
||||
ret['result'] = None
|
||||
ret['comment'] = (
|
||||
@ -177,7 +252,7 @@ def dead(name,
|
||||
log.debug(comment)
|
||||
current_status = __salt__['supervisord.status'](
|
||||
name=name,
|
||||
user=runas,
|
||||
user=user,
|
||||
conf_file=conf_file,
|
||||
bin_env=bin_env
|
||||
)
|
||||
@ -186,7 +261,7 @@ def dead(name,
|
||||
else:
|
||||
result = {name: __salt__['supervisord.stop'](
|
||||
name,
|
||||
user=runas,
|
||||
user=user,
|
||||
conf_file=conf_file,
|
||||
bin_env=bin_env
|
||||
)}
|
||||
@ -196,10 +271,19 @@ def dead(name,
|
||||
|
||||
|
||||
def mod_watch(name,
|
||||
restart=False,
|
||||
restart=True,
|
||||
update=False,
|
||||
user=None,
|
||||
runas=None,
|
||||
conf_file=None,
|
||||
bin_env=None):
|
||||
# Always restart on watch
|
||||
return running(name, True, update, runas, conf_file, bin_env)
|
||||
return running(
|
||||
name,
|
||||
restart=restart,
|
||||
update=update,
|
||||
user=user,
|
||||
runas=runas,
|
||||
conf_file=conf_file,
|
||||
bin_env=bin_env
|
||||
)
|
||||
|
@ -29,6 +29,7 @@ def managed(name,
|
||||
never_download=None,
|
||||
prompt=None,
|
||||
__env__='base',
|
||||
user=None,
|
||||
runas=None,
|
||||
no_chown=False,
|
||||
cwd=None,
|
||||
@ -62,6 +63,30 @@ def managed(name,
|
||||
ret['comment'] = 'Virtualenv was not detected on this system'
|
||||
return ret
|
||||
|
||||
salt.utils.warn_until(
|
||||
(0, 18),
|
||||
'Let\'s support \'runas\' until salt 0.19.0 is out, after which '
|
||||
'it will stop being supported',
|
||||
_dont_call_warnings=True
|
||||
)
|
||||
if runas:
|
||||
# Warn users about the deprecation
|
||||
ret.setdefault('warnings', []).append(
|
||||
'The \'runas\' argument is being deprecated in favor or \'user\', '
|
||||
'please update your state files.'
|
||||
)
|
||||
if user is not None and runas is not None:
|
||||
# user wins over runas but let warn about the deprecation.
|
||||
ret.setdefault('warnings', []).append(
|
||||
'Passed both the \'runas\' and \'user\' arguments. Please don\'t. '
|
||||
'\'runas\' is being ignored in favor of \'user\'.'
|
||||
)
|
||||
runas = None
|
||||
elif runas is not None:
|
||||
# Support old runas usage
|
||||
user = runas
|
||||
runas = None
|
||||
|
||||
if salt.utils.is_windows():
|
||||
venv_py = os.path.join(name, 'Scripts', 'python.exe')
|
||||
else:
|
||||
@ -125,7 +150,7 @@ def managed(name,
|
||||
extra_search_dir=extra_search_dir,
|
||||
never_download=never_download,
|
||||
prompt=prompt,
|
||||
runas=runas
|
||||
runas=user
|
||||
)
|
||||
|
||||
ret['result'] = _ret['retcode'] == 0
|
||||
@ -144,7 +169,7 @@ def managed(name,
|
||||
if requirements:
|
||||
before = set(__salt__['pip.freeze'](bin_env=name))
|
||||
_ret = __salt__['pip.install'](
|
||||
requirements=requirements, bin_env=name, runas=runas, cwd=cwd,
|
||||
requirements=requirements, bin_env=name, runas=user, cwd=cwd,
|
||||
index_url=index_url,
|
||||
extra_index_url=extra_index_url,
|
||||
no_chown=no_chown,
|
||||
|
Loading…
Reference in New Issue
Block a user