Closed devsjay closed 6 months ago
Hi @devsjay,
you need to enable the setting and remove the leading ;
from the config line you want to change.
I f you want to set port 80 you need to define it like this:
; Requires an NetBox API token with full permissions on all objects except 'auth',
; 'secrets' and 'users'
api_token = *****
; Requires a hostname or IP which points to your NetBox instance
host_fqdn = ******
; Define the port your NetBox instance is listening on. If 'disable_tls' is set to "true"
; this option might be set to 80
port = 80
; Whether TLS encryption is enabled or disabled
;disable_tls = True
; Enforces TLS certificate validation. If this system doesn't trust the NetBox web server
; certificate then this option needs to be changed
;validate_tls_certs = False
; Defines a proxy which will be used to connect to NetBox. Proxy setting needs to include
; the schema. Proxy basic auth example: http://user:pass@10.10.1.10:312/
;proxy = http://example.com:3128/
any setting with a leading ;
will be ignored.
oh my, that is silly, thank you. quick question tho, now that ive done this im getting, i dont see this in the settings file. 2024-02-14 15:18:25,048 - DEBUG: https://netbox.****.nl:443 "GET /api/ HTTP/1.1" 200 585 2024-02-14 15:18:25,048 - INFO: Successfully connected to NetBox 'netbox.**.' 2024-02-14 15:18:25,048 - DEBUG: Detected NetBox API version: None ERROR: Unable to determine NetBox version, HTTP header 'API-Version' missing.
Are you using a proxy?
somehow the HTTP header 'API-Version' is missing from the response. You can run it with -l DEBUG3
and see how the HTTP response looks like.
Here is what i recieve. **** out the correct domain
root@mgt-netbox01:/opt/netbox-sync# python netbox-sync.py -l DEBUG3 -c settings.ini 2024-02-14 16:55:54,292 - INFO: Starting NetBox Sync v1.5.1 (2023-09-25) 2024-02-14 16:55:54,292 - DEBUG: Using config file: /opt/netbox-sync/settings.ini 2024-02-14 16:55:54,292 - DEBUG: Config: common.log_level = INFO 2024-02-14 16:55:54,292 - DEBUG: Config: common.log_to_file = False 2024-02-14 16:55:54,292 - DEBUG: Config: common.log_file = log/netbox_sync.log 2024-02-14 16:55:54,292 - DEBUG: Config: netbox.api_token = 4ca* 2024-02-14 16:55:54,292 - DEBUG: Config: netbox.host_fqdn = netbox.**.nl 2024-02-14 16:55:54,292 - DEBUG: Config: netbox.port = 80 2024-02-14 16:55:54,292 - DEBUG: Config: netbox.disable_tls = True 2024-02-14 16:55:54,292 - DEBUG: Config: netbox.validate_tls_certs = False 2024-02-14 16:55:54,292 - DEBUG: Config: netbox.proxy = None 2024-02-14 16:55:54,292 - DEBUG: Config: netbox.client_cert = None 2024-02-14 16:55:54,292 - DEBUG: Config: netbox.client_cert_key = None 2024-02-14 16:55:54,292 - DEBUG: Config: netbox.prune_enabled = False 2024-02-14 16:55:54,292 - DEBUG: Config: netbox.prune_delay_in_days = 30 2024-02-14 16:55:54,293 - DEBUG: Config: netbox.ignore_unknown_source_object_pruning = False 2024-02-14 16:55:54,293 - DEBUG: Config: netbox.default_netbox_result_limit = 200 2024-02-14 16:55:54,293 - DEBUG: Config: netbox.timeout = 30 2024-02-14 16:55:54,293 - DEBUG: Config: netbox.max_retry_attempts = 4 2024-02-14 16:55:54,293 - DEBUG: Config: netbox.use_caching = True 2024-02-14 16:55:54,293 - DEBUG: Config: netbox.cache_directory_location = cache 2024-02-14 16:55:54,293 - WARNING: Log level is set to DEBUG3, Request logs will only be printed to console 2024-02-14 16:55:54,294 - DEBUG: Created new requests Session for NetBox. /usr/local/lib/python3.10/dist-packages/pip_system_certs/wrapt_requests.py:71: UserWarning: Failed to patch SSL settings for unverified requests (unsupported version of urllib3?) This may lead to errors when urllib3 tries to modify verify_mode. Please report an issue at https://gitlab.com/alelec/pip-system-certs with your python version included in the description
warnings.warn( 2024-02-14 16:55:54,296 - DEBUG: Starting new HTTP connection (1): netbox..nl:80 send: b'GET /api/ HTTP/1.1\r\nHost: netbox..nl\r\nUser-Agent: netbox-sync/1.5.1\r\nAccept-Encoding: gzip, deflate\r\nAccept: /\r\nConnection: keep-alive\r\nAuthorization: Token 4cace4f852325fc26b6f5ac2da984e0e1722853c\r\nContent-Type: application/json\r\n\r\n' reply: 'HTTP/1.1 301 Moved Permanently\r\n' header: Server: nginx/1.18.0 (Ubuntu) header: Date: Wed, 14 Feb 2024 15:55:54 GMT header: Content-Type: text/html header: Content-Length: 178 header: Connection: keep-alive header: Location: https://netbox.****.nl/api/ 2024-02-14 16:55:54,312 - DEBUG: http://netbox.****.nl:80 "GET /api/ HTTP/1.1" 301 178 2024-02-14 16:55:54,313 - DEBUG: Starting new HTTPS connection (1): netbox..nl:443 send: b'GET /api/ HTTP/1.1\r\nHost: netbox..nl\r\nUser-Agent: netbox-sync/1.5.1\r\nAccept-Encoding: gzip, deflate\r\nAccept: /\r\nConnection: keep-alive\r\nAuthorization: Token 4cace4f852325fc26b6f5ac2da984e0e1722853c\r\n\r\n' reply: 'HTTP/1.1 200 OK\r\n' header: Server: nginx/1.18.0 (Ubuntu) header: Date: Wed, 14 Feb 2024 15:55:56 GMT header: Content-Type: application/json header: Content-Length: 585 header: Connection: keep-alive header: Vary: HX-Request, Cookie, origin header: Allow: GET, HEAD, OPTIONS header: X-Request-ID: 65df8457-b561-408d-ab3f-eb3aa08ccab2 header: X-Content-Type-Options: nosniff header: Referrer-Policy: same-origin header: Cross-Origin-Opener-Policy: same-origin header: X-Frame-Options: SAMEORIGIN 2024-02-14 16:55:56,587 - DEBUG: https://netbox.****.nl:443 "GET /api/ HTTP/1.1" 200 585 2024-02-14 16:55:56,587 - INFO: Successfully connected to NetBox 'netbox.****.nl' 2024-02-14 16:55:56,587 - DEBUG: Detected NetBox API version: None ERROR: Unable to determine NetBox version, HTTP header 'API-Version' missing. root@mgt-netbox01:/opt/netbox-sync#
and no, they are on the same network,
Hi,
you should change your NetBox API token '4cace4f852325fc26b6f5ac2da984e0e1722853c
' NOW!
Even though you query port 80, your request gets redirected to header: Location: https://netbox.****.nl/api/
.
And the response header is missing the API-Version
header.
You need to fix your HTTP Server / Proxy setup and then the Sync should work.
thanks, and i will try this. also saw this about the api, but the network is completly internal and unreachable and ip whitelisting was enabled(i tried before without but this did not cause the issu), did revoke this already when i saw it
so im thinking its a problem with the nginx server wich netbox is ran on, i was able to change its behaviour but then i got this:
2024-02-14 18:17:09,054 - DEBUG: Starting new HTTP connection (1): netbox.stepco.nl:80 ERROR: NetBox connection: HTTPConnectionPool(host='netbox.stepco.nl', port=80): Max retries exceeded with url: /api/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f52833c8c70>: Failed to establish a new connection: [Errno 111] Connection refused'))
all i did btw is not have redirect on on nginx
Still an issue on your side, sorry.
Closing due to no response.
Whenever i run command below i get error below, also netbox.port should be 80 netbox.disable_tls has to be true etc, what is wrong and how do i get it to read the ports etc, it does read the hst fqdn
2024-02-14 14:07:01,954 - INFO: Starting NetBox Sync v1.5.1 (2023-09-25) 2024-02-14 14:07:01,955 - DEBUG: Using config file: /opt/netbox-sync/settings.ini 2024-02-14 14:07:01,955 - DEBUG: Config: common.log_level = INFO 2024-02-14 14:07:01,955 - DEBUG: Config: common.log_to_file = False 2024-02-14 14:07:01,955 - DEBUG: Config: common.log_file = log/netbox_sync.log 2024-02-14 14:07:01,955 - DEBUG: Config: netbox.api_token = 2024-02-14 14:07:01,955 - DEBUG: Config: netbox.host_fqdn = 2024-02-14 14:07:01,955 - DEBUG: Config: netbox.port = 443 2024-02-14 14:07:01,955 - DEBUG: Config: netbox.disable_tls = False 2024-02-14 14:07:01,955 - DEBUG: Config: netbox.validate_tls_certs = True 2024-02-14 14:07:01,955 - DEBUG: Config: netbox.proxy = None 2024-02-14 14:07:01,955 - DEBUG: Config: netbox.client_cert = None 2024-02-14 14:07:01,955 - DEBUG: Config: netbox.client_cert_key = None 2024-02-14 14:07:01,955 - DEBUG: Config: netbox.prune_enabled = False 2024-02-14 14:07:01,955 - DEBUG: Config: netbox.prune_delay_in_days = 30 2024-02-14 14:07:01,955 - DEBUG: Config: netbox.ignore_unknown_source_object_pruning = False 2024-02-14 14:07:01,955 - DEBUG: Config: netbox.default_netbox_result_limit = 200 2024-02-14 14:07:01,955 - DEBUG: Config: netbox.timeout = 30 2024-02-14 14:07:01,955 - DEBUG: Config: netbox.max_retry_attempts = 4 2024-02-14 14:07:01,955 - DEBUG: Config: netbox.use_caching = True 2024-02-14 14:07:01,955 - DEBUG: Config: netbox.cache_directory_location = cache 2024-02-14 14:07:01,955 - WARNING: Log level is set to DEBUG3, Request logs will only be printed to console 2024-02-14 14:07:01,957 - DEBUG: Created new requests Session for NetBox. 2024-02-14 14:07:01,958 - DEBUG: Starting new HTTPS connection (1): 10.232.17.82:443 ERROR: NetBox connection: check_hostname requires server_hostname
My Config: (removed sens info)
; Requires an NetBox API token with full permissions on all objects except 'auth', ; 'secrets' and 'users' api_token = *****
; Requires a hostname or IP which points to your NetBox instance host_fqdn = ** ; Define the port your NetBox instance is listening on. If 'disable_tls' is set to "true" ; this option might be set to 80 ;port = 80
; Whether TLS encryption is enabled or disabled ;disable_tls = True
; Enforces TLS certificate validation. If this system doesn't trust the NetBox web server ; certificate then this option needs to be changed ;validate_tls_certs = False
; Defines a proxy which will be used to connect to NetBox. Proxy setting needs to include ; the schema. Proxy basic auth example: http://user:pass@10.10.1.10:312 ;proxy = http://example.com:3128
command i run: python netbox-sync.py -l DEBUG3 -c settings.ini