问题原文
原帖链接 · Elrond · CC BY-SA 3.0
On the play-level, we have serial: 1 to allow us to run the whole play one host at a time. But I haven't found a simple way to do this on a single task. This is especially relevant, if the task in question doesn't perform proper locking (for whatever reason).
One obvious answer is to put the task in its own play. But that doesn't help with roles. (Having to put serial: 1 on the play using the role isn't really intuitive.)
已采纳解答
原帖链接 · maxschlepzig · CC BY-SA 4.0
You can run a single task in serial (i.e. host-by-host) by adding throttle: 1 to it.
Example:
---
- hosts: all
tasks:
- name: wait in parallel
command: sleep 20
- name: wait in serial
command: sleep 30
throttle: 1
References:
NB: throttle was introduced in Ansible 2.9
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
