Whenever you run a playbook, Ansible first checks the syntax of the playbook file. If an error is encountered, Ansible will error out saying there was a syntax error and will not proceed unless you fix that error. This syntax checking is performed only when you run the ansible-playbook command. When writing a big playbook, or if you have included task files, it might be difficult to fix all of the errors; this might end up wasting more time. In order to deal with such situations, Ansible provides a way to check your YAML syntax as you keep progressing with your playbook. For this example, we will need to create the playbooks/setup_apache.yaml file with the following content:
---
- hosts: all
tasks:
- name: Install Apache
yum:
name: httpd
state: present
become: True
- name: Enable Apache
service:
name: httpd
...