Merge pull request #2931 from ryannealmes/ec2-vpc-subnet-fix
ec2_vpc creating/updating incorrect subnets
This commit is contained in:
commit
55932201a9
1 changed files with 29 additions and 28 deletions
|
@ -416,10 +416,11 @@ def create_vpc(module, vpc_conn):
|
||||||
add_subnet = False
|
add_subnet = False
|
||||||
|
|
||||||
# Check if AWS subnet tags are in playbook subnet tags
|
# Check if AWS subnet tags are in playbook subnet tags
|
||||||
subnet_tags_extra = (set(csn.tags.items()).issubset(set(new_subnet_tags.items())))
|
existing_tags_subset_of_new_tags = (set(csn.tags.items()).issubset(set(new_subnet_tags.items())))
|
||||||
# Check if subnet tags in playbook are in AWS subnet tags
|
# Check if subnet tags in playbook are in AWS subnet tags
|
||||||
subnet_tags_current = (set(new_subnet_tags.items()).issubset(set(csn.tags.items())))
|
new_tags_subset_of_existing_tags = (set(new_subnet_tags.items()).issubset(set(csn.tags.items())))
|
||||||
if subnet_tags_extra is False:
|
|
||||||
|
if existing_tags_subset_of_new_tags is False:
|
||||||
try:
|
try:
|
||||||
for item in csn.tags.items():
|
for item in csn.tags.items():
|
||||||
if item not in new_subnet_tags.items():
|
if item not in new_subnet_tags.items():
|
||||||
|
@ -431,8 +432,8 @@ def create_vpc(module, vpc_conn):
|
||||||
except EC2ResponseError, e:
|
except EC2ResponseError, e:
|
||||||
module.fail_json(msg='Unable to delete resource tag, error {0}'.format(e))
|
module.fail_json(msg='Unable to delete resource tag, error {0}'.format(e))
|
||||||
# Add new subnet tags if not current
|
# Add new subnet tags if not current
|
||||||
subnet_tags_current = (set(new_subnet_tags.items()).issubset(set(csn.tags.items())))
|
|
||||||
if subnet_tags_current is not True:
|
if new_tags_subset_of_existing_tags is False:
|
||||||
try:
|
try:
|
||||||
changed = True
|
changed = True
|
||||||
create_subnet_tag = vpc_conn.create_tags(csn.id, new_subnet_tags)
|
create_subnet_tag = vpc_conn.create_tags(csn.id, new_subnet_tags)
|
||||||
|
|
Loading…
Reference in a new issue