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)
pull/30241/head
Nicklaus McClendon 7 years ago committed by Toshio Kuratomi
parent 1e2ce4c8ab
commit 6dbc3c63f8

@ -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…
Cancel
Save