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

Cope with Ansible >= 2.4 inventory changes #85

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

nphilipp
Copy link

@nphilipp nphilipp commented Dec 5, 2019

This is to deal with changes in Ansible 2.4 which removed ansible.inventory.Inventory, apparently to be replaced by ansible.inventory.manager.InventoryManager.

Here's how it behaved without the changes in this PR:

(ansible-review) nils@gibraltar:~/src/fedora-infra/ansible (master)> ansible-review inventory/builders 
WARN: No configuration file found at /home/nils/.config/ansible-review/config.ini
WARN: Using example standards found at /home/nils/src/ansible-review/lib/ansiblereview/examples
WARN: Using example lint-rules found at /home/nils/src/ansible-review/lib/ansiblereview/examples/lint-rules
Traceback (most recent call last):
  File "/home/nils/src/ansible-review/lib/ansiblereview/inventory.py", line 36, in parse
    ansible.inventory.Inventory(loader=loader, variable_manager=var_manager,
AttributeError: module 'ansible.inventory' has no attribute 'Inventory'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/nils/.virtualenvs/ansible-review/bin/ansible-review", line 11, in <module>
    load_entry_point('ansible-review', 'console_scripts', 'ansible-review')()
  File "/home/nils/src/ansible-review/lib/ansiblereview/__main__.py", line 99, in main
    errors = errors + candidate.review(options, lines)
  File "/home/nils/src/ansible-review/lib/ansiblereview/__init__.py", line 76, in review
    return utils.review(self, settings, lines)
  File "/home/nils/src/ansible-review/lib/ansiblereview/utils/__init__.py", line 120, in review
    result = standard.check(candidate, settings)
  File "/home/nils/src/ansible-review/lib/ansiblereview/inventory.py", line 41, in parse
    result.errors = [Error(None, "Inventory is broken: %s" % e.message)]
AttributeError: 'AttributeError' object has no attribute 'message'
(ansible-review) nils@gibraltar:~/src/fedora-infra/ansible (master)>

This PR also lets ansible-review cope with exceptions caught that don't have a message attribute.

@nphilipp
Copy link
Author

nphilipp commented Dec 5, 2019

NB: I'm not really familiar with Ansible innards myself, so please pay special attention to the actual functional changes in the "Cope with Ansible >= 2.4 inventory changes." commit when reviewing. Thanks.

@nphilipp nphilipp force-pushed the master--ansible-2.4-inventory branch from 267502c to 249c0fb Compare December 23, 2019 14:48
If pep8-naming is installed, flake8 will flag importing a camel-cased
module on Python 2 as the (better) name of the equivalent module in
Python.

Signed-off-by: Nils Philippsen <[email protected]>
@nphilipp nphilipp force-pushed the master--ansible-2.4-inventory branch from 249c0fb to 6bbe8b7 Compare June 9, 2020 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant