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

Compatibility with Ansible devel (2.8) broken #1727

Closed
pilou- opened this issue Feb 6, 2019 · 22 comments · Fixed by #2034
Closed

Compatibility with Ansible devel (2.8) broken #1727

pilou- opened this issue Feb 6, 2019 · 22 comments · Fixed by #2034
Labels
test Improvement to quality assurance: CI/CD, testing, building

Comments

@pilou-
Copy link
Contributor

pilou- commented Feb 6, 2019

Issue Type

  • Bug report

Since 7e92ff823e2bf97ee33c1b7ff87bb8acecb5ae77, molecule doesn't work with ansible devel version.

Error is:

        ==================================== ERRORS ====================================
        ____________________ ERROR collecting tests/test_default.py ____________________
        tests/test_default.py:6: in <module>
            os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
        /home/travis/build/ansible/molecule/.tox/ansibledevel-functional/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'

Issue was reported by @maxamillion on #ansible-molecule channel:

@maxamillion | can anyone advise what I'm doing wrong here? https://paste.fedoraproject.org/paste/6Q4OJP4CQxfzGU0HzqTpog
@maxamillion | or what I might be missing                                                                               
@maxamillion | I *think* it's a bug in testinfra, but I'm not certain                                                   
       Pilou | maxamillion: it seems base_parser has been removed (7e92ff823e2bf97ee33c1b7ff87bb8acecb5ae77)            
      @bcoca | maxamillion: tanner was saying this last week, ansible changed the internal options parser               
      @bcoca | and molecule uses it directly, which now breaks with devel                                               
      @bcoca | you can still use with <=2.7                                                                             
@maxamillion | oh right, I vaguely remember that conversation                                                           
@gundalow gundalow added the test Improvement to quality assurance: CI/CD, testing, building label Feb 6, 2019
@gundalow gundalow added this to the v2.20 milestone Feb 6, 2019
@decentral1se decentral1se self-assigned this Feb 6, 2019
@singuliere
Copy link
Contributor

I'll give this a try. Not sure to succeed but announcing anyways ;-)

@singuliere
Copy link
Contributor

singuliere commented Feb 8, 2019

Reproduced locally (see the full output) with

TOXENV='ansibledevel-functional' tox -- -k 'test_command_init_role[docker]' test/functional/test_command.py

with the following diff on tox.ini (also proposed as an enhancement)

diff --git a/tox.ini b/tox.ini
index 8e0e3823..30932e68 100644
--- a/tox.ini
+++ b/tox.ini
@@ -30,7 +30,7 @@ extras =
     vagrant
 commands =
     unit: pytest test/unit/ --cov={toxinidir}/molecule/ --no-cov-on-fail {posargs}
-    functional: pytest test/functional/ {posargs}
+    functional: pytest {posargs:test/functional/}
     lint: flake8
     lint: yamllint -s test/ molecule/

@singuliere
Copy link
Contributor

The corresponding testinfra issue is pytest-dev/pytest-testinfra#401

decentral1se added a commit to decentral1se/molecule that referenced this issue Feb 8, 2019
Until we fix:
* ansible#1727

Signed-off-by: Luke Murphy <[email protected]>
decentral1se added a commit to decentral1se/molecule that referenced this issue Feb 8, 2019
Until we fix:
* ansible#1727

Signed-off-by: Luke Murphy <[email protected]>
@decentral1se
Copy link
Contributor

Thanks for investigating @singuliere. I've submitted #1733 to stop us getting failing builds on master during the cron runs that test against ansible-devel. Let's hope to see a fix in testinfra soon.

@singuliere
Copy link
Contributor

@lwm this is indeed the wise thing to do :-) I proposed a pull request to testinfra but it is not trivial and I suspect it will be some time before this is fixed.

@webknjaz
Copy link
Member

webknjaz commented Feb 11, 2019

Basically testinfra uses private API which is not (and never was) guaranteed to be stable. The right way, as for now, is to call CLI. The long-term fix would be to use ansible-runner which (I heard so) is going to be ready at some point in future (aka probably soon).

@singuliere
Copy link
Contributor

The right way, as for now, is to call CLI.

@webknjaz there is no way to implement the testinfra ansible backend with the ansible CLI. The only choice is to use the unstable API. Or to not provide support for ansible at all, which we would not want, right? 😃

@webknjaz
Copy link
Member

Well, I just relayed what I heard from our internal slack. Didn't look into it personally.

@decentral1se
Copy link
Contributor

I think a number of tools have struggled with this choice (API vs. CLI), including this one! See https://molecule.readthedocs.io/en/latest/faq.html#have-you-thought-about-using-ansible-s-python-api-instead-of-playbooks. I am watching ansible-runner closely (I even tried a little experiment myself and the API is coming along fine IMHO!

@decentral1se
Copy link
Contributor

PR out for a fix in testinfra -> pytest-dev/pytest-testinfra#404

@themr0c themr0c modified the milestones: v2.20, v.2.21 Feb 20, 2019
@decentral1se decentral1se removed this from the v.2.21 milestone Feb 27, 2019
@decentral1se decentral1se removed their assignment Mar 19, 2019
@decentral1se
Copy link
Contributor

Further developments in pytest-dev/pytest-testinfra#401 👍

Luckily for us, it seems testinfra may be going in the direction of using ansible-runner!

@webknjaz
Copy link
Member

Ref: #1983

@decentral1se
Copy link
Contributor

OK people, we can move ahead with fixing this now. See pytest-dev/pytest-testinfra#401.

@decentral1se
Copy link
Contributor

OK, we can close this off with #2034.

kentr added a commit to kentr/drupal-vm that referenced this issue May 13, 2019
Molecule `2.20.1` installs on Python2.7 now.

Using `--pre` is resulting in Ansible 2.8-devel, and Molecule currently
doesn't work well with Ansible 2.8-devel.

See ansible/molecule#1727
jasonrogena added a commit to onaio/ansible-rapidpro-indexer that referenced this issue May 21, 2019
Specify the version of Ansible installed on TravisCI since there
currently seems to be compatibility issues with Ansible 2.8.

Related to ansible/molecule#1727

Signed-off-by: Jason Rogena <[email protected]>
@wildone
Copy link

wildone commented May 24, 2019

I got around this by adding testinfra to travis.yml which installed testinfra 3.0+

  • pip install testinfra molecule docker

jonashackt added a commit to jonashackt/molecule-ansible-docker-aws that referenced this issue May 24, 2019
…molecule 2.20.1 has requirement testinfra==1.19.0, but you'll have testinfra 3.0.4 which is incompatible.` thats simply wrong - with that, Molecule runs with Testinfra 3.x and Ansible 2.8 again like a charm - until the fix ansible/molecule#1727 gets released
@jonashackt
Copy link
Contributor

jonashackt commented May 24, 2019

Thanks @wildone - installing testinfra right before molecule (pip install testinfra molecule) provides a running workaround 👍 , until new Molecule version is available as pip package

@abeluck
Copy link

abeluck commented May 28, 2019

Using molecule's docker image here, and we need to add the following line to the dockerfile to make it work with ansible 2.8 and testinfra 3.x:

RUN pip install "ansible==2.8.0" "testinfra==3.0.4"

@decentral1se
Copy link
Contributor

Thanks @abeluck, we have to make a new release soon ...

bessonovevgen added a commit to bessonovevgen/apache-1c that referenced this issue Jun 2, 2019
nkinder added a commit to nkinder/ansible-keycloak that referenced this issue Jun 8, 2019
This works around an issue with ansible and molecule that breaks
our CI.  This issue was recently fixed upstream, but is not yet
available in the packages used during testing.
nkinder added a commit to nkinder/ansible-keycloak that referenced this issue Jun 8, 2019
This works around an issue with ansible and molecule that breaks
our CI.  This issue was recently fixed upstream, but is not yet
available in the packages used during testing.
jasonrogena added a commit to onaio/ansible-nginx that referenced this issue Jun 17, 2019
To avoid the tests from failing when running testinfra, install the
testinfra PIP package before molecule.

Related to ansible/molecule#1727

Signed-off-by: Jason Rogena <[email protected]>
sradco added a commit to sradco/logging that referenced this issue Jun 18, 2019
This works around an issue with ansible and molecule that breaks
our CI.  This issue was recently fixed upstream, but is not yet
available in the packages used during testing.

Signed-off-by: Shirly Radco <[email protected]>
sradco added a commit to linux-system-roles/logging that referenced this issue Jun 18, 2019
This works around an issue with ansible and molecule that breaks
our CI.  This issue was recently fixed upstream, but is not yet
available in the packages used during testing.

Signed-off-by: Shirly Radco <[email protected]>
ericsysmin pushed a commit to avinetworks/ansible-role-avicontroller-vmware that referenced this issue Jun 19, 2019
gerrit-ovirt-org pushed a commit to oVirt/ovirt-engine-metrics that referenced this issue Jun 23, 2019
Updated upstream source commit.
Commit details follow:

Project: https://github.com/linux-system-roles/logging
Branch:  master
Commit:  02dca4b04308c8ab626ecf8e43b6507d85ce63f8
Author:  Shirly Radco
Date:    Tue, 18 Jun 2019 21:50:36 +0300

    Workaround for ansible/molecule#1727

    This works around an issue with ansible and molecule that breaks
    our CI.  This issue was recently fixed upstream, but is not yet
    available in the packages used during testing.

    Signed-off-by: Shirly Radco <[email protected]>

x-md5: 90e83f234da3d088d484638aeb90038a
Change-Id: If59b6bb0e80cebbaad7de6b379c28bbd606604ae
lhoss pushed a commit to scigility/kerberos_server that referenced this issue Jun 25, 2019
@lhoss
Copy link

lhoss commented Jun 25, 2019

Apart

pip install "ansible==2.8.0" "testinfra==3.0.4"

I also needed to bump cerberus (to v1.3.1) to avoid some schema errors.
Good that this bump was already done in master recently: #2103

jasonrogena added a commit to onaio/ansible-nginx that referenced this issue Jul 30, 2019
To avoid the tests from failing when running testinfra, install Ansible
2.7 instead of 2.8 in the .travis.yml file.

Related to ansible/molecule#1727

Signed-off-by: Jason Rogena <[email protected]>
jasonrogena added a commit to onaio/ansible-nginx that referenced this issue Jul 30, 2019
To avoid the tests from failing when running testinfra, install Ansible
2.7 instead of 2.8 in the .travis.yml file.

Related to ansible/molecule#1727

Signed-off-by: Jason Rogena <[email protected]>
HorizonNet pushed a commit to ultratendency/kerberos_server that referenced this issue Dec 14, 2019
* Fix yamlint warning

* Replace categories by galaxy tags

Fixing: E702: Use 'galaxy_tags' rather than 'categories'
FIxing: E701: Role info should contain description

* Fix shell set pipefail lines

* Fix for molecule inconsistency

ansible/molecule#1727

* Fix molecule version

* Add flake8 installation

* Travis CI moved to python 3.6

Pythton 2.7 will be deprecated at 01.01.2010

* FIx ansible deprecation warning

* fix octal file mode checks (to work in both ansible v2.7.x and v2.8.x)

* update to latest molecule 2.22rc3 (that fixes flake8 and cerberus dependencies)

* update to recent molecule 2.22 stable version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Improvement to quality assurance: CI/CD, testing, building
Projects
None yet