def begin(self):
super(Ansible, self).begin()
- self.execute_playbook()
+ if len(self.cluster.remotes) > 0:
+ self.execute_playbook()
+ else:
+ log.info("There are no remotes; skipping playbook execution")
def execute_playbook(self, _logfile=None):
"""
from teuthology.test.task import TestTask
+
class TestAnsibleTask(TestTask):
klass = Ansible
task_name = 'ansible'
assert m_execute.called
assert 'cleanup' in task.config['vars']
+ def test_no_remotes(self):
+ self.task_config.update(dict(
+ playbook=[],
+ ))
+ self.ctx.cluster.remotes = dict()
+ task = self.klass(self.ctx, self.task_config)
+ with patch.object(ansible.pexpect, 'run') as m_run:
+ task.setup()
+ task.begin()
+ assert not m_run.called
+
class TestCephLabTask(TestAnsibleTask):
klass = CephLab