mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-14 06:30:31 -07:00
* 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>
(cherry picked from commit c776387daa
)
Co-authored-by: Jason Lingohr <lingfish@users.noreply.github.com>
This commit is contained in:
parent
c4e93b0b5f
commit
176c9a90ca
2 changed files with 5 additions and 2 deletions
changelogs/fragments
scripts/inventory
|
@ -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…
Add table
Reference in a new issue