An Ansible playbook uses a rolling update strategy with serial: 1. After the first host is updated, the playbook stops and shows 'PLAY RECAP' with only one host. What is the most likely reason?
Trap 1: the playbook has a 'failed_when' condition that stops execution
A 'failed_when' condition would cause the play to stop on failure, but it would not normally result in PLAY RECAP showing only one host unless all hosts fail. The scenario describes a successful run on one host.
Trap 2: the play uses 'delegate_to' incorrectly
Incorrect delegate_to usage would misdirect a task to another host, not truncate the play after one host; serial: 1 runs the whole play per host, so a failure or unreachable host on the first batch halts the run. It is tempting because delegate_to genuinely causes unexpected host targeting in other scenarios.
Trap 3: the playbook does not have any task that triggers the next batch,…
While 'serial: 1' controls concurrency, it does not stop execution after one batch; Ansible automatically proceeds to the next host after the current batch completes. This option is incorrect because it suggests that 'serial' alone causes the playbook to stop.
- A
the playbook has a 'failed_when' condition that stops execution
Why it fails: A 'failed_when' condition would cause the play to stop on failure, but it would not normally result in PLAY RECAP showing only one host unless all hosts fail. The scenario describes a successful run on one host.
- B
the inventory contains only one host
Correct. If the inventory contains only one host, the playbook will run on that host and then finish, producing a PLAY RECAP with exactly one host. This is the most likely reason given the behavior described.
- C
the play uses 'delegate_to' incorrectly
Why it fails: Incorrect delegate_to usage would misdirect a task to another host, not truncate the play after one host; serial: 1 runs the whole play per host, so a failure or unreachable host on the first batch halts the run. It is tempting because delegate_to genuinely causes unexpected host targeting in other scenarios.
- D
the playbook does not have any task that triggers the next batch, and 'serial' only controls concurrency, not retry
Why it fails: While 'serial: 1' controls concurrency, it does not stop execution after one batch; Ansible automatically proceeds to the next host after the current batch completes. This option is incorrect because it suggests that 'serial' alone causes the playbook to stop.