Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send openstack inventory logs to stderr #51827

Merged
merged 1 commit into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/51827-openstack_logs_to_stderr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- openstack inventory plugin - send logs from sdk to stderr so they do not combine with output
5 changes: 4 additions & 1 deletion lib/ansible/plugins/inventory/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
'''

import collections
import sys

from ansible.errors import AnsibleParserError
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
Expand Down Expand Up @@ -172,8 +173,10 @@ def parse(self, inventory, loader, path, cache=True):
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Should the inventory plugin be doing its own logging? @emonty Looks like logging was initially added in d548c47

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine if a plugin wants to log to a file, but the only supported data source the plugins have are the data from the inventory file, so it could add a log_file parameter and log there.

Integrating logging with Ansible logging in general would be more complex, and you can read more ranting about this in #51835


cloud_inventory = sdk_inventory.OpenStackInventory(
config_files=config_files,
Expand Down