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:
parent
0b13fd2c76
commit
c776387daa
2 changed files with 5 additions and 2 deletions
|
@ -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).
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue