|
|
@ -239,7 +239,7 @@ def main():
|
|
|
|
virtualenv_python=dict(default=None, required=False, type='str'),
|
|
|
|
virtualenv_python=dict(default=None, required=False, type='str'),
|
|
|
|
use_mirrors=dict(default='yes', type='bool'),
|
|
|
|
use_mirrors=dict(default='yes', type='bool'),
|
|
|
|
extra_args=dict(default=None, required=False),
|
|
|
|
extra_args=dict(default=None, required=False),
|
|
|
|
chdir=dict(default=None, required=False),
|
|
|
|
chdir=dict(default=None, required=False, type='path'),
|
|
|
|
executable=dict(default=None, required=False),
|
|
|
|
executable=dict(default=None, required=False),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
required_one_of=[['name', 'requirements']],
|
|
|
|
required_one_of=[['name', 'requirements']],
|
|
|
@ -258,6 +258,10 @@ def main():
|
|
|
|
if state == 'latest' and version is not None:
|
|
|
|
if state == 'latest' and version is not None:
|
|
|
|
module.fail_json(msg='version is incompatible with state=latest')
|
|
|
|
module.fail_json(msg='version is incompatible with state=latest')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if chdir is None:
|
|
|
|
|
|
|
|
# this is done to avoid permissions issues with privilege escalation and virtualenvs
|
|
|
|
|
|
|
|
chdir = tempfile.gettempdir()
|
|
|
|
|
|
|
|
|
|
|
|
err = ''
|
|
|
|
err = ''
|
|
|
|
out = ''
|
|
|
|
out = ''
|
|
|
|
|
|
|
|
|
|
|
@ -285,10 +289,7 @@ def main():
|
|
|
|
cmd += ' -p%s' % virtualenv_python
|
|
|
|
cmd += ' -p%s' % virtualenv_python
|
|
|
|
|
|
|
|
|
|
|
|
cmd = "%s %s" % (cmd, env)
|
|
|
|
cmd = "%s %s" % (cmd, env)
|
|
|
|
this_dir = tempfile.gettempdir()
|
|
|
|
rc, out_venv, err_venv = module.run_command(cmd, cwd=chdir)
|
|
|
|
if chdir:
|
|
|
|
|
|
|
|
this_dir = os.path.join(this_dir, chdir)
|
|
|
|
|
|
|
|
rc, out_venv, err_venv = module.run_command(cmd, cwd=this_dir)
|
|
|
|
|
|
|
|
out += out_venv
|
|
|
|
out += out_venv
|
|
|
|
err += err_venv
|
|
|
|
err += err_venv
|
|
|
|
if rc != 0:
|
|
|
|
if rc != 0:
|
|
|
@ -328,9 +329,6 @@ def main():
|
|
|
|
elif requirements:
|
|
|
|
elif requirements:
|
|
|
|
cmd += ' -r %s' % requirements
|
|
|
|
cmd += ' -r %s' % requirements
|
|
|
|
|
|
|
|
|
|
|
|
this_dir = tempfile.gettempdir()
|
|
|
|
|
|
|
|
if chdir:
|
|
|
|
|
|
|
|
this_dir = os.path.join(this_dir, chdir)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if module.check_mode:
|
|
|
|
if module.check_mode:
|
|
|
|
if extra_args or requirements or state == 'latest' or not name:
|
|
|
|
if extra_args or requirements or state == 'latest' or not name:
|
|
|
@ -340,7 +338,8 @@ def main():
|
|
|
|
module.exit_json(changed=True)
|
|
|
|
module.exit_json(changed=True)
|
|
|
|
|
|
|
|
|
|
|
|
freeze_cmd = '%s freeze' % pip
|
|
|
|
freeze_cmd = '%s freeze' % pip
|
|
|
|
rc, out_pip, err_pip = module.run_command(freeze_cmd, cwd=this_dir)
|
|
|
|
|
|
|
|
|
|
|
|
rc, out_pip, err_pip = module.run_command(freeze_cmd, cwd=chdir)
|
|
|
|
|
|
|
|
|
|
|
|
if rc != 0:
|
|
|
|
if rc != 0:
|
|
|
|
module.exit_json(changed=True)
|
|
|
|
module.exit_json(changed=True)
|
|
|
@ -353,7 +352,7 @@ def main():
|
|
|
|
changed = (state == 'present' and not is_present) or (state == 'absent' and is_present)
|
|
|
|
changed = (state == 'present' and not is_present) or (state == 'absent' and is_present)
|
|
|
|
module.exit_json(changed=changed, cmd=freeze_cmd, stdout=out, stderr=err)
|
|
|
|
module.exit_json(changed=changed, cmd=freeze_cmd, stdout=out, stderr=err)
|
|
|
|
|
|
|
|
|
|
|
|
rc, out_pip, err_pip = module.run_command(cmd, path_prefix=path_prefix, cwd=this_dir)
|
|
|
|
rc, out_pip, err_pip = module.run_command(cmd, path_prefix=path_prefix, cwd=chdir)
|
|
|
|
out += out_pip
|
|
|
|
out += out_pip
|
|
|
|
err += err_pip
|
|
|
|
err += err_pip
|
|
|
|
if rc == 1 and state == 'absent' and \
|
|
|
|
if rc == 1 and state == 'absent' and \
|
|
|
|