--- - name: Ensure Python is installed win_chocolatey: name: python state: present - name: Purge venv if asked when: purge_venv | bool and not refresh_api | bool block: - name: Remove service ansible.windows.win_service: name: "{{ disk_service_name }}" state: absent - name: purge folder ansible.windows.win_file: path: "{{ python_venv }}" state: absent - name: Create venv folder ansible.windows.win_file: path: "{{ python_venv }}" state: directory - name: Copy requirements.txt ansible.windows.win_copy: src: requirements.txt dest: "{{ python_venv }}\\requirements.txt" - name: Create virtual environment win_shell: "python -m venv {{ python_venv }}" - name: Upgrade pip in the virtual environment win_shell: "{{ python_venv_bin }} -m pip install --upgrade pip" args: chdir: "{{ python_venv }}" - name: Install Python dependencies from requirements.txt win_shell: "{{ python_venv_bin }} -m pip install -r {{ python_venv }}\\requirements.txt" args: chdir: "{{ python_venv }}" ...