Task attribute order convention
In order to make the Ansible tasks in Vlad easy to read they should follow the following order of attributes:
name
- should also follow the name convention.module
- followed by attributes (e.g.command: ls -la
).with_items
- used to supply a list of options to the task.sudo
- used if the task needs sudo access.when
- used to run a check before running the task.tags
- roles will generally have their own tags so these should only be added to tasks in certain circumstances.- Any other option pertinent to the operation of the task (e.g.
changed_when
,failed_when
etc). notify
- needed if the task changes something that needs to restart a service. This should always appear at the end of the task block.
Examples
- name: add varnish vcl
template: src=varnish_defaultvcl.j2 dest=/etc/varnish/default.vcl
sudo: true
notify:
- restart varnish
- name: install MailCatcher prerequisite packages
apt: pkg={{ item }} state=installed
with_items:
- rubygems
- libsqlite3-dev
- ruby-dev
sudo: true