ansible - 失败时重试 ansible ad-hoc
问题描述
在ansible playbook中,我们可以检测shell命令的结果,检查然后重试,如果有这样的失败
---
# Retry when failure
- hosts: all
become: yes
become_user: www-data
vars:
ansible_python_interpreter: /usr/bin/python3
tasks:
- name: checking test task
shell: bin/console ahihi
args:
chdir: /var/www/backend/current/
executable: /bin/bash
register: result
until: result == 0
retries: 3
delay: 15
但是如何在 ansible ad-hoc 命令中配置注册/直到/重试/延迟?因为我需要运行一个小命令(但有时会在网络问题或类似情况下失败),需要重试至少 3 次才能放弃。
这是我的临时命令:
ansible -i cron -m shell \
--become --become-user www-data \
-a "/var/www/backend/current/bin/console ahihi"
解决方案
推荐阅读
- c# - 项目名称导致命名空间混淆
- r - RSQLite - dbWriteTable - field.type - 如何获得正确的日期格式?
- html - 为什么 box-shadow 属性不适用于 a 而是直接应用于 Edge 中的元素?
- pandas - 如何使用 groupby 并计算每个组的计数
- java - 我如何在相机帧上循环处理(例如使用标准 java Image QR 检测器扫描 qr 码)
- sql-server - 如何从 Azure SQL 数据库查询本地 SQL Server 数据库?
- jquery - 如何使用相同的 jQuery 函数选择不同的 div?
- flutter - 处理错误网络图像加载
- parsing - 为什么野牛不会自动转换语法?
- python - slack rtm_connect 没有返回输出