Replies: 1 comment
-
I made several attempts to resolve the issue, including the following steps: Resizing the Netbox VM. You can also find the code on GitHub at the following link: https://github.com/ypant/netbox/blob/main/netbox_import_csv.py |
Beta Was this translation helpful? Give feedback.
-
Ansible NetBox Collection version
v3.13.0
Ansible version
NetBox version
v3.5.6
Python version
3.10
Steps to Reproduce
Here is the ansible script I am trying to run. Note: I have attempted to execute the script using python 3.8, 3.9, 3.10 and 3.11 with similar (inconsistent) behavior:
`---
hosts: netbox
gather_facts: False
connection: local
vars:
netbox_url: "http://192.168.56.5:80"
netbox_token: "5929xxxx59"
ansible_python_interpreter: /usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/bin/python3
prefixes:
- Prefix: 10.102.10.0/24
Tenant: vnet-arc-fgt-dev-eu1
tasks:
name: Create tenant within NetBox with only required information
netbox.netbox.netbox_tenant:
netbox_url: "{{ netbox_url }}"
netbox_token: "{{ netbox_token }}"
data:
name: "{{ item.Tenant }}"
state: present
validate_certs: false
with_items: "{{ prefixes }}"
name: Create prefix within NetBox with only required information
netbox.netbox.netbox_prefix:
netbox_url: "{{ netbox_url }}"
netbox_token: "{{ netbox_token }}"
data:
prefix: "{{ item.Prefix }}"
tenant: "{{ item.Tenant }}"
state: present
with_items: "{{ prefixes }}"`
However I am getting inconsistent results: around 50% of the time, I get an error saying that the connection fails while at others the configuration is applied successfully:
successful response:
`ansible-playbook -i inventory/vagrant-devtest.ini playbooks/ipam.yml
PLAY [netbox] ************************************************************************************************************************************************
TASK [Create tenant within NetBox with only required information] ********************************************************************************************
ok: [vagrant_netbox_server] => (item={'Prefix': '10.102.10.0/24', 'Tenant': 'vnet-arc-fgt-dev-eu1'})
TASK [Create prefix within NetBox with only required information] ********************************************************************************************
ok: [vagrant_netbox_server] => (item={'Prefix': '10.102.10.0/24', 'Tenant': 'vnet-arc-fgt-dev-eu1'})
PLAY RECAP ***************************************************************************************************************************************************
vagrant_netbox_server : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
`
Unsuccessful Response:
`
ansible-playbook -vvv -i inventory/vagrant-devtest.ini playbooks/ipam.yml
ansible-playbook [core 2.15.1]
config file = /Users/ypant/work/gcom/az-dev/devtest-ansible/ansible.cfg
configured module search path = ['/Users/ypant/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/ansible
ansible collection location = /Users/ypant/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/bin/ansible-playbook
python version = 3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 18:10:28) [Clang 15.0.7 ] (/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/bin/python)
jinja version = 3.1.2
libyaml = True
Using /Users/ypant/work/gcom/az-dev/devtest-ansible/ansible.cfg as config file
host_list declined parsing /Users/ypant/work/gcom/az-dev/devtest-ansible/inventory/vagrant-devtest.ini as it did not pass its verify_file() method
script declined parsing /Users/ypant/work/gcom/az-dev/devtest-ansible/inventory/vagrant-devtest.ini as it did not pass its verify_file() method
auto declined parsing /Users/ypant/work/gcom/az-dev/devtest-ansible/inventory/vagrant-devtest.ini as it did not pass its verify_file() method
yaml declined parsing /Users/ypant/work/gcom/az-dev/devtest-ansible/inventory/vagrant-devtest.ini as it did not pass its verify_file() method
Parsed /Users/ypant/work/gcom/az-dev/devtest-ansible/inventory/vagrant-devtest.ini inventory source with ini plugin
redirecting (type: callback) ansible.builtin.yaml to community.general.yaml
redirecting (type: callback) ansible.builtin.yaml to community.general.yaml
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
PLAYBOOK: ipam.yml *************************************************************************************************************************************************************
1 plays in playbooks/ipam.yml
PLAY [netbox] ******************************************************************************************************************************************************************
TASK [Create tenant within NetBox with only required information] **************************************************************************************************************
task path: /Users/ypant/work/gcom/az-dev/devtest-ansible/playbooks/ipam.yml:16
<192.168.56.5> ESTABLISH LOCAL CONNECTION FOR USER: ypant
<192.168.56.5> EXEC /bin/sh -c 'echo ~ypant && sleep 0'
<192.168.56.5> EXEC /bin/sh -c '( umask 77 && mkdir -p "
echo /Users/ypant/.ansible/tmp
"&& mkdir "echo /Users/ypant/.ansible/tmp/ansible-tmp-1689096350.351926-10450-86700633607771
" && echo ansible-tmp-1689096350.351926-10450-86700633607771="echo /Users/ypant/.ansible/tmp/ansible-tmp-1689096350.351926-10450-86700633607771
" ) && sleep 0'Using module file /Users/ypant/.ansible/collections/ansible_collections/netbox/netbox/plugins/modules/netbox_tenant.py
<192.168.56.5> PUT /Users/ypant/.ansible/tmp/ansible-local-10447mgwaldhj/tmpz9hdo77j TO /Users/ypant/.ansible/tmp/ansible-tmp-1689096350.351926-10450-86700633607771/AnsiballZ_netbox_tenant.py
<192.168.56.5> EXEC /bin/sh -c 'chmod u+x /Users/ypant/.ansible/tmp/ansible-tmp-1689096350.351926-10450-86700633607771/ /Users/ypant/.ansible/tmp/ansible-tmp-1689096350.351926-10450-86700633607771/AnsiballZ_netbox_tenant.py && sleep 0'
<192.168.56.5> EXEC /bin/sh -c '/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/bin/python3 /Users/ypant/.ansible/tmp/ansible-tmp-1689096350.351926-10450-86700633607771/AnsiballZ_netbox_tenant.py && sleep 0'
<192.168.56.5> EXEC /bin/sh -c 'rm -f -r /Users/ypant/.ansible/tmp/ansible-tmp-1689096350.351926-10450-86700633607771/ > /dev/null 2>&1 && sleep 0'
ok: [vagrant_netbox_server] => (item={'Prefix': '10.102.10.0/24', 'Tenant': 'vnet-arc-fgt-dev-eu1'}) => changed=false
ansible_loop_var: item
invocation:
module_args:
cert: null
data:
comments: null
custom_fields: null
description: null
name: vnet-arc-fgt-dev-eu1
slug: null
tags: null
tenant_group: null
netbox_token: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
netbox_url: http://192.168.56.5:80
query_params: null
state: present
validate_certs: false
item:
Prefix: 10.102.10.0/24
Tenant: vnet-arc-fgt-dev-eu1
msg: tenant vnet-arc-fgt-dev-eu1 already exists
tenant:
circuit_count: 0
cluster_count: 0
comments: ''
created: '2023-07-10T14:49:19.470354Z'
custom_fields: {}
description: ''
device_count: 0
display: vnet-arc-fgt-dev-eu1
group: null
id: 1
ipaddress_count: 0
last_updated: '2023-07-10T14:49:19.470380Z'
name: vnet-arc-fgt-dev-eu1
prefix_count: 1
rack_count: 0
site_count: 0
slug: vnet-arc-fgt-dev-eu1
tags: []
url: http://192.168.56.5/api/tenancy/tenants/1/
virtualmachine_count: 0
vlan_count: 0
vrf_count: 0
TASK [Create prefix within NetBox with only required information] **************************************************************************************************************
task path: /Users/ypant/work/gcom/az-dev/devtest-ansible/playbooks/ipam.yml:26
<192.168.56.5> ESTABLISH LOCAL CONNECTION FOR USER: ypant
<192.168.56.5> EXEC /bin/sh -c 'echo ~ypant && sleep 0'
<192.168.56.5> EXEC /bin/sh -c '( umask 77 && mkdir -p "
echo /Users/ypant/.ansible/tmp
"&& mkdir "echo /Users/ypant/.ansible/tmp/ansible-tmp-1689096351.386289-10470-259184315756197
" && echo ansible-tmp-1689096351.386289-10470-259184315756197="echo /Users/ypant/.ansible/tmp/ansible-tmp-1689096351.386289-10470-259184315756197
" ) && sleep 0'Using module file /Users/ypant/.ansible/collections/ansible_collections/netbox/netbox/plugins/modules/netbox_prefix.py
<192.168.56.5> PUT /Users/ypant/.ansible/tmp/ansible-local-10447mgwaldhj/tmpxkjnxavx TO /Users/ypant/.ansible/tmp/ansible-tmp-1689096351.386289-10470-259184315756197/AnsiballZ_netbox_prefix.py
<192.168.56.5> EXEC /bin/sh -c 'chmod u+x /Users/ypant/.ansible/tmp/ansible-tmp-1689096351.386289-10470-259184315756197/ /Users/ypant/.ansible/tmp/ansible-tmp-1689096351.386289-10470-259184315756197/AnsiballZ_netbox_prefix.py && sleep 0'
<192.168.56.5> EXEC /bin/sh -c '/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/bin/python3 /Users/ypant/.ansible/tmp/ansible-tmp-1689096351.386289-10470-259184315756197/AnsiballZ_netbox_prefix.py && sleep 0'
<192.168.56.5> EXEC /bin/sh -c 'rm -f -r /Users/ypant/.ansible/tmp/ansible-tmp-1689096351.386289-10470-259184315756197/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/urllib3/connectionpool.py", line 790, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/urllib3/connectionpool.py", line 536, in _make_request
response = conn.getresponse()
^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/urllib3/connection.py", line 454, in getresponse
httplib_response = super().getresponse()
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/http/client.py", line 1378, in getresponse
response.begin()
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/http/client.py", line 318, in begin
version, status, reason = self._read_status()
^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/http/client.py", line 287, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/urllib3/connectionpool.py", line 844, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/urllib3/util/retry.py", line 470, in increment
raise reraise(type(error), error, _stacktrace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/urllib3/util/util.py", line 38, in reraise
raise value.with_traceback(tb)
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/urllib3/connectionpool.py", line 790, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/urllib3/connectionpool.py", line 536, in _make_request
response = conn.getresponse()
^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/urllib3/connection.py", line 454, in getresponse
httplib_response = super().getresponse()
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/http/client.py", line 1378, in getresponse
response.begin()
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/http/client.py", line 318, in begin
version, status, reason = self._read_status()
^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/http/client.py", line 287, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/ypant/.ansible/tmp/ansible-tmp-1689096351.386289-10470-259184315756197/AnsiballZ_netbox_prefix.py", line 107, in
_ansiballz_main()
File "/Users/ypant/.ansible/tmp/ansible-tmp-1689096351.386289-10470-259184315756197/AnsiballZ_netbox_prefix.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/Users/ypant/.ansible/tmp/ansible-tmp-1689096351.386289-10470-259184315756197/AnsiballZ_netbox_prefix.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible_collections.netbox.netbox.plugins.modules.netbox_prefix', init_globals=dict(_module_fqn='ansible_collections.netbox.netbox.plugins.modules.netbox_prefix', _modlib_path=modlib_path),
File "", line 226, in run_module
File "", line 98, in _run_module_code
File "", line 88, in _run_code
File "/var/folders/k8/cnw1b0ls2f90q8dwkyz720200000gn/T/ansible_netbox.netbox.netbox_prefix_payload_hdayngnd/ansible_netbox.netbox.netbox_prefix_payload.zip/ansible_collections/netbox/netbox/plugins/modules/netbox_prefix.py", line 288, in
File "/var/folders/k8/cnw1b0ls2f90q8dwkyz720200000gn/T/ansible_netbox.netbox.netbox_prefix_payload_hdayngnd/ansible_netbox.netbox.netbox_prefix_payload.zip/ansible_collections/netbox/netbox/plugins/modules/netbox_prefix.py", line 283, in main
File "/var/folders/k8/cnw1b0ls2f90q8dwkyz720200000gn/T/ansible_netbox.netbox.netbox_prefix_payload_hdayngnd/ansible_netbox.netbox.netbox_prefix_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_ipam.py", line 41, in init
File "/var/folders/k8/cnw1b0ls2f90q8dwkyz720200000gn/T/ansible_netbox.netbox.netbox_prefix_payload_hdayngnd/ansible_netbox.netbox.netbox_prefix_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py", line 689, in init
File "/var/folders/k8/cnw1b0ls2f90q8dwkyz720200000gn/T/ansible_netbox.netbox.netbox_prefix_payload_hdayngnd/ansible_netbox.netbox.netbox_prefix_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py", line 1203, in _find_ids
File "/var/folders/k8/cnw1b0ls2f90q8dwkyz720200000gn/T/ansible_netbox.netbox.netbox_prefix_payload_hdayngnd/ansible_netbox.netbox.netbox_prefix_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py", line 746, in _nb_endpoint_get
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/pynetbox/core/endpoint.py", line 161, in get
ret = next(resp, None)
^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/pynetbox/core/response.py", line 127, in next
next(self.response), self.endpoint.api, self.endpoint
^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/pynetbox/core/query.py", line 280, in get
req = self._make_call(add_params=add_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/pynetbox/core/query.py", line 230, in _make_call
req = getattr(self.http_session, verb)(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/requests/sessions.py", line 602, in get
return self.request("GET", url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/requests/adapters.py", line 501, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
failed: [vagrant_netbox_server] (item={'Prefix': '10.102.10.0/24', 'Tenant': 'vnet-arc-fgt-dev-eu1'}) => changed=false
ansible_loop_var: item
item:
Prefix: 10.102.10.0/24
Tenant: vnet-arc-fgt-dev-eu1
module_stderr: |-
Traceback (most recent call last):
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/urllib3/connectionpool.py", line 790, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/urllib3/connectionpool.py", line 536, in _make_request
response = conn.getresponse()
^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/site-packages/urllib3/connection.py", line 454, in getresponse
httplib_response = super().getresponse()
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/http/client.py", line 1378, in getresponse
response.begin()
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/http/client.py", line 318, in begin
version, status, reason = self._read_status()
^^^^^^^^^^^^^^^^^^^
File "/usr/local/Caskroom/miniconda/base/envs/ansible_py3.10/lib/python3.11/http/client.py", line 287, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
module_stdout: ''
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
rc: 1
PLAY RECAP *********************************************************************************************************************************************************************
vagrant_netbox_server : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
`
When I enabled logging, there is no log entry corresponding to the request above:
2023-07-11 22:05:12,421 netbox.rqworker WARNING: No queues have been specified. This process will service the following queues by default: high, default, low 2023-07-11 22:13:09,095 django.request WARNING: Not Found: /asdaffa 2023-07-11 22:18:51,628 netbox.rqworker WARNING: No queues have been specified. This process will service the following queues by default: high, default, low 2023-07-11 22:25:43,867 django.request WARNING: Not Found: /ipam/ip-ranges/2/ 2023-07-11 22:27:53,344 django.request WARNING: Not Found: /ipam/ip-ranges10
Expected Behavior
It should not give inconsistent results
Observed Behavior
The result was not consistent. The server reset the connection.
Here is the full packet exchange (tcpdump pcap file) between client and server both consisting of successful and unsuccessful messages. Please rename the file to pcap to view the content.
packet-dump-pcap.zip
Here is the screen shot showing connection reset from the server:
Beta Was this translation helpful? Give feedback.
All reactions