idempotentcy using ec2_vpc ??

71 views
Skip to first unread message

Gregory Spranger

unread,
Jun 5, 2014, 3:39:50 PM6/5/14
to ansible...@googlegroups.com
hi all,

been testing out this fun module: http://docs.ansible.com/ec2_vpc_module.html

curious if anyone has figured out a way to have "idempotency" when creating a VPC using this module .. more specifically, our subnets and route tables do change, so i would prefer that after i update the play -- it would update the existing VPC and not create a new one .. below is my example code:


      local_action:
       
module: ec2_vpc
        aws_access_key
: yoyoma
        aws_secret_key
: mamayo
        state
: present
        cidr_block
: 10.169.0.0/16
        region
: us-east-1
        subnets
:
         
- cidr: 10.169.1.0/24
            az
: us-east-1b
         
- cidr: 10.169.2.0/24
            az
: us-east-1b
         
- cidr: 10.169.3.0/24
            az
: us-east-1b
        internet_gateway
: True
        route_tables
:
         
- subnets:
             
- 10.169.1.0/24
            routes
:
             
- dest: 0.0.0.0/0
                gw
: igw
     
register: vpc          


thanks !!
greg

Michael DeHaan

unread,
Jun 6, 2014, 8:43:59 AM6/6/14
to ansible...@googlegroups.com
"curious if anyone has figured out a way to have "idempotency" when creating a VPC using this module "

Idempotency is one of my least favorite words, because it's used in so many different ways by different people to mean many different things :)

Just to be sure, what is the above code block doing that you don't like?

Thanks!





--
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/9238e36a-e4e6-48b6-b234-aefb27517122%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gregory K. Spranger

unread,
Jun 6, 2014, 9:06:21 AM6/6/14
to ansible...@googlegroups.com
yeah -- i re-read what i wrote and cringed a little -- sorry about
that .. let me explain better what i am hoping for ..

#1 in my example play, it creates a VPC just fine .. problem is, if i
run it again -- with no changes to the code -- it will create a new
VPC with the same options .. i guess i am hoping it would not do that
(<< my definition of "idempotency" ;-) ..

#2 let's say i update example code with new subnet, i would *hope*
that it would update the existing VPC instead of creating a new one --
as it does now ..

mind you, my tests were pretty basic and i did not implement the use
of resource_tags or define a vpc_id (<< which i ASSumed is only for
deleting a VPC)


thanks,
greg
> https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgzTGWJswe8TJ-M2bXoAcZDZRw99v5wTJxFpJLSszcqifA%40mail.gmail.com.

Nathan Howell

unread,
Jun 6, 2014, 2:04:21 PM6/6/14
to ansible...@googlegroups.com
You'll want to add resource_tags... and read the comments for them in the documentation. :-)

Nathan

Gregory K. Spranger

unread,
Jun 6, 2014, 2:11:37 PM6/6/14
to ansible...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages