infobloxopen / infoblox-ansible

Ansible modules for interfacing to Infoblox systems
GNU General Public License v3.0
55 stars 64 forks source link

INFOBLOX_HTTP_REQUEST_TIMEOUT cannot be an environmental variable #185

Open mrfito opened 1 year ago

mrfito commented 1 year ago

I am trying to use the inventory plugin connected to our infoblox device. I issue this command $ ansible-inventory --list -i infoblox.yaml and I expect to get a list of all the hosts in my infoblox device but I guess this instead [WARNING]: * Failed to parse /home/infoblox.yaml with auto plugin: Infoblox HTTP request failed with: HTTPSConnectionPool(host='myhost.mydomain.com', port=443): Max retries exceeded with url: /wapi/v2.1/record%3Ahost?_return_fields=name%2Cview%2Cextattrs%2Cipv4addrs&_max_results=1000 (Caused by ReadTimeoutError("HTTPSConnectionPool(host='myhost.mydomain.com', port=443): Read timed out. (read timeout=10)",)) [WARNING]: * Failed to parse /home/infoblox.yaml with yaml plugin: Plugin configuration YAML file, not YAML inventory [WARNING]: * Failed to parse /home/infoblox.yaml with ini plugin: Invalid host pattern 'plugin:' supplied, ending in ':' is not allowed, this character is reserved to provide a port. [WARNING]: Unable to parse /home/infoblox.yaml as an inventory source [WARNING]: No inventory was parsed, only implicit localhost is available { "_meta": { "hostvars": {} }, "all": { "children": [ "ungrouped" ] } }

This error tells me that the infoblox device doesn't answer fast enough. Looking at the repo I find the file plugins/module_utils/api.py 'http_request_timeout': dict(type='int', default=10, fallback=(env_fallback, ['INFOBLOX_HTTP_REQUEST_TIMEOUT'])),

So then I tried to set the environment variable $ export INFOBLOX_HTTP_REQUEST_TIMEOUT=20 expecting to increase the timeout and then run $ ansible-inventory --list -i infoblox.yaml

but instead of getting the list of hosts I get [WARNING]: * Failed to parse /home/infoblox.yaml with auto plugin: Timeout value connect was 20, but it must be an int, float or None. [WARNING]: * Failed to parse /home/infoblox.yaml with yaml plugin: Plugin configuration YAML file, not YAML inventory [WARNING]: * Failed to parse /home/infoblox.yaml with ini plugin: Invalid host pattern 'plugin:' supplied, ending in ':' is not allowed, this character is reserved to provide a port. [WARNING]: Unable to parse /home/infoblox.yaml as an inventory source [WARNING]: No inventory was parsed, only implicit localhost is available { "_meta": { "hostvars": {} }, "all": { "children": [ "ungrouped" ] } }

It seems environmental variables are always strings so the inventory plugin should convert the env into a string. Am I wrong?

I know that my set up has all requirements and it is set up correctly because if I modified plugins/module_utils/api.py to have a timeout of 20 'http_request_timeout': dict(type='int', default=20, fallback=(env_fallback, ['INFOBLOX_HTTP_REQUEST_TIMEOUT'])), and then I can successfully run $ ansible-inventory --list -i infoblox.yaml and I get the list of all hosts in our infoblox device.

In the meantime, is there a workaround that doesn't involve modifying apy.py?

hemanthKa677 commented 1 year ago

Hi @mrfito, Could you please share the yaml data from infoblox.yaml ? So that, I will test on my end to fix the issue.

mrfito commented 1 year ago

Hi @hemanthKa677 I failed to see how the contents of the infoblox.yaml will help but here you are. Please let me know if you need anything else. Thanks, Rodolfo

`# This file provides the configuration information for the Infoblox dynamic

inventory script that is used to dynamically pull host information from NIOS.

plugin: infoblox.nios_modules.nios_inventory host: myhost.mydoamin.com username: admin password: OurSecretPassword

hostfilter: `