diff --git a/changelogs/fragments/436-infoblox-use-stderr-and-environment-for-config.yaml b/changelogs/fragments/436-infoblox-use-stderr-and-environment-for-config.yaml new file mode 100644 index 0000000000..7a7a0445cb --- /dev/null +++ b/changelogs/fragments/436-infoblox-use-stderr-and-environment-for-config.yaml @@ -0,0 +1,2 @@ +minor_changes: + - infoblox inventory script - use stderr for reporting errors, and allow use of environment for configuration (https://github.com/ansible-collections/community.general/pull/436). diff --git a/scripts/inventory/infoblox.py b/scripts/inventory/infoblox.py index 6b2cae0b3f..9e985a9eb9 100644 --- a/scripts/inventory/infoblox.py +++ b/scripts/inventory/infoblox.py @@ -20,6 +20,7 @@ from ansible_collections.community.general.plugins.module_utils.net_tools.nios.a CONFIG_FILES = [ + os.environ.get('INFOBLOX_CONFIG_FILE', ''), '/etc/ansible/infoblox.yaml', '/etc/ansible/infoblox.yml' ] @@ -44,7 +45,7 @@ def main(): if os.path.exists(config_file): break else: - sys.stdout.write('unable to locate config file at /etc/ansible/infoblox.yaml\n') + sys.stderr.write('unable to locate config file at /etc/ansible/infoblox.yaml\n') sys.exit(-1) try: @@ -53,7 +54,7 @@ def main(): provider = config.get('provider') or {} wapi = WapiInventory(provider) except Exception as exc: - sys.stdout.write(to_text(exc)) + sys.stderr.write(to_text(exc)) sys.exit(-1) if args.host: