From 204e185e7d38a79bebb8ecb5a2aa875d30605ef5 Mon Sep 17 00:00:00 2001 From: Vadim Shulkin Date: Mon, 3 Mar 2025 22:18:31 -0500 Subject: [PATCH] Added --- run_python_script.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/run_python_script.yml b/run_python_script.yml index 00b69e9..576ffa3 100644 --- a/run_python_script.yml +++ b/run_python_script.yml @@ -7,9 +7,24 @@ src: ./requirements.txt # Ensure this exists locally dest: /tmp/requirements.txt - - name: Install dependencies from copied requirements.txt + - name: Create Python Virtual Environment + command: python3 -m venv /tmp/ansible_venv + args: + creates: /tmp/ansible_venv/bin/activate + + - name: Install required Python packages pip: requirements: /tmp/requirements.txt + virtualenv: /tmp/ansible_venv + virtualenv_command: "python3 -m venv" + + - name: Check installed Python packages + command: bash -c "source /tmp/ansible_venv/bin/activate && pip list" + register: installed_packages + + - name: Show installed packages + debug: + msg: "{{ installed_packages.stdout }}" - name: Run the Python script command: python3 scripts/my_script.py