Skip to content

Commit

Permalink
Assure verify is not skipped with TestInfra
Browse files Browse the repository at this point in the history
A missing playbook does not mean no verification is to be done for
any verifiers. For example TestInfra verifier does not use a playbook.

Still, a missing verify.yml when using Ansible Verifier will be
considered a skip with warning.

Fixes: 2543
  • Loading branch information
ssbarnea committed Feb 10, 2020
1 parent 10cc6f8 commit ef22e7c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 0 additions & 4 deletions molecule/command/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ def execute(self):
:return: None
"""
self.print_info()
if not self._config.provisioner.playbooks.verify:
msg = 'Skipping, verify playbook not configured.'
LOG.warning(msg)
return
self._config.verifier.execute()


Expand Down
4 changes: 4 additions & 0 deletions molecule/provisioner/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,10 @@ def verify(self):
:return: None
"""
if not self.playbooks.verify:
LOG.warning('Skipping, verify playbook not configured.')
return

pb = self._get_ansible_playbook(self.playbooks.verify)
pb.execute()

Expand Down
9 changes: 5 additions & 4 deletions molecule/test/unit/provisioner/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,11 @@ def test_syntax(_instance, mocker, _patched_ansible_playbook):
def test_verify(_instance, mocker, _patched_ansible_playbook):
_instance.verify()

_patched_ansible_playbook.assert_called_once_with(
_instance._config.provisioner.playbooks.verify, _instance._config
)
_patched_ansible_playbook.return_value.execute.assert_called_once_with()
if _instance._config.provisioner.playbooks.verify:
_patched_ansible_playbook.assert_called_once_with(
_instance._config.provisioner.playbooks.verify, _instance._config
)
_patched_ansible_playbook.return_value.execute.assert_called_once_with()


def test_write_config(temp_dir, _instance):
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ test =
pytest-xdist>=1.29.0, < 2
pytest>=4.6.3, < 5
shade>=1.31.0, < 2
testinfra >= 3.4.0
lint =
ansible-lint >= 4.1.1a2, < 5
flake8 >= 3.6.0
Expand Down

0 comments on commit ef22e7c

Please sign in to comment.