Replies: 3 comments 2 replies
-
Is this as simple as netbox_api: https://netbox.url/api
—
Mark Tinberg ***@***.***>
Division of Information Technology-Network Services
University of Wisconsin-Madison
…________________________________
From: Eric ***@***.***>
Sent: Wednesday, October 5, 2022 10:12 AM
To: netbox-community/netbox ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [netbox-community/netbox] Unable to Add IP Address to Interface with Ansible Modules (Discussion #10573)
Greetings:
I am trying to add an IP address to a VM interface using the Netbox Ansible modules, but no matter what I try I always receive a "Failed to establish connection to Netbox API" error.
I have verified:
* the Netbox server is up and I can log in via browser
* I am able to access the API using the token I've created
* the certificate on the Netbox instance is trusted using "openssl s_client -connect netbox.url:443 -showcerts 2>&1 | head" (I have also tried disabling certificate verification entirely)
* the host where the playbook is running can access the Netbox API by running a test query of "curl -X GET -H "Authorization: Token abcd" https://netbox.url/api/ipam/prefixes/ -H "accept: application/json" {"count":0,"next":null,"previous":null,"results":[]}". This test returns results successfully.
Here is the playbook, minus some of the prior operations which return the next available IP from Infoblox and create a host record in Infoblox:
---
- hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Create IP address in netbox and assign to interface
netbox_ip_address:
netbox_url: https://netbox.url
netbox_token: "{{ lookup('community.hashi_vault.hashi_vault', 'secret/kv/automation/data/ansible-netbox-tst-token/:token auth_method=approle') }}"
data:
address: "{{ host.ipv4addrs[0].ipv4addr }}"
vrf: "{{ vlan_from_netbox }}"
dns_name: "{{ host.ipv4addrs[0].host }}"
interface:
name: tst_interface
virtual_machine: interfacetst
Here is the results when running the playbook with -vvvv:
TASK [Create IP address in netbox and assign to interface] *********************
task path: /var/lib/go-agent/pipelines/nios-test/ansible-infoblox-nios-tst-nb.yml:38
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: go
<127.0.0.1> EXEC /bin/sh -c 'echo ~go && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /var/go/.ansible/tmp `"&& mkdir "` echo /var/go/.ansible/tmp/ansible-tmp-1664980412.785029-687657-66584688212957 `" && echo ansible-tmp-1664980412.785029-687657-66584688212957="` echo /var/go/.ansible/tmp/ansible-tmp-1664980412.785029-687657-66584688212957 `" ) && sleep 0'
Using module file /usr/lib/python3.6/site-packages/ansible/modules/net_tools/netbox/netbox_ip_address.py
<127.0.0.1> PUT /var/go/.ansible/tmp/ansible-local-687621r_ztnoir/tmpvb41c0th TO /var/go/.ansible/tmp/ansible-tmp-1664980412.785029-687657-66584688212957/AnsiballZ_netbox_ip_address.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /var/go/.ansible/tmp/ansible-tmp-1664980412.785029-687657-66584688212957/ /var/go/.ansible/tmp/ansible-tmp-1664980412.785029-687657-66584688212957/AnsiballZ_netbox_ip_address.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/libexec/platform-python /var/go/.ansible/tmp/ansible-tmp-1664980412.785029-687657-66584688212957/AnsiballZ_netbox_ip_address.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /var/go/.ansible/tmp/ansible-tmp-1664980412.785029-687657-66584688212957/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
File "/tmp/ansible_netbox_ip_address_payload_evm6hvj1/ansible_netbox_ip_address_payload.zip/ansible/modules/net_tools/netbox/netbox_ip_address.py", line 280, in main
fatal: [localhost]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"data": {
"address": "172.16.134.158",
"dns_name": "interfacetst.netbox.url",
"interface": {
"name": "tst_interface",
"virtual_machine": "interfacetst"
},
"vrf": "VLAN134"
},
"netbox_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"netbox_url": "https://netbox.url",
"state": "present",
}
}
}
MSG:
Failed to establish connection to Netbox API
We are using Netbox v 3.3.4 and I am using pynetbox 6.6.2 with the 3.8.0 version of the Netbox collection installed via ansible-galaxy. The ansible version is 2.9.27 on RHEL 8. The packaging module is also installed via pip as mentioned in the README for ansible <2.10.
Can someone point me to where I'm going wrong? Is it because ansible is stuck at 2.9? It seems like everything should connect without issues to me.
Thanks!
—
Reply to this email directly, view it on GitHub<#10573>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAS7UMYPWKIAFOFKFMS3RN3WBWLFBANCNFSM6AAAAAAQ5VOUP4>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
The initial issue seems to be caused by: However, now that it can connect, it's failing to assign the IP with a different error now: If I run a GET https://netbox.url/api/virtualization/interfaces?id=43 though, it returns the correct interface. I've tried using Is there a different way that interfaces are supposed to be specified for a VM? |
Beta Was this translation helpful? Give feedback.
-
My go-to at that point would be to /usr/sbin/tcpdump and see what the application is actually doing for network traffic, is it trying to connect to the right thing on the right port and is that connection successful or failed. You may need to do that on both ends to ensure what is being sent is the same as what is being received.
—
Mark Tinberg ***@***.***>
Division of Information Technology-Network Services
University of Wisconsin-Madison
…________________________________
From: Eric ***@***.***>
Sent: Wednesday, October 5, 2022 10:44 AM
To: netbox-community/netbox ***@***.***>
Cc: Mark Tinberg ***@***.***>; Comment ***@***.***>
Subject: Re: [netbox-community/netbox] Unable to Add IP Address to Interface with Ansible Modules (Discussion #10573)
I have changed the URL to include /api, but I am still getting the "Failed to establish connection..." error. I wondered about this, but the examples for netbox_ip_address just show the FQDN with no extra path which is why I left it off initially.
Thanks for the suggestion though!
—
Reply to this email directly, view it on GitHub<#10573 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAS7UM3GZBPHJIJGQ63MHELWBWO5RANCNFSM6AAAAAAQ5VOUP4>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Greetings:
I am trying to add an IP address to a VM interface using the Netbox Ansible modules, but no matter what I try I always receive a "Failed to establish connection to Netbox API" error.
I have verified:
Here is the playbook, minus some of the prior operations which return the next available IP from Infoblox and create a host record in Infoblox:
Here is the results when running the playbook with -vvvv:
We are using Netbox v 3.3.4 and I am using pynetbox 6.6.2 with the 3.8.0 version of the Netbox collection installed via ansible-galaxy. The ansible version is 2.9.27 on RHEL 8. The packaging module is also installed via pip as mentioned in the README for ansible <2.10.
Can someone point me to where I'm going wrong? Is it because ansible is stuck at 2.9? It seems like everything should connect without issues to me.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions