I am new to Ansible and I am trying to follow the steps in the below links to to Install nginx and webserver but when I am copy the code as it is and run it , it gives me an error similar to "ERROR! Syntax Error while loading YAML." although I am using online Yaml Validator and it says "YAML IS VALID"
I need Ansible/Yaml Editor when I past the code on it , it can restructure the file automatically to a valid one and adjust spaces and tabs!
---
- hosts: Appserver
become: true
tasks:
- name: install apache
apt: name=apache2 state=present update_cache=yes
- name: deleted index.html
file: path=/var/www/html/index.html state=absent
notify: restart apache2
handlers:
- name: restart apache2
service: name=apache2 state=restarted
- hosts: App1
become: true
tasks:
- name: set up index.html for first web server
copy: content="<html><header><title>Welcome to Server 1</title></header><body>Hello from Server 1!</body></html>" dest=/var/www/html/index.html mode=0644
notify: restart apache2
handlers:
- name: restart apache2
service: name=apache2 state=restarted
- hosts: App2
become: true
tasks:
- name: set up index.html for second web server
copy: content="<html><header><title>Welcome to Server 2</title></header><body>Hello from Server 2!</body></html>" dest=/var/www/html/index.html mode=0644
notify: restart apache2
handlers:
- name: restart apache2
service: name=apache2 state=restarted