---
- name: Create a AWS instance
hosts: all
gather_facts: true
vars:
keypair: *************
instance_type: t2.micro
image: ami-b63769a1
region: us-east-1
tag_Type: "webserver"
tag_Environment: "production"
tag_name: {"A", "B", "C", "D"}
count: 4
tasks:
- name: Install python-setuptools using yum
yum: pkg=python-setuptools
- name: Launch EC2 instance
ec2:
key_name: "{{keypair}}"
group: default
count: "{{count}}"
instance_type: "{{instance_type}}"
instance_tags: '{"Name": "{{tag_name}}","Type":"{{tag_Type}}","Environment":"{{tag_Environment}}"}'
image: "{{image}}"
wait: true
region: "{{region}}"
# state: "stopped"
aws_access_key: *****************
aws_secret_key: ****************
register: ec2
with_items: tag_name
please help me to do it using with_item or any other way. Or suggest me similar playbooks for creating n instances.