My ansible inventory has netbox_url and netbox_token under [all:vars]
When I do a curl request too the api with whose credential I get a 200 response
In my ansible playbook I have this task
- name: Get device details from NetBox via API
ansible.builtin.set_fact:
nb_device_name: "{{ item.value.name }}"
nb_device_id: "{{ item.value.id }}"
loop: "{{ lookup('netbox.netbox.nb_lookup', 'devices',
api_endpoint=netbox_url,
token=netbox_token,
api_filter='primary_ip4='~ ansible_host ~ '/' ~ mask) }}"
loop_control:
label: "{{ item.value.name }}
my log is returning 403, I am not sure what I am doing wrong?
FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'netbox.netbox.nb_lookup'. Error was a <class 'pynetbox.core.query.RequestError'>, original message: The request failed with code 403 Forbidden: {'detail': 'Authentication credentials were not provided.'}. The request failed with code 403 Forbidden: {'detail': 'Authentication credentials were not provided.'}"}