The following is my yaml file for a ansible configuration of a cisco device. In /etc/ansible/hosts I have also edited the hosts file to reflect my Amazon EC2 Ami instance as can be seen below
[ec2-instances]
ec2-54-152-72-23.compute-1.amazonaws.com
Inventory file ^
YAML File Below
---
- hosts: ec2-54-152-72-23.compute-1.amazonaws.com
gather_facts: false
connection: local
tasks:
-name: Customer IOS Upgrade Initial Discovery
cli_command: "{{ show }}"
vars:
show:
- show run
- show version
- show interface status
- show license
-mail:
host: smtp.gmail.com
port: 587
username: [email protected]
password: sample2
to: [email protected]
subject: '{{ ansible_hostname }} configuration'
body: 'System {{ ansible_hostname }} has been successfully discovered.'
delegate_to: localhost
save_when: changed
...
I get the following error message when trying to run the following. Any idea why this is happening? I have switched out what is seen in the initial .yaml file provided with [ec2-instances] and there is still no difference in runtime result.
ansible-playbook -i /etc/ansible/hosts test2.yml --user ec2-user --private-key=/home/adam/Desktop/EC2CSR1000v.pem -vvv
ansible-playbook 2.7.9
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/adam/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0]
Using /etc/ansible/ansible.cfg as config file
/etc/ansible/hosts did not meet host_list requirements, check plugin documentation if this is unexpected
/etc/ansible/hosts did not meet script requirements, check plugin documentation if this is unexpected
Parsed /etc/ansible/hosts inventory source with ini plugin
ERROR! A malformed block was encountered while loading tasks
The error appears to have been in '/etc/ansible/scripts/test2.yml': line 2, column 4, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- hosts: [ec2-instance]
^ here