Add evaluate taget health for alias based records

This commit is contained in:
Mike Buzzetti 2015-11-18 13:08:21 -05:00
parent 2dba0d8d3a
commit b00e1b556c

View file

@ -64,6 +64,12 @@ options:
required: false required: false
version_added: "1.9" version_added: "1.9"
default: null default: null
alias_evaluate_target_health:
description:
- Whether or not to evaluate an alias target health. Useful for aliases to Elastic Load Balancers.
required: false
version_added: "2.0"
default: false
value: value:
description: description:
- The new value when creating a DNS record. Multiple comma-spaced values are allowed for non-alias records. When deleting a record all values for the record must be specified or Route53 will not delete it. - The new value when creating a DNS record. Multiple comma-spaced values are allowed for non-alias records. When deleting a record all values for the record must be specified or Route53 will not delete it.
@ -131,7 +137,9 @@ options:
required: false required: false
default: null default: null
version_added: "2.0" version_added: "2.0"
author: "Bruce Pennypacker (@bpennypacker)" author:
- "Bruce Pennypacker (@bpennypacker)"
- "Mike Buzzetti <mike.buzzetti@gmail.com>"
extends_documentation_fragment: aws extends_documentation_fragment: aws
''' '''
@ -194,6 +202,17 @@ EXAMPLES = '''
alias=True alias=True
alias_hosted_zone_id="{{ elb_zone_id }}" alias_hosted_zone_id="{{ elb_zone_id }}"
# Add an alias record that points to an Amazon ELB and evaluates it health:
- route53:
command=create
zone=foo.com
record=elb.foo.com
type=A
value="{{ elb_dns_name }}"
alias=True
alias_hosted_zone_id="{{ elb_zone_id }}"
alias_evaluate_target_health=True
# Add an AAAA record with Hosted Zone ID. Note that because there are colons in the value # Add an AAAA record with Hosted Zone ID. Note that because there are colons in the value
# that the entire parameter list must be quoted: # that the entire parameter list must be quoted:
- route53: - route53:
@ -291,6 +310,7 @@ 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),
alias = dict(required=False, type='bool'), alias = dict(required=False, type='bool'),
alias_hosted_zone_id = dict(required=False), alias_hosted_zone_id = dict(required=False),
alias_evaluate_target_health = dict(required=False, type='bool', default=False),
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),
@ -317,6 +337,7 @@ def main():
value_in = module.params.get('value') value_in = module.params.get('value')
alias_in = module.params.get('alias') alias_in = module.params.get('alias')
alias_hosted_zone_id_in = module.params.get('alias_hosted_zone_id') alias_hosted_zone_id_in = module.params.get('alias_hosted_zone_id')
alias_evaluate_target_health_in = module.params.get('alias_evaluate_target_health')
retry_interval_in = module.params.get('retry_interval') retry_interval_in = module.params.get('retry_interval')
private_zone_in = module.params.get('private_zone') private_zone_in = module.params.get('private_zone')
identifier_in = module.params.get('identifier') identifier_in = module.params.get('identifier')
@ -378,7 +399,7 @@ def main():
health_check=health_check_in, failover=failover_in) health_check=health_check_in, failover=failover_in)
for v in value_list: for v in value_list:
if alias_in: if alias_in:
wanted_rset.set_alias(alias_hosted_zone_id_in, v) wanted_rset.set_alias(alias_hosted_zone_id_in, v, alias_evaluate_target_health_in)
else: else:
wanted_rset.add_value(v) wanted_rset.add_value(v)
@ -413,6 +434,7 @@ def main():
record['value'] = rset.alias_dns_name record['value'] = rset.alias_dns_name
record['values'] = [rset.alias_dns_name] record['values'] = [rset.alias_dns_name]
record['alias_hosted_zone_id'] = rset.alias_hosted_zone_id record['alias_hosted_zone_id'] = rset.alias_hosted_zone_id
record['alias_evaluate_target_health'] = rset.alias_evaluate_target_health
else: else:
record['alias'] = False record['alias'] = False
record['value'] = ','.join(sorted(rset.resource_records)) record['value'] = ','.join(sorted(rset.resource_records))