From 176c9a90caa160cb83caa0eb233f38d0e207d375 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2020 06:11:43 +0100 Subject: [PATCH] infoblox inventory script: Use stderr, and allow use of environment for config (#436) (#1183) * Use stderr, and allow use of environment for config Originally from https://github.com/ansible/ansible/pull/49685 * Create 436-infoblox-use-stderr-and-environment-for-config.yaml * Update changelogs/fragments/436-infoblox-use-stderr-and-environment-for-config.yaml Co-authored-by: Felix Fontein * Update scripts/inventory/infoblox.py Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein (cherry picked from commit c776387daa4565ab197221765b4ade8fc704d398) Co-authored-by: Jason Lingohr --- .../436-infoblox-use-stderr-and-environment-for-config.yaml | 2 ++ scripts/inventory/infoblox.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/436-infoblox-use-stderr-and-environment-for-config.yaml 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: