infobloxopen / infoblox-ansible

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

nios_a_record fails when using environment variables for provider data #255

Open murrahjm opened 2 months ago

murrahjm commented 2 months ago

Given the following sample code:

infoblox.nios.nios_a_record:
  name: testrecord.domain.com
  view: default
  ipv4addr: 10.10.10.10

with the following environment variables set:

INFOBLOX_HOST INFOBLOX_USERNAME INFOBLOX_PASSWORD

the task fails with this error:

"ansible.module_utils.api.get_connector() argument after ** must be a mapping, not NoneType"

I think it's referencing this line: https://github.com/infobloxopen/infoblox-ansible/blob/1c947713461d0869c7ef44261ad12a0389be9b99/plugins/module_utils/api.py#L244

murrahjm commented 2 months ago

Just playing around I was able to fix this by changing this line:

https://github.com/infobloxopen/infoblox-ansible/blob/1c947713461d0869c7ef44261ad12a0389be9b99/plugins/module_utils/api.py#L244

to this:

self.connector = get_connector(**(provider or {}))

basically allowing an empty value to get passed, which will then be populated with the NIOS_PROVIDER_SPEC (unless provider is explicitly passed, in which case it will use that)

My python isn't great so I have no idea if this is the correct way to fix it, but I tested it in my environment and it seemed to function at least with the nios_a_record module. Happy to do a pull request is this is valid.