sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
sudo nano /etc/ansible/hosts
Edited the file as:
[Webserver] 192.168.27.1
[servers] host1 ansible_ssh_host: 192.168.27.1 Then
sudo mkdir /etc/ansible/group_vars
sudo nano /etc/ansible/group_vars/servers
Yaml file is created as:
---
ansible_ssh_user: root
Then:
ansible -m ping all
and the error that I encountered is as:
ERROR! Attempted to read "/etc/ansible/hosts" as YAML: Syntax Error while loading YAML.
The error appears to have been in '/etc/ansible/hosts': line 46, column 1, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
[Webserver]
192.168.27.1
^ here
Attempted to read "/etc/ansible/hosts" as ini file: /etc/ansible/hosts:50: Expected key=value host variable assignment, got: 192.168.27.1
Please help me resolve this problem.