diff options
author | Matt Clay <matt@mystile.com> | 2023-10-31 01:25:53 +0100 |
---|---|---|
committer | Matt Clay <matt@mystile.com> | 2023-10-31 17:14:51 +0100 |
commit | bea459654a19f3a11ed13be5a580a43b07b05e43 (patch) | |
tree | b76d2e454986af5ec8f928473aa7792ae0e7fb3c | |
parent | pip - Add break_system_packages option (#82097) (diff) | |
download | ansible-bea459654a19f3a11ed13be5a580a43b07b05e43.tar.xz ansible-bea459654a19f3a11ed13be5a580a43b07b05e43.zip |
pip - Add module in venv example
-rw-r--r-- | lib/ansible/modules/pip.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/ansible/modules/pip.py b/lib/ansible/modules/pip.py index df84fbd935..9fc89499a5 100644 --- a/lib/ansible/modules/pip.py +++ b/lib/ansible/modules/pip.py @@ -242,6 +242,26 @@ EXAMPLES = ''' name: bottle umask: "0022" become: True + +- name: Run a module inside a virtual environment + block: + - name: Ensure the virtual environment exists + pip: + name: psutil + virtualenv: "{{ venv_dir }}" + # On Debian-based systems the correct python*-venv package must be installed to use the `venv` module. + virtualenv_command: "{{ ansible_python_interpreter }} -m venv" + + - name: Run a module inside the virtual environment + wait_for: + port: 22 + vars: + # Alternatively, use a block to affect multiple tasks, or use set_fact to affect the remainder of the playbook. + ansible_python_interpreter: "{{ venv_python }}" + + vars: + venv_dir: /tmp/pick-a-better-venv-path + venv_python: "{{ venv_dir }}/bin/python" ''' RETURN = ''' |