Understanding and writing ansible playbook

Ansible playbooks are written in YAML language. #vi ngix-install.yml
So create with .yml or .yaml extension

YAML files begins with —

next immediate line starts with – . Name is optional -name:

hosts expects all or group hosts: all

Do you want to become a root on target server use become become: true

what action you need to perform specify under tasks tasks:

Modules there are 500+ modules
Simple google search ansible module to install package yum:

ansible module to copy file name:ngnix
state: latest

service:
name:nginx
state: started

The hosts file is inventory. That means you can create hosts file in any directory

service
name: nginx
start: started

To check whether yaml will work
# ansible-playbook -i hosts ngnix-install.yml –check

Leave a comment