From af9ff07c74b53798edff132aa8f8099773e97a91 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Wed, 13 Feb 2019 08:36:37 -0500 Subject: [PATCH] Send openstack inventory logs to stderr (#51827) --- changelogs/fragments/51827-openstack_logs_to_stderr.yml | 2 ++ lib/ansible/plugins/inventory/openstack.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/51827-openstack_logs_to_stderr.yml diff --git a/changelogs/fragments/51827-openstack_logs_to_stderr.yml b/changelogs/fragments/51827-openstack_logs_to_stderr.yml new file mode 100644 index 0000000000..e442988691 --- /dev/null +++ b/changelogs/fragments/51827-openstack_logs_to_stderr.yml @@ -0,0 +1,2 @@ +bugfixes: + - openstack inventory plugin - send logs from sdk to stderr so they do not combine with output diff --git a/lib/ansible/plugins/inventory/openstack.py b/lib/ansible/plugins/inventory/openstack.py index 9c9a1e0300..671ffd3c68 100644 --- a/lib/ansible/plugins/inventory/openstack.py +++ b/lib/ansible/plugins/inventory/openstack.py @@ -108,6 +108,7 @@ fail_on_errors: yes ''' import collections +import sys from ansible.errors import AnsibleParserError from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable @@ -172,8 +173,10 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): else: config_files = None + # Redict logging to stderr so it does not mix with output + # particular ansible-inventory JSON output # TODO(mordred) Integrate openstack's logging with ansible's logging - sdk.enable_logging() + sdk.enable_logging(stream=sys.stderr) cloud_inventory = sdk_inventory.OpenStackInventory( config_files=config_files,