I have provisioned an amazon instance using ec2 module. Now I need to do some more manipulation on the instance. So does ansible get a handle on the instance it just created?
Hi,
Hope these links help.
http://docs.ansible.com/guide_aws.html
https://github.com/ansible/ansible-examples/blob/master/language_features/eucalyptus-ec2.yml
You should be able to register a var which will get return info from
the module, I believe this includes new instance ids.
A quick example
- 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
W dniu środa, 10 czerwca 2015 16:54:53 UTC+2 użytkownik Brian Coca napisał: