Add private_zone parameter for route53

Fixes #473
This commit is contained in:
James Cammarata 2015-02-26 21:35:10 -06:00
parent f38a8561a5
commit fafb93490c

View file

@ -84,6 +84,12 @@ options:
required: false required: false
default: 500 default: 500
aliases: [] aliases: []
private_zone:
description:
- If set to true, the private zone matching the requested name within the domain will be used if there are both public and private zones. The default is to use the public zone.
required: false
default: false
version_added: "1.9"
requirements: [ "boto" ] requirements: [ "boto" ]
author: Bruce Pennypacker author: Bruce Pennypacker
''' '''
@ -175,7 +181,8 @@ def main():
type = dict(choices=['A', 'CNAME', 'MX', 'AAAA', 'TXT', 'PTR', 'SRV', 'SPF', 'NS'], required=True), type = dict(choices=['A', 'CNAME', 'MX', 'AAAA', 'TXT', 'PTR', 'SRV', 'SPF', 'NS'], required=True),
value = dict(required=False), value = dict(required=False),
overwrite = dict(required=False, type='bool'), overwrite = dict(required=False, type='bool'),
retry_interval = dict(required=False, default=500) retry_interval = dict(required=False, default=500),
private_zone = dict(required=False, type='bool', default=False),
) )
) )
module = AnsibleModule(argument_spec=argument_spec) module = AnsibleModule(argument_spec=argument_spec)
@ -187,6 +194,7 @@ def main():
type_in = module.params.get('type') type_in = module.params.get('type')
value_in = module.params.get('value') value_in = module.params.get('value')
retry_interval_in = module.params.get('retry_interval') retry_interval_in = module.params.get('retry_interval')
private_zone_in = module.params.get('private_zone')
ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module) ec2_url, aws_access_key, aws_secret_key, region = get_ec2_creds(module)
@ -218,8 +226,11 @@ def main():
zones = {} zones = {}
results = conn.get_all_hosted_zones() results = conn.get_all_hosted_zones()
for r53zone in results['ListHostedZonesResponse']['HostedZones']: for r53zone in results['ListHostedZonesResponse']['HostedZones']:
zone_id = r53zone['Id'].replace('/hostedzone/', '') # only save this zone id if the private status of the zone matches
zones[r53zone['Name']] = zone_id # the private_zone_in boolean specified in the params
if module.boolean(r53zone['Config']['PrivateZone']) == private_zone_in:
zone_id = r53zone['Id'].replace('/hostedzone/', '')
zones[r53zone['Name']] = zone_id
# Verify that the requested zone is already defined in Route53 # Verify that the requested zone is already defined in Route53
if not zone_in in zones: if not zone_in in zones: