ansible / molecule

Molecule aids in the development and testing of Ansible content: collections, playbooks and roles
https://ansible.readthedocs.io/projects/molecule/
MIT License
3.89k stars 664 forks source link

3.0.2 testinfra not working on freshly initialized role #2597

Closed unglaublicherdude closed 4 years ago

unglaublicherdude commented 4 years ago

Issue Type

Molecule and Ansible details

docker run -v $(pwd):$(pwd) -w $(pwd) quay.io/ansible/molecule:3.0.2 molecule init role --verifier-name testinfra foobar
docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):$(pwd) -w $(pwd) quay.io/ansible/molecule:3.0.2 molecule test

Molecule installation method (one of):

Ansible installation method (one of):

Detail any linters or test runners used:

Desired Behavior

The default tests should run without any problems

Actual Behaviour

an error is thrown

ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --connection=ansible --ansible-inventory=/root/.cache/molecule/foobar/default/inventory/ansible_inventory.yml
  inifile: None
  rootdir: /home/xxx/Downloads/Projects/test/foobar/molecule/default
unglaublicherdude commented 4 years ago

Are you actually planning to remove testinfra? Because that is atm, the main way we test stuff.

zeitounator commented 4 years ago

The pinned issue #2560 (Migrating to molecule v3) states:

if you use testinfra, add it as a pip dependency, it is no longer installed by default

From what I read in the doc/tickets (and believe I understood), there is absolutely no intent to remove testinfra. In an effort to lower the number of mandatory dependencies, It is just not the default verifier any more. I do use testinfa and migrated. An example result here: https://travis-ci.org/ansible-ThoTeam/nexus3-oss/jobs/655689626#L2239

unglaublicherdude commented 4 years ago

Oh. IMHO that's a bad decision. I guess, for most of the molecule users testinfra is still the default. And it is a really bad user experience, when I can initialize something with your docker image, but the run itself without custom changes just fails.

unglaublicherdude commented 4 years ago

Workaround

docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):$(pwd) -w $(pwd) --user root quay.io/ansible/molecule:3.0.2 /bin/sh -c "pip3 install testinfra; molecule test -s default"

ssbarnea commented 4 years ago

Closing because it was fixed on master, next release will include testinfra inside the container.

Timmoth commented 1 year ago

I was getting this error today when testing molecule & testinfra for the first time.

running: pip install pytest-testinfra fixed it for me!

(note if you installed 'testinfra' run 'pip uninstall testinfra' first as its been deprecated)