Updated pip module to always return changed if venv is created (#24233)
* Updated pip module to always return changed if venv is created Fixes #23204 * Add integration test to pip (see #23204)
This commit is contained in:
parent
1e2ce4c8ab
commit
6dbc3c63f8
2 changed files with 21 additions and 1 deletions
|
@ -425,9 +425,10 @@ def main():
|
||||||
out = ''
|
out = ''
|
||||||
|
|
||||||
env = module.params['virtualenv']
|
env = module.params['virtualenv']
|
||||||
|
venv_created = False
|
||||||
if env:
|
if env:
|
||||||
if not os.path.exists(os.path.join(env, 'bin', 'activate')):
|
if not os.path.exists(os.path.join(env, 'bin', 'activate')):
|
||||||
|
venv_created = True
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
module.exit_json(changed=True)
|
module.exit_json(changed=True)
|
||||||
|
|
||||||
|
@ -566,6 +567,8 @@ def main():
|
||||||
_, out_freeze_after, _ = _get_packages(module, pip, chdir)
|
_, out_freeze_after, _ = _get_packages(module, pip, chdir)
|
||||||
changed = out_freeze_before != out_freeze_after
|
changed = out_freeze_before != out_freeze_after
|
||||||
|
|
||||||
|
changed = changed or venv_created
|
||||||
|
|
||||||
module.exit_json(changed=changed, cmd=cmd, name=name, version=version,
|
module.exit_json(changed=changed, cmd=cmd, name=name, version=version,
|
||||||
state=state, requirements=requirements, virtualenv=env,
|
state=state, requirements=requirements, virtualenv=env,
|
||||||
stdout=out, stderr=err)
|
stdout=out, stderr=err)
|
||||||
|
|
|
@ -166,3 +166,20 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "not q_check_mode.changed"
|
- "not q_check_mode.changed"
|
||||||
|
|
||||||
|
# ansible#23204
|
||||||
|
- name: ensure is a fresh virtualenv
|
||||||
|
file:
|
||||||
|
state: absent
|
||||||
|
name: "{{ output_dir }}/pipenv"
|
||||||
|
|
||||||
|
- name: install pip throught pip into fresh virtualenv
|
||||||
|
pip:
|
||||||
|
name: pip
|
||||||
|
virtualenv: "{{ output_dir }}/pipenv"
|
||||||
|
register: pip_install_venv
|
||||||
|
|
||||||
|
- name: make sure pip in fresh virtualenv report changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "pip_install_venv.changed"
|
||||||
|
|
Loading…
Reference in a new issue