1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

infoblox inventory script: Use stderr, and allow use of environment for config (#436)

* 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 <felix@fontein.de>

* Update scripts/inventory/infoblox.py

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Jason Lingohr 2020-10-27 04:42:05 +10:00 committed by GitHub
parent 0b13fd2c76
commit c776387daa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -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).

View file

@ -20,6 +20,7 @@ from ansible_collections.community.general.plugins.module_utils.net_tools.nios.a
CONFIG_FILES = [ CONFIG_FILES = [
os.environ.get('INFOBLOX_CONFIG_FILE', ''),
'/etc/ansible/infoblox.yaml', '/etc/ansible/infoblox.yaml',
'/etc/ansible/infoblox.yml' '/etc/ansible/infoblox.yml'
] ]
@ -44,7 +45,7 @@ def main():
if os.path.exists(config_file): if os.path.exists(config_file):
break break
else: 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) sys.exit(-1)
try: try:
@ -53,7 +54,7 @@ def main():
provider = config.get('provider') or {} provider = config.get('provider') or {}
wapi = WapiInventory(provider) wapi = WapiInventory(provider)
except Exception as exc: except Exception as exc:
sys.stdout.write(to_text(exc)) sys.stderr.write(to_text(exc))
sys.exit(-1) sys.exit(-1)
if args.host: if args.host: