This module executes all modules just like a top-level play but allows all normal task attributes (e.g. with_items). It is useful as a replacement of include when it would be awkward (e.g. creating one/two line included files), factoring out repetitive task attributes (when/sudo/remote_user etc.) including the unsupported include/with_items combination.
All variables set (by e.g. register) are propagated outside the play and may be used in subsequent tasks
Note: gather_facts defaults to false in embedded plays
Note: This module (ab)uses internal Ansible APIs and is not guaranteed to work across all possible versions. Currently tested and working with 1.7.x (should work with many other versions too)
tasks
,pre_tasks
(also with embeddedinclude
)roles
gather_facts
(defaults to false)hosts
(but please don't use it)include
of whole plays
handlers
,notify
(onlynotify
on theplay
task itself is supported)vars
vars_prompt
tags
(tags are applied to theplay
task as a whole)
Simply copy (or symlink) the two files into your playbook directory (preserving directory structure), for example:
mkdir -p ~/playbooks/library ~/playbooks/action_plugins
ln -s `pwd`/action_plugins/play.py ~/playbooks/action_plugins/
ln -s `pwd`/library/play ~/playbooks/library/
- play:
tasks:
- postgresql_user: name=someuser
- postgresql_db: name=somedb owner=someuser
sudo: true
sudo_user: postgres
- play:
tasks:
- git: repo=http://example.com/{{ item.git }} dest=/usr/local/src/{{ item }}
- command: make install chdir=/usr/local/src/{{ item }}
with_items:
- foo
- bar
- play:
tasks:
- include: install.yml pkg={{ item }}
with_items:
- foo
- bar