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

Molecule verify failed with "AttributeError: 'PlaybookCLI' object has no attribute 'base_parser'" #2083

Closed
codequokka opened this issue Jun 1, 2019 · 11 comments
Labels

Comments

@codequokka
Copy link

Issue Type

  • Bug report

Molecule and Ansible details

ansible 2.8.0
  config file = None
  configured module search path = ['/Users/nbchk/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/nbchk/work/ansible/molecule-install-test/.venv/lib/python3.7/site-packages/ansible
  executable location = /Users/nbchk/work/ansible/molecule-install-test/.venv/bin/ansible
  python version = 3.7.3 (default, Mar 27 2019, 09:23:15) [Clang 10.0.1 (clang-1001.0.46.3)]
molecule, version 2.20.1

Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • pip

Detail any linters or test runners used:

  • None

Desired Behavior

molecule verify should run default test example successfully.

Actual Behaviour

molecule verify failed with "AttributeError: 'PlaybookCLI' object has no attribute 'base_parser'"

$ molecule --debug vefiry
--> Validating schema /Users/nbchk/work/ansible/molecule-install-test/molecule/default/molecule.yml.
Validation completed successfully.
--> Test matrix
    
└── default
    └── verify
    
--> Scenario: 'default'
--> Action: 'verify'
--> Executing Testinfra tests found in /Users/nbchk/work/ansible/molecule-install-test/molecule/default/tests/...
DEBUG: ANSIBLE ENVIRONMENT
---
ANSIBLE_CONFIG: /var/folders/x_/5723f_vj5_j8rg8v_5rflzx00000gn/T/molecule/molecule-install-test/default/ansible.cfg
ANSIBLE_FILTER_PLUGINS: /Users/nbchk/work/ansible/molecule-install-test/.venv/lib/python3.7/site-packages/molecule/provisioner/ansible/plugins/filters:/var/folders/x_/5723f_vj5_j8rg8v_5rflzx00000gn/T/molecule/molecule-install-test/default/plugins/filters:/Users/nbchk/work/ansible/molecule-install-test/plugins/filters
ANSIBLE_LIBRARY: /Users/nbchk/work/ansible/molecule-install-test/.venv/lib/python3.7/site-packages/molecule/provisioner/ansible/plugins/libraries:/var/folders/x_/5723f_vj5_j8rg8v_5rflzx00000gn/T/molecule/molecule-install-test/default/library:/Users/nbchk/work/ansible/molecule-install-test/library
ANSIBLE_ROLES_PATH: /var/folders/x_/5723f_vj5_j8rg8v_5rflzx00000gn/T/molecule/molecule-install-test/default/roles:/Users/nbchk/work/ansible

DEBUG: MOLECULE ENVIRONMENT
---
MOLECULE_DEBUG: 'True'
MOLECULE_DEPENDENCY_NAME: galaxy
MOLECULE_DRIVER_NAME: vagrant
MOLECULE_ENV_FILE: /Users/nbchk/work/ansible/molecule-install-test/.env.yml
MOLECULE_EPHEMERAL_DIRECTORY: /var/folders/x_/5723f_vj5_j8rg8v_5rflzx00000gn/T/molecule/molecule-install-test/default
MOLECULE_FILE: /Users/nbchk/work/ansible/molecule-install-test/molecule/default/molecule.yml
MOLECULE_INSTANCE_CONFIG: /var/folders/x_/5723f_vj5_j8rg8v_5rflzx00000gn/T/molecule/molecule-install-test/default/instance_config.yml
MOLECULE_INVENTORY_FILE: /var/folders/x_/5723f_vj5_j8rg8v_5rflzx00000gn/T/molecule/molecule-install-test/default/inventory/ansible_inventory.yml
MOLECULE_LINT_NAME: yamllint
MOLECULE_PROJECT_DIRECTORY: /Users/nbchk/work/ansible/molecule-install-test
MOLECULE_PROVISIONER_LINT_NAME: ansible-lint
MOLECULE_PROVISIONER_NAME: ansible
MOLECULE_SCENARIO_DIRECTORY: /Users/nbchk/work/ansible/molecule-install-test/molecule/default
MOLECULE_SCENARIO_NAME: default
MOLECULE_VERIFIER_LINT_NAME: flake8
MOLECULE_VERIFIER_NAME: testinfra
MOLECULE_VERIFIER_TEST_DIRECTORY: /Users/nbchk/work/ansible/molecule-install-test/molecule/default/tests

DEBUG: SHELL REPLAY
ANSIBLE_CONFIG=/var/folders/x_/5723f_vj5_j8rg8v_5rflzx00000gn/T/molecule/molecule-install-test/default/ansible.cfg ANSIBLE_FILTER_PLUGINS=/Users/nbchk/work/ansible/molecule-install-test/.venv/lib/python3.7/site-packages/molecule/provisioner/ansible/plugins/filters:/var/folders/x_/5723f_vj5_j8rg8v_5rflzx00000gn/T/molecule/molecule-install-test/default/plugins/filters:/Users/nbchk/work/ansible/molecule-install-test/plugins/filters ANSIBLE_LIBRARY=/Users/nbchk/work/ansible/molecule-install-test/.venv/lib/python3.7/site-packages/molecule/provisioner/ansible/plugins/libraries:/var/folders/x_/5723f_vj5_j8rg8v_5rflzx00000gn/T/molecule/molecule-install-test/default/library:/Users/nbchk/work/ansible/molecule-install-test/library ANSIBLE_ROLES_PATH=/var/folders/x_/5723f_vj5_j8rg8v_5rflzx00000gn/T/molecule/molecule-install-test/default/roles:/Users/nbchk/work/ansible MOLECULE_DEBUG=True MOLECULE_DEPENDENCY_NAME=galaxy MOLECULE_DRIVER_NAME=vagrant MOLECULE_ENV_FILE=/Users/nbchk/work/ansible/molecule-install-test/.env.yml MOLECULE_EPHEMERAL_DIRECTORY=/var/folders/x_/5723f_vj5_j8rg8v_5rflzx00000gn/T/molecule/molecule-install-test/default MOLECULE_FILE=/Users/nbchk/work/ansible/molecule-install-test/molecule/default/molecule.yml MOLECULE_INSTANCE_CONFIG=/var/folders/x_/5723f_vj5_j8rg8v_5rflzx00000gn/T/molecule/molecule-install-test/default/instance_config.yml MOLECULE_INVENTORY_FILE=/var/folders/x_/5723f_vj5_j8rg8v_5rflzx00000gn/T/molecule/molecule-install-test/default/inventory/ansible_inventory.yml MOLECULE_LINT_NAME=yamllint MOLECULE_PROJECT_DIRECTORY=/Users/nbchk/work/ansible/molecule-install-test MOLECULE_PROVISIONER_LINT_NAME=ansible-lint MOLECULE_PROVISIONER_NAME=ansible MOLECULE_SCENARIO_DIRECTORY=/Users/nbchk/work/ansible/molecule-install-test/molecule/default MOLECULE_SCENARIO_NAME=default MOLECULE_VERIFIER_LINT_NAME=flake8 MOLECULE_VERIFIER_NAME=testinfra MOLECULE_VERIFIER_TEST_DIRECTORY=/Users/nbchk/work/ansible/molecule-install-test/molecule/default/tests

DEBUG: COMMAND
/Users/nbchk/work/ansible/molecule-install-test/.venv/bin/py.test --connection=ansible --ansible-inventory=/var/folders/x_/5723f_vj5_j8rg8v_5rflzx00000gn/T/molecule/molecule-install-test/default/inventory/ansible_inventory.yml -p no:cacheprovider --debug /Users/nbchk/work/ansible/molecule-install-test/molecule/default/tests/test_default.py -vvv

    ============================= test session starts ==============================
    platform darwin -- Python 3.7.3, pytest-4.6.0, py-1.8.0, pluggy-0.12.0 -- /Users/nbchk/work/ansible/molecule-install-test/.venv/bin/python3.7
    using: pytest-4.6.0 pylib-1.8.0
    setuptools registered plugins:
      testinfra-1.19.0 at /Users/nbchk/work/ansible/molecule-install-test/.venv/lib/python3.7/site-packages/testinfra/plugin.py
    rootdir: /Users/nbchk/work/ansible/molecule-install-test/molecule/default
    plugins: testinfra-1.19.0
    collecting ... 
collecting 0 items / 1 errors                                                  
collected 0 items / 1 errors                                                   
    
    ==================================== ERRORS ====================================
    ____________________ ERROR collecting tests/test_default.py ____________________
    tests/test_default.py:6: in <module>
        os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
    ../../.venv/lib/python3.7/site-packages/testinfra/utils/ansible_runner.py:153: in __init__
        self.cli.options = self.cli.base_parser(
    E   AttributeError: 'PlaybookCLI' object has no attribute 'base_parser'
    =============================== warnings summary ===============================
    /Users/nbchk/work/ansible/molecule-install-test/.venv/lib/python3.7/site-packages/jinja2/utils.py:485
      /Users/nbchk/work/ansible/molecule-install-test/.venv/lib/python3.7/site-packages/jinja2/utils.py:485: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
        from collections import MutableMapping
    
    /Users/nbchk/work/ansible/molecule-install-test/.venv/lib/python3.7/site-packages/jinja2/runtime.py:318
      /Users/nbchk/work/ansible/molecule-install-test/.venv/lib/python3.7/site-packages/jinja2/runtime.py:318: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
        from collections import Mapping
    
    /Users/nbchk/work/ansible/molecule-install-test/.venv/lib/python3.7/site-packages/yaml/constructor.py:126
      /Users/nbchk/work/ansible/molecule-install-test/.venv/lib/python3.7/site-packages/yaml/constructor.py:126: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
        if not isinstance(key, collections.Hashable):
    
    -- Docs: https://docs.pytest.org/en/latest/warnings.html
    !!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
    ===================== 3 warnings, 1 error in 0.74 seconds ======================
@codequokka codequokka added the bug label Jun 1, 2019
@coaxial
Copy link

coaxial commented Jun 2, 2019

Same situation here, I tried forcing pip install testinfra==3.0.4 but I'm getting ERROR: molecule 2.20.1 has requirement testinfra==1.19.0, but you'll have testinfra 3.0.5 which is incompatible.

@coaxial
Copy link

coaxial commented Jun 2, 2019

One temporary fix is to pip install molecule==2.19 ansible==2.7.11.

@codequokka
Copy link
Author

@coaxial, Your workaround solves this issue.
But it is only workaround.
I think if molecule installs ansible 2.8 as its dependency, testinfra adpoting for ansible 2.8 should be installed.

@coaxial
Copy link

coaxial commented Jun 3, 2019

For sure, this is a workaround if you don't want to wait around for a patch that solves the issue and keep working in the meantime.

@WithoutAnAce
Copy link

Yep, from what I've been messing around with, testinfra 1.19 doesn't work with newer versions of Ansible (the ones installed by default by molecule). I've had some luck with just installing the latest testinfra and ignoring that error.

@codequokka
Copy link
Author

@wilmardo
I know ansible 2.8 some backward compatibility issue(#1727).
However latest testinfra already compatible with ansible 2.8, so I want that molecule install latest testinfra as it dependency.

@WithoutAnAce
Copy link

Is the latest testinfra compatible with molecule?

@tehsmyers
Copy link
Contributor

The latest testinfra is compatible with molecule, and vice versa. molecule is currently using the latest testinfra on master starting with the merge of #2034, and this issue should be fixed with the next release of molecule.

@wilmardo
Copy link
Contributor

wilmardo commented Jun 5, 2019

@codequokka Did you mean to mention me? This seems outside of my expertise :)

@codequokka
Copy link
Author

@wilmardo
I'm sorry that I confused @wilmardo and @WithoutAnAce :(

@seandst
Thank you.
I use a workaround @coaxial mentioned until next molecule release.

bibliotechy pushed a commit to tulibraries/ansible-rails_app that referenced this issue Jun 12, 2019
Fixes a [molecule issue](ansible/molecule#2083) preventing Ansible 2.8 to be used, which is required for new additions to this role.
@rshad
Copy link

rshad commented Jul 5, 2019

Hi all,

@coaxial > One temporary fix is to pip install molecule==2.19 ansible==2.7.11.

Working with this version of Molecule will lead to the error:

ERROR. Duplicate scenario name "default" found. Exiting

In order to get the right compatibility I used the following versions of ansible and molecule:

  • ansible 2.7.11
  • molecule 2.20.1 "latest"

Kind Regards,

Rshad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants