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: "Devops User" uid: 2001 group: devops - name: install htop package action: apt name=htop state=present update_cache=yes - hosts: www user: vagrant sudo...