Repository: ansible/molecule

Issue #1262: Incompatibility with ansible 2.5.1 ?
Created: 2018-04-19T21:58:27Z
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).

Duplicate issue #1263: testinfra fails to collect tests when run in TravisCI
Created: 2018-04-20T10:46:15Z
Issue Type

Bug report

Molecule and Ansible details
ansible-2.5.1
molecule-2.12.1
Molecule installation method (one of):

pip

Ansible installation method (one of):

pip

Desired Behavior
I have a molecule project that runs successfully on Linux box and in Jenkins. However, when I try to run it in TravisCI, it fails on testinfra step (everything else seems to work perfectly).
.travis.yml:
---
language: python
python: "2.7"

sudo: required

services:
  - docker

before_install:
  - sudo apt-get update -qq

install:
  - pip install molecule
  - pip install docker-py

script:
- molecule test

Actual Behaviour
-->Executing Testinfra tests found in /home/travis/build/CourseOrchestra/fluteansible/molecule/default/tests/...
    ============================= test session starts ==============================
    platform linux2 -- Python 2.7.14, pytest-3.3.0, py-1.5.2, pluggy-0.6.0
    rootdir: /home/travis/build/CourseOrchestra/fluteansible/molecule/default, inifile:
    plugins: testinfra-1.7.1
collected 0 items / 1 errors                                                     
    ==================================== ERRORS ====================================
    ____________________ ERROR collecting tests/test_default.py ____________________
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/pluggy/__init__.py:617: in __call__
        return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/pluggy/__init__.py:222: in _hookexec
        return self._inner_hookexec(hook, methods, kwargs)
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/pluggy/__init__.py:216: in <lambda>
        firstresult=hook.spec_opts.get('firstresult'),
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/_pytest/python.py:192: in pytest_pycollect_makeitem
        res = list(collector._genfunctions(name, obj))
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/_pytest/python.py:370: in _genfunctions
        self.ihook.pytest_generate_tests(metafunc=metafunc)
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/pluggy/__init__.py:617: in __call__
        return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/pluggy/__init__.py:222: in _hookexec
        return self._inner_hookexec(hook, methods, kwargs)
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/pluggy/__init__.py:216: in <lambda>
        firstresult=hook.spec_opts.get('firstresult'),
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/testinfra/plugin.py:143: in pytest_generate_tests
        ansible_inventory=metafunc.config.option.ansible_inventory,
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/testinfra/host.py:125: in get_hosts
        for backend in testinfra.backend.get_backends(hosts, **kwargs):
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/testinfra/backend/__init__.py:89: in get_backends
        for name in klass.get_hosts(host, **kw):
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/testinfra/backend/ansible.py:72: in get_hosts
        return AnsibleRunner(kwargs.get("ansible_inventory")).get_hosts(host)
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/testinfra/utils/ansible_runner.py:171: in __init__
        self.cli._play_prereqs(self.cli.options))
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/ansible/cli/__init__.py:804: in _play_prereqs
        inventory = InventoryManager(loader=loader, sources=options.inventory)
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/ansible/inventory/manager.py:145: in __init__
        self.parse_sources(cache=True)
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/ansible/inventory/manager.py:206: in parse_sources
        parse = self.parse_source(source, cache=cache)
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/ansible/inventory/manager.py:261: in parse_source
        if plugin.verify_file(source):
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-packages/ansible/plugins/inventory/yaml.py:84: in verify_file
        if not ext or ext in self.get_option('yaml_extensions'):
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-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)
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-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)
    /home/travis/virtualenv/python2.7.14/lib/python2.7/site-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.71 seconds ============================
An error occured during the test sequence.  Cleaning up.

Closing comment (2018-04-20T10:57:48Z): Sorry, now I see this is already reported in #1262