Tutorial by Examples

In Ansible, a playbook is is a YAML file containing the definition of how a server should look. In a playbook you define what actions Ansible should take to get the server in the state you want. Only what you define gets done. This is a basic Ansible playbook that installs git on every host belongi...
The format of a playbook is quite straightforward, but strict in terms of spacing and layout. A playbook consists of plays. A play is a combination of targets hosts and the tasks we want to apply on these hosts, so a drawing of a playbook is this: To execute this playbook, we simply run: ansible...
Here’s a simple play: - name: Configure webserver with git hosts: webserver become: true vars: package: git tasks: - name: install git apt: name={{ package }} state=present As we said earlier, every play must contain: A set of hosts to configure A list of t...
Play contains several tasks, which can be tagged: - name: Install applications hosts: all become: true tasks: - name: Install vim apt: name=vim state=present tags: - vim - name: Install screen apt: name=screen state=present tags: - s...

Page 1 of 1