Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: pynetbox Module Not Detected for netbox.netbox.lookup Plugin in AWX #1330

Open
Superset1986 opened this issue Oct 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Superset1986
Copy link

Ansible NetBox Collection version

v3.20.0

Ansible version

ansible [core 2.15.12]
config file = None
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/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.9.19 (main, Jun 11 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3)
jinja version = 3.1.4
libyaml = True

NetBox version

v4.0.6

Python version

3.9

Steps to Reproduce

I am encountering an issue with the netbox.netbox.lookup plugin while running playbooks in AWX. The error message indicates that the pynetbox module is not installed, even though pynetbox is installed and visible when running pip list. Interestingly, other NetBox-related modules, such as netbox.netbox.netbox_vm_interface, works without any issues.

I tried logging into the execution environment while the container was running and running python -c "import pynetbox" without errors. I also did a pip list to confirm pynetbox was installed.

First step of my playbook is to install pynetbox into the execution environment:

    - name: pip install pynetbox
      shell: pip install plugins/pynetbox-7.4.0-py3-none-any.whl
      register: raw_output
      delegate_to: localhost
      run_once: true

Playbook task that is failing:

    - name: "Query NetBox for all sites"
      debug:
        msg: >
          "Device {{ item.value.name }} (ID: {{ item.key }}) was
          manufactured by {{ item.value.device_type.manufacturer.name }}"
      loop: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='role=firewall', api_endpoint=netbox_url, token=netbox_token)}}"

Playbook task that is working:

    - name: Create or update VM in Netbox
      netbox.netbox.netbox_vm_interface:
        netbox_token: '{{ NETBOX_TOKEN }}'
        netbox_url: '{{ NETBOX_API }}'
        data:
          virtual_machine: "{{ inventory_hostname }}"
          name: "{{ item[0] }}"
        state: present
        validate_certs: False
      loop: "{{ interfaces_data }}"
      delegate_to: localhost

Expected Behavior

The netbox.netbox.lookup plugin should successfully detect the pynetbox module, and the playbook should execute without errors like the netbox.netbox.netbox_vm_interface module.

Observed Behavior

Task is failing with the following error:
fatal: [localhost]: FAILED! => {"msg": "The pynetbox python module is required"}

@Superset1986 Superset1986 added the bug Something isn't working label Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant