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

better information for user from inventory plugins #46766

Merged
merged 2 commits into from
Oct 12, 2018
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/inv_fixes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- Give user better error messages and more information on verbose about inventory plugin behaviour
2 changes: 1 addition & 1 deletion lib/ansible/inventory/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def parse_source(self, source, cache=False):
display.debug('%s failed to parse %s' % (plugin_name, source))
failures.append({'src': source, 'plugin': plugin_name, 'exc': AnsibleError(e)})
else:
display.debug('%s did not meet %s requirements' % (source, plugin_name))
display.v('%s did not meet %s requirements, check plugin documentation if this is unexpected' % (source, plugin_name))
else:
if not parsed and failures:
# only if no plugin processed files should we show errors.
Expand Down
7 changes: 6 additions & 1 deletion lib/ansible/plugins/inventory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,13 @@ def verify_file(self, path):
So only call this base class if you expect it to be a file.
'''

valid = False
b_path = to_bytes(path, errors='surrogate_or_strict')
return (os.path.exists(b_path) and os.access(b_path, os.R_OK))
if (os.path.exists(b_path) and os.access(b_path, os.R_OK)):
valid = True
else:
self.display.vvv('Skipping due to inventory source not existing or not being readable by the current user')
return valid

def _populate_host_vars(self, hosts, variables, group=None, port=None):
if not isinstance(variables, Mapping):
Expand Down
6 changes: 4 additions & 2 deletions lib/ansible/plugins/inventory/foreman.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- requests >= 1.1
description:
- Get inventory hosts from the foreman service.
- "Uses a configuration file as an inventory source, it must end in foreman.yml or foreman.yaml and has a ``plugin: foreman`` entry."
- "Uses a configuration file as an inventory source, it must end in ``.foreman.yml`` or ``.foreman.yaml`` and has a ``plugin: foreman`` entry."
extends_documentation_fragment:
- inventory_cache
options:
Expand All @@ -29,7 +29,7 @@
description: foreman authentication user
required: True
password:
description: forman authentication password
description: foreman authentication password
required: True
validate_certs:
description: verify SSL certificate if using https
Expand Down Expand Up @@ -102,6 +102,8 @@ def verify_file(self, path):
if super(InventoryModule, self).verify_file(path):
if path.endswith(('foreman.yaml', 'foreman.yml')):
valid = True
else:
self.display.vvv('Skipping due to inventory source not ending in "foreman.yaml" nor "foreman.yml"')
return valid

def _get_session(self):
Expand Down