netbox-community / ansible_modules

NetBox modules for Ansible using Ansible Collections
GNU General Public License v3.0
330 stars 211 forks source link

[Bug]: No module named 'pynetbox' #1175

Closed GreatSatoshi closed 6 months ago

GreatSatoshi commented 7 months ago

Ansible NetBox Collection version

v3.16.0

Ansible version

  config file = /runner/project/ansible.cfg
  configured module search path = ['/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /runner/requirements_collections:/runner/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.9.18 (main, Jan 24 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3)
  jinja version = 3.1.3
  libyaml = True

NetBox version

v2.7.6

Python version

3.9

Steps to Reproduce

For start, I launch my playbook with the web AWX interface installed with operator on K3S (single node) First step, create a playbook This is my playbook without sensitive information "vm_create-tmp.yml"

---
- name:  Clone a virtual machine from Linux template and customize
  hosts: localhost
  connection: local
  gather_facts: False
  tasks:
    - name: Create virtual machine within NetBox with only required information
      netbox.netbox.netbox_virtual_machine:
        netbox_url: "{{ url }}"
        netbox_token: "{{ token }}"
        data:
          name: "{{ vm_hostname }}"
          virtual_machine_role: "{{ virtual_machine_role }}"
          cluster: "{{ cluster }}"
          vcpus: "vcp_var"
          disk: "{{ disk }}
          memory: "{{ memory:  }}"
          platform: "{{ platform }}"
          comments: "{{ comments }}"
          custom_fields:
            eresp: "{{ eresp_var }}"
            hostname: "{{ vm_hostname }}"
        state: present

There is my file structure I had a git repository in /home/me/.ansible/collections/ansible_collection/ So the AWX project was link to repository, in my ansible_collection we got /home/me/.ansible/collections/ansible_collection/collections/requirments.yml inside my "requirments.yml"

collections:
  - name: netbox.netbox
    version: 3.16.0

when i start my playbook trhougt AWX i got this error

"exception": "Traceback (most recent call last):\n File \"/tmp/ansible_netbox.netbox.netbox_virtual_machine_payload_fl7b5sfw/ansible_netbox.netbox.netbox_virtual_machine_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py\", line 27, in \n import pynetbox\nModuleNotFoundError: No module named 'pynetbox'\n", "msg": "Failed to import the required Python library (pynetbox) on automation-job-415-rmcb9's Python /usr/bin/python3. 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", "invocation": { "module_args": {

I can't install pynetbox manually because I'm on kubernetes and my modifications will be removed when the container is recreated. How come there's a module missing when the project's requirments.txt says

pynetbox packaging pytz

Expected Behavior

When I start my playbook locally, I mean on my localhost after install the netbox : sudo ansible-galaxy collection install netbox.netbox

I got 0 problem the request was sent correctly to my netbox server and I can see on it with all my custom field and when I do pip freeze i got pynetbox==7.3.3 installed

Observed Behavior

Instead i got

"Failed to import the required Python library (pynetbox) on automation-job-415-rmcb9's Python /usr/bin/python3. 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",

sc68cal commented 7 months ago

This is an issue with your AWX operator and kubernetes. Whatever container is being used does not have the dependencies installed.

GreatSatoshi commented 7 months ago

This is an issue with your AWX operator and kubernetes. Whatever container is being used does not have the dependencies installed.

I don't think so cause i don't have any problem with my other collection and rôle but i will reinstall all of my cluster tommorrow

GreatSatoshi commented 6 months ago

It's ok it was a problem with my AWX environment, thank you