提问人:ar rr 提问时间:11/10/2023 最后编辑:ar rr 更新时间:11/13/2023 访问量:50
ansible 有任务的无限循环吗?
Does ansible have infinite loops for tasks?
问:
我想创建一个剧本,如果它返回 404 错误,它将重新启动我的服务。 我正在使用 ansible-semaphore,所以,我只想使用 ansible。没有 python 或其他任何东西。我还没有在 ansible 中找到有关无限循环的信息。这甚至有可能永远运行我的剧本,直到 SIGKILL?
在 python 中,它应该像
While True:
bool = task1()
if bool:
task2()
如何创建零件?
我的 playbook 中的任务是:While: True
tasks:
- name: Check if service is working
uri:
url: "http://example.com
status_code: [200,404]
register: result
until: result.status == 404
retries: 10
delay: 30
- name: restart nginx
ansible.builtin.shell: systemctl restart nginx
when: "{{ result }} == 404"
答: 暂无答案
评论