Strategy Plugins

Strategy plugins control the flow of play execution by handling task and host scheduling.

Enabling Strategy Plugins

Strategy plugins shipped with Ansible are enabled by default. You can enable a custom strategy plugin byputting it in one of the lookup directory sources configured in ansible.cfg.

Using Strategy Plugins

Only one strategy plugin can be used in a play, but you can use different ones for each play in a playbook or ansible run.The default is the linear plugin. You can change this default in Ansible configuration using an environment variable:

  1. export ANSIBLE_STRATEGY=free

or in the ansible.cfg file:

  1. [defaults]
  2. strategy=linear

You can also specify the strategy plugin in the play via the strategy keyword in a play:

  1. - hosts: all
  2. strategy: debug
  3. tasks:
  4. - copy: src=myhosts dest=/etc/hosts
  5. notify: restart_tomcat
  6.  
  7. - package: name=tomcat state=present
  8.  
  9. handlers:
  10. - name: restart_tomcat
  11. service: name=tomcat state=restarted

Plugin List

You can use ansible-doc -t strategy -l to see the list of available plugins.Use ansible-doc -t strategy <plugin name> to see plugin-specific specific documentation and examples.

See also