Below is my ansible code
<code>- name: EC2 Creation
hosts: localhost
tasks:
ec2_instance:
# amazon.aws.ec2_instance:
region: ap-south-1
instance_type: t2.micro
image_id: ami-022ce6f32988af5fa
count: 1
wait: yes
tags:
name: Test
vpc_subnet_id: subnet-078e0bc5c6d3d2d66
network:
assign_public_ip: true
key_name: linux
secutiry_group: ALL_TCP
</code>
<code>- name: EC2 Creation
hosts: localhost
tasks:
ec2_instance:
# amazon.aws.ec2_instance:
region: ap-south-1
instance_type: t2.micro
image_id: ami-022ce6f32988af5fa
count: 1
wait: yes
tags:
name: Test
vpc_subnet_id: subnet-078e0bc5c6d3d2d66
network:
assign_public_ip: true
key_name: linux
secutiry_group: ALL_TCP
</code>
- name: EC2 Creation
hosts: localhost
tasks:
ec2_instance:
# amazon.aws.ec2_instance:
region: ap-south-1
instance_type: t2.micro
image_id: ami-022ce6f32988af5fa
count: 1
wait: yes
tags:
name: Test
vpc_subnet_id: subnet-078e0bc5c6d3d2d66
network:
assign_public_ip: true
key_name: linux
secutiry_group: ALL_TCP
While using this to create ec2 instance, getting below error
<code>[WARNING]: Found both group and host with same name: localhost
ERROR! A malformed block was encountered while loading tasks: {'ec2_instance':
{'region': 'ap-south-1', 'instance_type': 't2.micro', 'image_id':
'ami-022ce6f32988af5fa', 'count': 1, 'wait': True, 'tags': {'name': 'Test'},
'vpc_subnet_id': 'subnet-078e0bc5c6d3d2d66', 'network': {'assign_public_ip':
True}, 'key_name': 'linux', 'secutiry_group': 'ALL_TCP'}} should be a list or
None but is <class 'ansible.parsing.yaml.objects.AnsibleMapping'>
The error appears to be in '/root/ec2.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: EC2 Creation
^ here
</code>
<code>[WARNING]: Found both group and host with same name: localhost
ERROR! A malformed block was encountered while loading tasks: {'ec2_instance':
{'region': 'ap-south-1', 'instance_type': 't2.micro', 'image_id':
'ami-022ce6f32988af5fa', 'count': 1, 'wait': True, 'tags': {'name': 'Test'},
'vpc_subnet_id': 'subnet-078e0bc5c6d3d2d66', 'network': {'assign_public_ip':
True}, 'key_name': 'linux', 'secutiry_group': 'ALL_TCP'}} should be a list or
None but is <class 'ansible.parsing.yaml.objects.AnsibleMapping'>
The error appears to be in '/root/ec2.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: EC2 Creation
^ here
</code>
[WARNING]: Found both group and host with same name: localhost
ERROR! A malformed block was encountered while loading tasks: {'ec2_instance':
{'region': 'ap-south-1', 'instance_type': 't2.micro', 'image_id':
'ami-022ce6f32988af5fa', 'count': 1, 'wait': True, 'tags': {'name': 'Test'},
'vpc_subnet_id': 'subnet-078e0bc5c6d3d2d66', 'network': {'assign_public_ip':
True}, 'key_name': 'linux', 'secutiry_group': 'ALL_TCP'}} should be a list or
None but is <class 'ansible.parsing.yaml.objects.AnsibleMapping'>
The error appears to be in '/root/ec2.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: EC2 Creation
^ here
Can anyone help me here
2