Chr*_*s F 4 ansible ansible-2.x
Ansible v2.4.0.0
我正在安装Gitlab-CE,在Ansible任务中运行以下命令。如您所见,某些进程已关闭,但最终会启动。
# gitlab-ctl status
run: gitlab-workhorse: 0s, normally up
run: logrotate: 1s, normally up
down: nginx: 0s, normally up
down: postgresql: 1s, normally up
run: redis: 0s, normally up
run: sidekiq: 0s, normally up
run: unicorn: 0s, normally up
Run Code Online (Sandbox Code Playgroud)
如何编写Ansible wait_for任务来检查所有服务何时都处于运行状态?IOW我只想看到下一个任务就继续下一个任务
# gitlab-ctl status
run: gitlab-workhorse: 0s, normally up
run: logrotate: 1s, normally up
run: nginx: 0s, normally up
run: postgresql: 1s, normally up
run: redis: 0s, normally up
run: sidekiq: 0s, normally up
run: unicorn: 0s, normally up
Run Code Online (Sandbox Code Playgroud)
Kon*_*rov 10
您可以使用retries/ until方法:
- command: gitlab-ctl status
register: cmd_res
retries: 5
until: cmd_res.stdout_lines | reject('search','^run') | list | count == 0
Run Code Online (Sandbox Code Playgroud)
我们从开头的输出中删除任何行,run并对它们进行计数。仅当没有剩余的行时才继续执行下一个任务。
| 归档时间: |
|
| 查看次数: |
5745 次 |
| 最近记录: |