dawidd6 / action-ansible-playbook

:gear: A GitHub Action for running Ansible playbooks
MIT License
306 stars 68 forks source link

Ansible inventory requires additional Python packages #92

Closed kimdre closed 9 months ago

kimdre commented 9 months ago

My dynamic inventory requires the requests python package to load the hosts from an API, however I'm not able to install the package via pip. I guess because the playbook action uses its own virtual env?

- name: Checkout
  uses: actions/checkout@v4

- name: Setup Python
  uses: actions/setup-python@v5
  with:
    python-version: '3.11'
    cache: 'pip'

- name: Install Ansible dependencies
  run: pip install -r requirements.txt

- name: Run playbook
  uses: dawidd6/action-ansible-playbook@v2
  with:
    directory: ./ansible
    playbook: swarm-apply.yaml
    key: ${{secrets.SSH_PRIVATE_KEY}}
    requirements: galaxy-requirements.yaml

I receive this error message telling me that the requests package is still missing, even tho I installed it via pip one step before.

[WARNING]:  * Failed to parse /home/runner/work/myproject/deployment/ansible/inventory/prod.hcloud.yaml with
ansible_collections.hetzner.hcloud.plugins.inventory.hcloud plugin: Failed to import the required Python library (requests) 
on fv-az189-444's Python /opt/pipx/venvs/ansible-core/bin/python. Please read the module documentation
and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, 
please consult the documentation on ansible_python_interpreter
dawidd6 commented 9 months ago

That depends solely on the runner. Action just runs whatever ansible-playbook binary is in PATH.