Tagging a newly created VPC

61 views
Skip to first unread message

Chinmaya Patanaik

unread,
Apr 2, 2014, 5:49:48 AM4/2/14
to ansible...@googlegroups.com
Hi,

I created a vpc using ec2_vpc module. Now after the VPC is being created, I would like to tag it using ec2_tag module.

---
- name: Playbook to create an AWS VPC
  hosts: local
  connection: local
  tasks:
     - name: Creating a VPC
       action:
          module: ec2_vpc
          state: present
          aws_access_key: XXXX
          aws_secret_key: XXXX
          region: us-east-1
          cidr_block: 172.23.0.0/16
          instance_tenancy: default
          dns_hostnames: yes
          dns_support: yes
      register: new_vpc

 - name: Tag the newly Created VPC
   action:
     module: ec2_tag
         aws_access_key: XXXX
         aws_secret_key: XXXX
         region: us-east-1
         state: present
         resource: '{{item.id}}'
     args:
         tags:
            Name: TestVPC101
     with_items: new_vpc

But when I executed the playbook, the tagging task failed saying item resource not found.



James Cammarata

unread,
Apr 2, 2014, 1:06:03 PM4/2/14
to ansible...@googlegroups.com
You should use the "wait=yes" (or "wait: yes" in the form you've specified above) option to tell Ansible to wait until the VPC is in the "available" state before returning.


--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a9464844-698e-4164-bee4-76265eed413c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages