Added Overwrite option for Route53 record creation
This commit is contained in:
parent
d59b5d4c7c
commit
8fc13062aa
1 changed files with 16 additions and 1 deletions
|
@ -72,6 +72,12 @@ options:
|
|||
required: false
|
||||
default: null
|
||||
aliases: []
|
||||
overwrite:
|
||||
description:
|
||||
- Whether an existing record should be overwritten on create if values do not match
|
||||
required: false
|
||||
default: null
|
||||
aliases: []
|
||||
requirements: [ "boto" ]
|
||||
author: Bruce Pennypacker
|
||||
'''
|
||||
|
@ -133,7 +139,8 @@ def main():
|
|||
type = dict(choices=['A', 'CNAME', 'MX', 'AAAA', 'TXT', 'PTR', 'SRV', 'SPF', 'NS'], required=True),
|
||||
value = dict(required=False),
|
||||
ec2_secret_key = dict(aliases=['EC2_SECRET_KEY'], no_log=True, required=False),
|
||||
ec2_access_key = dict(aliases=['EC2_ACCESS_KEY'], required=False)
|
||||
ec2_access_key = dict(aliases=['EC2_ACCESS_KEY'], required=False),
|
||||
overwrite = dict(required=False, choices=BOOLEANS, type='bool')
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -212,6 +219,14 @@ def main():
|
|||
|
||||
changes = ResourceRecordSets(conn, zones[zone_in])
|
||||
|
||||
if command_in == 'create' and found_record:
|
||||
if not module.params['overwrite']:
|
||||
module.fail_json(msg = "Record already exists with different value. Set 'overwrite' to replace it")
|
||||
else:
|
||||
change = changes.add_change("DELETE", record_in, type_in, ttl_in)
|
||||
for v in record['values']:
|
||||
change.add_value(v)
|
||||
|
||||
if command_in == 'create' or command_in == 'delete':
|
||||
change = changes.add_change(command_in.upper(), record_in, type_in, ttl_in)
|
||||
for v in value_list:
|
||||
|
|
Loading…
Reference in a new issue