Question
Delegate_to connection overhead limits during loop execution
Tasadduq BurneyownerOwner · Founder
23.5K reputation · 23 Oct 2022, 08:57 UTC
31K views0
Goal
Evaluate the performance impact and connection behavior when combining the delegate_to keyword with task loops in Ansible.
While delegate_to allows task execution on a host other than the current target, executing this within a loop may trigger repeated connection overhead. It is unclear if the connection plugin maintains a persistent session for the delegated host across loop iterations or establishes a new connection for every item.
Questions
- Does Ansible reuse the SSH connection to the delegated host across loop iterations, or is a new connection initiated for each item?
- What are the documented limits or recommended configurations to mitigate connection latency when delegating looped tasks to a single external host?