Our first playbook
Equipped with the basic rules explained previously and assuming readers have done a quick dive into YAML fundamentals, we will now begin writing our first playbook. Our problem statement includes the following:
- Create a devops user on all hosts. This user should be part of the
devops
group. - Install the "htop" utility. Htop is an improved version of top—an interactive system process monitor.
- Add the Nginx repository to the web servers and start it as a service.
Now, we will create our first playbook and save it as simple_playbook.yml
containing the following code:
--- - hosts: all remote_user: vagrant sudo: yes tasks: - group: name: devops state: present - name: create devops user with admin privileges user: name: devops comment: ...
Get Ansible Playbook Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.