An Ansible strategy decides how hosts move through a play. strategy: free lets each host run to the end of the play as fast as it can. linear, the default, finishes each task on every host before the next task starts. host_pinned works like free but never has more hosts mid-play than you have forks. The strategies guide states the default exactly: “By default, Ansible runs each task on all hosts affected by a play before starting the next task on any host, using 5 forks”. It sets free on a play like this:
- hosts: all
strategy: free
tasks:
# ...
linear, free and host_pinned compared
The first three rows come from the linear, free and host_pinned plugin pages and the playbook keywords reference. The last two rows are our view, drawn from those rules.
linear |
free |
host_pinned |
|
|---|---|---|---|
| Ordering | Lockstep per batch: each task runs on the batch, up to the fork limit at a time, before the next task | Each host moves on without waiting for other hosts to finish the current task | Like free, but hosts with an active play never exceed the number of forks |
| Shared task boundary | Yes, at every task | No | No |
max_fail_percentage |
Works | No: the keyword “only works on linear or linear-derived strategies” | No, for the same reason |
| State after an interrupted run (our view) | Hosts in the batch stop at or near the same task | Hosts in the batch can be at different points in the play | At most forks hosts part-way; the rest finished or not yet started |
| Suits (our view) | Plays that rely on max_fail_percentage |
Independent hosts with uneven task times | Independent hosts where a half-applied change is costly |
A strategy sets ordering, not capacity
The playbook keywords reference says the strategy keyword “Allows you to choose the strategy plugin to use for the play”, and each plugin page describes the order in which hosts take on tasks. The fork count sets how many hosts work at once, and the configuration reference lists its default as 5.
Concurrency is a separate control, covered in how Ansible runs a playbook. The configuration reference lists both settings in the [defaults] section of ansible.cfg, under the keys strategy and forks.
linear: lockstep, and the default
The linear plugin page (FQCN ansible.builtin.linear) describes task execution as “in lockstep per host batch as defined by serial (default all)”. Up to the fork limit of hosts run each task at once, then the next set, until the batch is done, before the play moves to the next task.
The playbook keywords reference says max_fail_percentage “can be used to abort the run after a given percentage of hosts in the current batch has failed”. It adds: “This only works on linear or linear-derived strategies”.
As illustrative arithmetic under lockstep: if 39 hosts finish a package install in two seconds and the fortieth takes ninety, that task holds the play for at least ninety seconds. If the same host is slowest at every one of 25 tasks, it paces the whole run.
free: every host races to the end of the play
The free plugin page (FQCN ansible.builtin.free) says: “Task execution is as fast as possible per batch as defined by serial (default all)”. Ansible does not wait for other hosts to finish the current task before queuing more tasks for other hosts. All hosts are still attempted for the current task, but hosts that have already finished are not blocked from new tasks.
The same page notes that, unlike the default linear strategy, a host that is slow or stuck on a task does not hold up the rest of the hosts and tasks.
What you give up:
max_fail_percentage. The keyword only works on linear or linear-derived strategies, per the keywords reference.- The once-only reading of
run_once. The ansible-lint run-once rule “warns against the use ofrun_oncewhen thestrategyis set tofree”, to remind users that “run_onceis not providing any warranty that the task will run only once”.
host_pinned: free, capped at the fork count
host_pinned (FQCN ansible.builtin.host_pinned) is marked “New in Ansible 2.7” on its plugin page. Execution is as fast as possible per host in the batch, and Ansible will not start a play for a host unless the play can be finished without interruption by tasks for another host. In the page’s words, “the number of hosts with an active play does not exceed the number of forks”.
Ansible does not wait for other hosts before queuing the next task for a host that has finished one. Once a host is done with the play, its slot opens to a host that was waiting to start. Other than that, the page says it behaves like free.
debug: an interactive session
Ansible also ships a debug strategy (ansible.builtin.debug). Its plugin page says execution is linear but “controlled by an interactive debug session”.
The debugging guide calls enabling the debugger as a strategy a backwards-compatible method that “may be removed in a future release”. The same guide documents the debugger keyword for a play, role, block or task, with values such as on_failed, on_unreachable, on_skipped, always and never.
Where a strategy is set, and what overrides what
A strategy can be set as a play keyword (shown at the top of this page), in ansible.cfg, or through an environment variable. The configuration reference lists the setting as DEFAULT_STRATEGY: default linear, added in version 2.3, [defaults] key strategy, environment variable ANSIBLE_STRATEGY. The ansible.cfg form matches the strategies guide:
[defaults]
strategy = free
The shell line below is adapted; the variable name comes from the configuration reference.
export ANSIBLE_STRATEGY=free
Ansible’s precedence appendix orders its categories, lowest to highest, as configuration settings, command-line options, playbook keywords, variables, and direct assignment. “Each category overrides any information from all lower-precedence categories”.
Within configuration settings, the appendix says: “Environment variables have a higher precedence than entries in ansible.cfg”. It also says: “Any playbook keyword will override any command-line option and any configuration setting”. So a play that declares strategy: linear beats an ansible.cfg or ANSIBLE_STRATEGY value of free. Our view: that is the escape hatch for a play that needs max_fail_percentage inside a fleet-wide free setup.
serial, throttle, order and run_once are not strategies
The strategies guide covers these keywords under its own heading, Using keywords to control execution, apart from strategy selection.
serialsets a batch size: “a number, a percentage, or a list of numbers of hosts”. Ansible “completes the play on the specified number or percentage of hosts before starting the next batch of hosts”. Bothfreeandhost_pinneddefine their behaviour per batch as defined byserial, so the two controls compose.throttle“limits the number of workers for a particular task” and can be set at block and task level. The guide suggests it for tasks that “may be CPU-intensive or interact with a rate-limiting API”. It can lower workers but not raise them aboveforksorserial.order“controls the order in which hosts are run”, with valuesinventory(default),reverse_inventory,sorted,reverse_sortedandshuffle.run_oncemakes a task attempt to run on the first host available and then apply results and facts to all active hosts in the same batch, per the keywords reference. Withserial, it runs on one host in each serial batch. Underfree, ansible-lint’s run-once rule warns against it.
For a task that must run only once regardless of serial, the strategies guide shows the when: inventory_hostname == ansible_play_hosts_all[0] construct instead of run_once. This task is an adapted example built on that condition:
- name: Report once across the play
ansible.builtin.debug:
msg: "This task is selected on the first host in the play."
when: inventory_hostname == ansible_play_hosts_all[0]
So serial: 10 with strategy: host_pinned is not contradictory. It means ten hosts per batch; within each batch, no more than forks hosts have an active play, and each runs it without interruption by tasks for another host.
Choosing one
Our view, based on the documented behaviour above:
- The play relies on
max_fail_percentage: stay onlinear. - Hosts are independent and per-host duration varies widely:
free. - Hosts are independent but a partially applied change is expensive:
host_pinned. - The change is risky regardless of strategy: add
serial, which is a blast-radius control rather than a speed control.
Strategy will not fix a capacity problem
Forks set how many hosts work at once (default 5, per the configuration reference), and no strategy raises that width. The inventory sizing calculator on this site models the fork, controller memory and batch-runtime relationship, and the ansible-playbook flag reference covers -f and the diagnostic options.
Common mistakes
- Treating
serialandstrategyas alternatives instead of controls that compose per batch. - Expecting
max_fail_percentageto stop afreeorhost_pinnedrun; the keywords reference limits it to linear or linear-derived strategies. - Relying on
run_oncefor singleton work underfree, which the ansible-lint run-once rule flags.
Which hosts a strategy applies to is a separate question, and it is answered by inventory groups, variables and patterns.
Evidence and limits: this page is documentary, drawn from the docs.ansible.com “latest” pages, checked on 2026-11-20, when the ansible.builtin collection index showed collection version 2.22.0.post0, plus the ansible-lint run-once rule. The examples were not run for this page.