Molecule: Incompatibility with ansible 2.5.1 ?

Created on 19 Apr 2018  路  14Comments  路  Source: ansible-community/molecule

Issue Type

  • Bug report

Molecule and Ansible details

ansible --version

2.5.1

molecule --version

2.12.1
Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • pip

Desired Behavior

Testinfra tests should work fine.

Actual Behaviour (Bug report only)

Launching Testinfra tests trigger the following error:

` ============================= test session starts ==============================
platform linux2 -- Python 2.7.12, pytest-3.5.0, py-1.5.3, pluggy-0.6.0
rootdir: /home/stephen/dev/kafka-lib/molecule/kafka_1.0.1, inifile:
plugins: testinfra-1.7.1
collected 0 items / 1 errors

==================================== ERRORS ====================================
____________________ ERROR collecting tests/test_default.py ____________________
/usr/local/lib/python2.7/dist-packages/pluggy/__init__.py:617: in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
/usr/local/lib/python2.7/dist-packages/pluggy/__init__.py:222: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/local/lib/python2.7/dist-packages/pluggy/__init__.py:216: in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
/usr/local/lib/python2.7/dist-packages/_pytest/python.py:200: in pytest_pycollect_makeitem
    res = list(collector._genfunctions(name, obj))
/usr/local/lib/python2.7/dist-packages/_pytest/python.py:378: in _genfunctions
    self.ihook.pytest_generate_tests(metafunc=metafunc)
/usr/local/lib/python2.7/dist-packages/pluggy/__init__.py:617: in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
/usr/local/lib/python2.7/dist-packages/pluggy/__init__.py:222: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/local/lib/python2.7/dist-packages/pluggy/__init__.py:216: in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
/usr/local/lib/python2.7/dist-packages/testinfra/plugin.py:143: in pytest_generate_tests
    ansible_inventory=metafunc.config.option.ansible_inventory,
/usr/local/lib/python2.7/dist-packages/testinfra/host.py:125: in get_hosts
    for backend in testinfra.backend.get_backends(hosts, **kwargs):
/usr/local/lib/python2.7/dist-packages/testinfra/backend/__init__.py:89: in get_backends
    for name in klass.get_hosts(host, **kw):
/usr/local/lib/python2.7/dist-packages/testinfra/backend/ansible.py:72: in get_hosts
    return AnsibleRunner(kwargs.get("ansible_inventory")).get_hosts(host)
/usr/local/lib/python2.7/dist-packages/testinfra/utils/ansible_runner.py:171: in __init__
    self.cli._play_prereqs(self.cli.options))
/usr/local/lib/python2.7/dist-packages/ansible/cli/__init__.py:804: in _play_prereqs
    inventory = InventoryManager(loader=loader, sources=options.inventory)
/usr/local/lib/python2.7/dist-packages/ansible/inventory/manager.py:145: in __init__
    self.parse_sources(cache=True)
/usr/local/lib/python2.7/dist-packages/ansible/inventory/manager.py:206: in parse_sources
    parse = self.parse_source(source, cache=cache)
/usr/local/lib/python2.7/dist-packages/ansible/inventory/manager.py:261: in parse_source
    if plugin.verify_file(source):
/usr/local/lib/python2.7/dist-packages/ansible/plugins/inventory/yaml.py:84: in verify_file
    if not ext or ext in self.get_option('yaml_extensions'):
/usr/local/lib/python2.7/dist-packages/ansible/plugins/__init__.py:58: in get_option
    option_value = C.config.get_config_value(option, plugin_type=get_plugin_class(self), plugin_name=self._load_name, variables=hostvars)
/usr/local/lib/python2.7/dist-packages/ansible/config/manager.py:284: in get_config_value
    value, _drop = self.get_config_value_and_origin(config, cfile=cfile, plugin_type=plugin_type, plugin_name=plugin_name, keys=keys, variables=variables)
/usr/local/lib/python2.7/dist-packages/ansible/config/manager.py:304: in get_config_value_and_origin
    defs = self._plugins[plugin_type][plugin_name]
E   KeyError: 'inventory'
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
=========================== 1 error in 0.89 seconds ============================

`
The exact same test with exact same configuration is OK with Ansible 2.5.0 (instead of 2.5.1).

bug

Most helpful comment

I'm having the same problem here.
My "workaround" was to downgrade ansible to version 2.5.0 instead of using 2.5.1.

Everything is working again using the following versions:

  • ansible==2.5.0
  • molecule==2.12.1
  • pytest==3.5.0
  • testinfra==1.7.1
--> Executing Testinfra tests found in /home/test/roles/myrole/molecule/docker/tests/...
    ============================= test session starts ==============================
    platform linux2 -- Python 2.7.12, pytest-3.5.0, py-1.5.3, pluggy-0.6.0
    rootdir: /home/test/roles/myrole/molecule/docker, inifile:
    plugins: testinfra-1.7.1
collected 1 item

    tests/test_default.py .                                                  [100%]

    =========================== 1 passed in 3.48 seconds ===========================

All 14 comments

@StephenSorriaux what version of testinfra are you using?

@retr0h I am using testinfra 1.7.1 in both cases

Hello,

The same for me.
we have an incompatibility since last update. The same rror occurs

I'm having the same problem here.
My "workaround" was to downgrade ansible to version 2.5.0 instead of using 2.5.1.

Everything is working again using the following versions:

  • ansible==2.5.0
  • molecule==2.12.1
  • pytest==3.5.0
  • testinfra==1.7.1
--> Executing Testinfra tests found in /home/test/roles/myrole/molecule/docker/tests/...
    ============================= test session starts ==============================
    platform linux2 -- Python 2.7.12, pytest-3.5.0, py-1.5.3, pluggy-0.6.0
    rootdir: /home/test/roles/myrole/molecule/docker, inifile:
    plugins: testinfra-1.7.1
collected 1 item

    tests/test_default.py .                                                  [100%]

    =========================== 1 passed in 3.48 seconds ===========================

Yes, I'm currently doing the same thing.

Sorry for the question, but how do you downgrade to Ansible 2.5.0, it seems that it has been removed from apt?

Thanks ;)

I personally wouldn't mix apt python packages with pip python packages. If you're using Molecule, I suggest going full out on virtualenv and simply install the dependencies with pip. The quickstart should get you going.

Actually I'm still having this issue.
https://travis-ci.org/jgeusebroek/ansible-role-backports/jobs/369566362

Am I missing something?

You're using testinfra 1.7.1 and it was fixed in testinfra 1.12.0.

Thanks, I noticed that, but shouldn't the latest testinfra be installed with a _pip install molecule_?

Collecting testinfra==1.7.1 (from molecule) Using cached https://files.pythonhosted.org/packages/49/1c/3c276b76417553143b1976719c9c7d37a0a6e3d26451dee55177a8098d5a/testinfra-1.7.1-py2.py3-none-any.whl

When installing molecule on a 'clean' machine it also installs 1.7.1. (log)

Thats because Molecule 2.13 has not been released yet, which includes this fix.

That explains it. My bad. I'll just have to wait for release, thanks.

That explains it. My bad. I'll just have to wait for release, thanks.

馃憤

Was this page helpful?
0 / 5 - 0 ratings