Ansible play book error ec2 setpu

498 views
Skip to first unread message

prasanna kumar

unread,
Mar 24, 2022, 6:16:29 AM3/24/22
to ansible...@googlegroups.com, dick....@geant.org
Dear dick,

 I have to install aws ec2 instances through ansible-playbook,I am getting this error,kindly help me



ERROR! A playbook must be a list of plays, got a <class 'ansible.parsing.yaml.objects.AnsibleMapping'> instead

The error appears to be in '/etc/ansible/task.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---
  Name: webserver
  ^ here


this is  code, kindly help me
---
  Name: webserver
  hosts: centos
  connection: local
  tasks:
   - name: launching ec2
     ec2:
     instance_type: t2.micro
     key_name: cgs
     image: ami-04be797e37992bf1e
     region: us-west-1
     group: default
     count: 1
     vpc_subnet_id: subnet-094c33691ee761fe0
     wait: yes
     assign_public_ip: yes
~




Thanks & regards,
Prasanna Kumar .S

Dick Visser

unread,
Mar 24, 2022, 9:03:42 AM3/24/22
to prasanna kumar, ansible...@googlegroups.com
 
Did you use MS Word or something to edit the yaml file?
The name key should be lower case.

Sent from a mobile device

From: prasanna kumar <prassu....@gmail.com>
Sent: Thursday, March 24, 2022 11:17:23 AM
To: ansible...@googlegroups.com <ansible...@googlegroups.com>; Dick Visser <dick....@geant.org>
Subject: Ansible play book error ec2 setpu
 

Amit Chettri

unread,
Mar 25, 2022, 8:08:57 AM3/25/22
to ansible...@googlegroups.com, dick....@geant.org
Your playbook syntax is not right  

Incorrect:
---
  Name: webserver
  hosts: centos
  connection: local
  tasks:

Correct way should be 
---
- name: webserver

  hosts: centos
  connection: local
  tasks:

Regards
Amit 

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAOf-3v5Z%2B6BALhG%3DWNbCBucxgHmsxb9%3D875RQO2OujgCR-9qSg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages