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ł:
>
> You should be able to register a var which will g

    - 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

et return info from 
> the module, I believe this includes new instance ids. 
>
> On Wed, Jun 10, 2015 at 3:08 AM, Yasser Hussain 
> <[email protected] <javascript:>> wrote: 
> > 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? 
> > 
> > -- 
> > 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] <javascript:>. 
> > To post to this group, send email to [email protected] 
> <javascript:>. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/ansible-project/f729cb81-8c6a-4c05-b8c7-97239fe22104%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
> Brian Coca 
>

-- 
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/17827c82-4728-4dbf-8454-a2503cd92891%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to