- hosts: localhost
connection: local
gather_facts: False
tasks:
- name: Provision a set of instances
ec2:
region: eu-central-1
key_name: some_aws_key
group: default
instance_type: t2.micro
image: ami-accff2b1
vpc_subnet_id: subnet-xxxxxxx
wait: yes
exact_count: 3
count_tag:
Name: Demo
instance_tags:
Name: Demo
test_tag: Demo
register: ec2_ip: yes
i - debug: var=ec2
- name: Add instances to host group
local_action: add_host hostname={{ item.public_ip }} groupname=my_group
with_items: ec2.instances
- name: Add tag to instances
local_action: ec2_tag resource={{
item.id }} region=eu-central-1 state=present
with_items: ec2.instances
args:
tags:
Name: EP2
- name: Add tag to instances
local_action: ec2_tag resource={{
item.id }} region=eu-central-1 state=present
with_items: ec2.instances
args:
tags:
Name: EP2