Closed Woytek-Polnik closed 5 years ago
Strange! Is this issue present in the latest release candidate?
with this
pip install --index-url https://test.pypi.org/simple --extra-index-url https://pypi.org/simple molecule==2.22rc4.dev10
I have the same error
________________ ERROR collecting shared/tests/test_default.py _________________ ../shared/tests/test_default.py:6: in <module> os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') /usr/lib/python2.7/site-packages/testinfra/utils/ansible_runner.py:127: in get_hosts inventory = self.inventory /usr/lib/python2.7/site-packages/testinfra/utils/__init__.py:44: in __get__ value = obj.__dict__[self.func.__name__] = self.func(obj) /usr/lib/python2.7/site-packages/testinfra/utils/ansible_runner.py:145: in inventory return get_ansible_inventory(self.ansible_config, self.inventory_file) /usr/lib/python2.7/site-packages/testinfra/utils/ansible_runner.py:58: in get_ansible_inventory return json.loads(local.check_output(cmd, *args)) /usr/lib64/python2.7/json/__init__.py:338: in loads return _default_decoder.decode(s) /usr/lib64/python2.7/json/decoder.py:366: in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) /usr/lib64/python2.7/json/decoder.py:384: in raw_decode raise ValueError("No JSON object could be decoded") E ValueError: No JSON object could be decoded !!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!! =========================== 1 error in 0.71 seconds ============================
@ssbarnea this should also black releases :/
I seen this error myself but I do not remember when and why. I do not use testinfra or ansible-runner myself so if we would have a very simple reproducer code it may be easier to get it fixed. Ideally a PR, one including a test, so we avoid regression.
https://github.com/WojciechPolnik/molecule_test_ansible_verbose created with molecule init role added requirements.txt from pip freeze python-3.7.4
default
scenario causes fail
ok
scenario works
differences:
config_options:
defaults:
verbosity: 2
I managed to identify what caused this failure, the output of ansible inventory listing command contains one debug line which, obviously, makes the entire output an invalid JSON.
Using /root/.cache/molecule_parallel/test-init-.../default/ansible.cfg as config file
This seems like something caused by Ansible itself, a serious regression as all logging should go exclusively to stderr
. I need to look from where it comes from...
Mainly this is caused by https://github.com/ansible/ansible/issues/59973 which breaks testinfra. Is not Molecule bug but clearly affects it really badly.
You are correct but it was like this in ansible 2.7, 2.6, 2.5. So ansible did not change. Just it was change the way it is wrapped/output parsed
II
the 1 debug line
depends on the verbosity, with verbosity 2 you have more lines etc
III
It works for Testinfa 1.* 2.*, fails
for 3.*
@WojciechPolnik Clearly Molecule has no fault in this and cannot even do anything about (other than avoiding nerwer versions of testinfra).
I will close this as we should look fixing https://github.com/philpep/testinfra/issues/470 and making a new release of testinfra.
@WojciechPolnik now that there is a fix in testinfra
, would you be able to do some Q&A testing to support us? Please see the patch in https://github.com/philpep/testinfra/pull/471. Any logs/feedback is much appreciated.
@decentral1se I'll test it within 24h and give feedback
Thanks a lot :rocket:
Responded in philpep/testinfra#471
Issue Type
Verbosity for ansible in molecule.yml breaks
verify
tests.Molecule and Ansible details
Python 2.7, 3.7 Ansible 2.7., 2.8.* Molecule 2.20.2
All via pip
Actual Behaviour
Fails:
Going deeper:
*`local.check_output(cmd, args)` returns verbose text.**
verbosity: 1
verbosity: 2
It cannot be dumped to json then
After cutting verbose lines to just pure
it works.
Desired Behavior
It worked for molecule 2.20.0 ok with new it crashes.