Delegation and parallel execution
By default, Ansible tasks are executed in parallel. Delegating a task does not change this and does not handle concurrency issues (multiple forks writing to the same file).
Most commonly, users are affected by this when updating a single file on a single delegated to host for all hosts (using thecopy,template, orlineinfilemodules, for example). They will still operate in parallel forks (default 5) and overwrite each other.
This can be handled in several ways:
By using an intermediate play withserial: 1or usingthrottle: 1at the task level, for more detail seeControlling playbook execution: strategies and more