Sample playbook --- - hosts: webservers remote_user: root tasks: - name: ensure apache is at the latest version yum: pkg=httpd state=latest - name: write the apache config file template: src=/srv/httpd.j2 dest=/etc/httpd.conf - hosts: databases remote_user: root tasks: - name: ensure postgresql is at the latest version yum: name=postgresql state=latest - name: ensure that postgresql is started service: name=postgresql state=running David Murphy, October 2015
yum Manages packages with the yum package manager1 - yum: pkg=httpd state=latest 1 http://docs.ansible.com/ansible/yum_module.html David Murphy, October 2015
template Create/modify files using variables2 - template: src=/srv/httpd.j2 dest=/etc/httpd.conf 2 http://docs.ansible.com/ansible/template_module.html David Murphy, October 2015
service Controls services on the remote host(s)3 - service: name=postgresql state=running 3 http://docs.ansible.com/ansible/service_module.html David Murphy, October 2015
A better example → install packages → create database, then database user → download/unzip → edit config → configure webserver → ensure webserver is running David Murphy, October 2015