mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge branch '2014.7' into develop
Conflicts: salt/states/file.py
This commit is contained in:
commit
b83ab14c01
@ -10,6 +10,11 @@ from __future__ import absolute_import
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
|
try:
|
||||||
|
from shlex import quote as _cmd_quote # pylint: disable=E0611
|
||||||
|
except ImportError:
|
||||||
|
from pipes import quote as _cmd_quote
|
||||||
|
from shlex import split as _cmd_split
|
||||||
|
|
||||||
# Set up logger
|
# Set up logger
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -31,15 +36,21 @@ def _rbenv_exec(command, args='', env=None, runas=None, ret=None):
|
|||||||
binary = _rbenv_bin(runas)
|
binary = _rbenv_bin(runas)
|
||||||
path = _rbenv_path(runas)
|
path = _rbenv_path(runas)
|
||||||
|
|
||||||
if env:
|
environ = {}
|
||||||
env = ' {0}'.format(env)
|
for token in _cmd_split(env):
|
||||||
env = env or ''
|
try:
|
||||||
|
var, val = token.split('=')
|
||||||
|
environ[var] = val
|
||||||
|
except Exception:
|
||||||
|
pass # if token != var=val, it's not a proper env anyway
|
||||||
|
environ['RBENV_ROOT'] = path
|
||||||
|
|
||||||
binary = 'env RBENV_ROOT={0}{1} {2}'.format(path, env, binary)
|
args = ' '.join([_cmd_quote(arg) for arg in _cmd_split(args)])
|
||||||
|
|
||||||
result = __salt__['cmd.run_all'](
|
result = __salt__['cmd.run_all'](
|
||||||
'{0} {1} {2}'.format(binary, command, args),
|
'{0} {1} {2}'.format(binary, _cmd_quote(command), args),
|
||||||
runas=runas
|
runas=runas,
|
||||||
|
env=environ
|
||||||
)
|
)
|
||||||
|
|
||||||
if isinstance(ret, dict):
|
if isinstance(ret, dict):
|
||||||
@ -62,7 +73,8 @@ def _rbenv_path(runas=None):
|
|||||||
if runas in (None, 'root'):
|
if runas in (None, 'root'):
|
||||||
path = __salt__['config.option']('rbenv.root') or '/usr/local/rbenv'
|
path = __salt__['config.option']('rbenv.root') or '/usr/local/rbenv'
|
||||||
else:
|
else:
|
||||||
path = __salt__['config.option']('rbenv.root') or '~{0}/.rbenv'.format(runas)
|
path = _cmd_quote(__salt__['config.option']('rbenv.root')
|
||||||
|
or '~{0}/.rbenv'.format(runas))
|
||||||
|
|
||||||
return os.path.expanduser(path)
|
return os.path.expanduser(path)
|
||||||
|
|
||||||
@ -72,7 +84,8 @@ def _install_rbenv(path, runas=None):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
return 0 == __salt__['cmd.retcode'](
|
return 0 == __salt__['cmd.retcode'](
|
||||||
'git clone https://github.com/sstephenson/rbenv.git {0}'.format(path), runas=runas)
|
'git clone https://github.com/sstephenson/rbenv.git {0}'
|
||||||
|
.format(_cmd_quote(path)), runas=runas)
|
||||||
|
|
||||||
|
|
||||||
def _install_ruby_build(path, runas=None):
|
def _install_ruby_build(path, runas=None):
|
||||||
@ -81,7 +94,8 @@ def _install_ruby_build(path, runas=None):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
return 0 == __salt__['cmd.retcode'](
|
return 0 == __salt__['cmd.retcode'](
|
||||||
'git clone https://github.com/sstephenson/ruby-build.git {0}'.format(path), runas=runas)
|
'git clone https://github.com/sstephenson/ruby-build.git {0}'
|
||||||
|
.format(_cmd_quote(path)), runas=runas)
|
||||||
|
|
||||||
|
|
||||||
def _update_rbenv(path, runas=None):
|
def _update_rbenv(path, runas=None):
|
||||||
@ -89,7 +103,7 @@ def _update_rbenv(path, runas=None):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
return 0 == __salt__['cmd.retcode'](
|
return 0 == __salt__['cmd.retcode'](
|
||||||
'cd {0} && git pull'.format(path), runas=runas)
|
'git pull', runas=runas, cwd=path)
|
||||||
|
|
||||||
|
|
||||||
def _update_ruby_build(path, runas=None):
|
def _update_ruby_build(path, runas=None):
|
||||||
@ -98,7 +112,7 @@ def _update_ruby_build(path, runas=None):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
return 0 == __salt__['cmd.retcode'](
|
return 0 == __salt__['cmd.retcode'](
|
||||||
'cd {0} && git pull'.format(path), runas=runas)
|
'git pull', runas=runas, cwd=path)
|
||||||
|
|
||||||
|
|
||||||
def install(runas=None, path=None):
|
def install(runas=None, path=None):
|
||||||
@ -299,9 +313,12 @@ def do(cmdline=None, runas=None):
|
|||||||
salt '*' rbenv.do 'gem list bundler' deploy
|
salt '*' rbenv.do 'gem list bundler' deploy
|
||||||
'''
|
'''
|
||||||
path = _rbenv_path(runas)
|
path = _rbenv_path(runas)
|
||||||
|
environ = {'PATH': '{0}/shims:{1}'.format(path, os.environ['PATH'])}
|
||||||
|
cmdline = ' '.join([_cmd_quote(cmd) for cmd in _cmd_split(cmdline)])
|
||||||
result = __salt__['cmd.run_all'](
|
result = __salt__['cmd.run_all'](
|
||||||
'env PATH={0}/shims:$PATH {1}'.format(path, cmdline),
|
cmdline,
|
||||||
runas=runas
|
runas=runas,
|
||||||
|
env=environ
|
||||||
)
|
)
|
||||||
|
|
||||||
if result['retcode'] == 0:
|
if result['retcode'] == 0:
|
||||||
|
@ -15,7 +15,7 @@ import logging
|
|||||||
from salt.ext.six import string_types
|
from salt.ext.six import string_types
|
||||||
|
|
||||||
# Import Salt libs
|
# Import Salt libs
|
||||||
from salt.utils.odict import _OrderedDict
|
from salt.utils.odict import OrderedDict as _OrderedDict
|
||||||
import salt.client
|
import salt.client
|
||||||
import salt.utils.virt
|
import salt.utils.virt
|
||||||
import salt.utils.cloud
|
import salt.utils.cloud
|
||||||
|
@ -1235,6 +1235,9 @@ def managed(name,
|
|||||||
run.
|
run.
|
||||||
'''
|
'''
|
||||||
name = os.path.expanduser(name)
|
name = os.path.expanduser(name)
|
||||||
|
# contents must be a string
|
||||||
|
if contents:
|
||||||
|
contents = str(contents)
|
||||||
|
|
||||||
# Make sure that leading zeros stripped by YAML loader are added back
|
# Make sure that leading zeros stripped by YAML loader are added back
|
||||||
mode = __salt__['config.manage_mode'](mode)
|
mode = __salt__['config.manage_mode'](mode)
|
||||||
|
@ -117,7 +117,7 @@ def delete_vm(options):
|
|||||||
proc.communicate()
|
proc.communicate()
|
||||||
|
|
||||||
|
|
||||||
def echo_parseable_environment(options):
|
def echo_parseable_environment(options, parser):
|
||||||
'''
|
'''
|
||||||
Echo NAME=VAL parseable output
|
Echo NAME=VAL parseable output
|
||||||
'''
|
'''
|
||||||
@ -959,7 +959,7 @@ def parse():
|
|||||||
parser.exit('--provider or --pull-request is required')
|
parser.exit('--provider or --pull-request is required')
|
||||||
|
|
||||||
if options.echo_parseable_environment:
|
if options.echo_parseable_environment:
|
||||||
echo_parseable_environment(options)
|
echo_parseable_environment(options, parser)
|
||||||
parser.exit(0)
|
parser.exit(0)
|
||||||
|
|
||||||
if not options.test_git_commit and not options.pull_request:
|
if not options.test_git_commit and not options.pull_request:
|
||||||
|
Loading…
Reference in New Issue
Block a user