You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When attempting to run an Ansible playbook defined in the Ansible Provisioner block, I receive the error: "winrm or requests is not installed: No module named 'winrm'"
The specific issue appears to be that the 'ansible python module path' is located in the pipx env that Ansible is automatically installed to, but pywinrm wasn't installed along with it: azure-arm.image: ansible python module location = /opt/pipx/venvs/ansible-core/lib/python3.8/site-packages/ansible
Reproduction Steps
This deployment is taking place in an Azure pipeline with an Ubuntu container, deploying Windows 10 hosts to Azure. The playbook is intended to target those hosts.
Run a Packer build (note: packer init was run first) with the following configuration and Ansible provisioner using WinRM.
I can think of a couple of complicated workarounds for this, but dealing with wrappers and custom virtual environments doesn't seem like a good solution when the fundamental issue appears to be a missing dependency in the ansible provisioner package itself. The official docs for this provisioner certainly make it seem like this is possible out of the box, but maybe they're expecting a Windows to Windows deployment rather than Unix to Windows...
Additionally, I've been unable to find any reference to the /opt/pipx/venv path in any of the related repos or issues. I'm not sure if this is a new feature or potentially an issue with Azure Pipelines. If the module was using the standard system Python module path, I could simply install pywinrm to the Ubuntu container, but in its current state the virtual environment precludes that.
Okay, technically the following workaround fixes the issues, but it would still be nice to get a 'yes' or 'no' as to whether this is usually necessary, and if so, please add a clearer explanation / use-case to the docs:
Added to Azure DevOps pipeline:
- script: |
chmod +x ./packer/ansible.sh && \
python3 -m venv /tmp/venv && \
source /tmp/venv/bin/activate && \
python3 -m pip install wheel pywinrm ansible && \
deactivate
displayName: 'Add exec bit to ansible.sh and install Ansible and pywinrm to venv'
Overview of the Issue
When attempting to run an Ansible playbook defined in the Ansible Provisioner block, I receive the error:
"winrm or requests is not installed: No module named 'winrm'"
The specific issue appears to be that the 'ansible python module path' is located in the pipx env that Ansible is automatically installed to, but pywinrm wasn't installed along with it:
azure-arm.image: ansible python module location = /opt/pipx/venvs/ansible-core/lib/python3.8/site-packages/ansible
Reproduction Steps
This deployment is taking place in an Azure pipeline with an Ubuntu container, deploying Windows 10 hosts to Azure. The playbook is intended to target those hosts.
Run a Packer build (note:
packer init
was run first) with the following configuration and Ansible provisioner using WinRM.Packer version
Packer Version: 1.7.4 x64
Simplified Packer Buildfile
image_build.pkr.hcl:
image_build.pkrvars.hcl:
Ansible Playbook
playbook-windows.yml:
Operating system and Environment details
OS: ubuntu-20.04 LTS x64
Python Version: 3.8.10
Ansible Version: ansible-core 2.11.3 (installed via packer init)
Log Fragments and crash.log files
The text was updated successfully, but these errors were encountered: