I created 4 instances using Ansible EC2 module. I want to give names as 
A,B,C,D. I want to give those names as "*with_items:* " loops. So what is 
the possible ways to modify the below code. I created 4 instances using "
*count:4". *


---
- 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: 1

  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.

>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2ed6daf7-1428-4a65-be34-8adcdce06979%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to