我必须在我的剧本中重新启动systemd单元并等到服务处于活动状态,所以我的检查并等待"逻辑必须如下所示"伪代码":
for iterations=0; iterations < 10; iterations++ {
status = systemctl is-active myservice
if (status == active)
break
sleep 3s
}
}
if status != active {
failure: exit playbook
}
似乎在ansible playbook中我可以迭代shell命令的结果但是在查看&#34; loops&#34;在文件中: http://docs.ansible.com/ansible/latest/playbooks_loops.html#iterating-over-the-results-of-a-program-execution 根据输出,我无法找到如何重复命令本身。可以吗?