Skip to content

Commit

Permalink
Merge pull request #756 from tremble/route53/disable-healthcheck
Browse files Browse the repository at this point in the history
Add support for disabling route53 health checks

SUMMARY
Add support for disabling route53 health checks
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
route53_health_check
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
  • Loading branch information
ansible-zuul[bot] authored Oct 13, 2021
2 parents 503df4c + 96028dc commit cf4a95a
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/756-route53_health_check-disable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- route53_health_check - added support for disabling health checks (https://github.com/ansible-collections/community.aws/pull/756).
20 changes: 20 additions & 0 deletions plugins/modules/route53_health_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
choices: [ 'present', 'absent' ]
type: str
default: 'present'
disabled:
description:
- Stops Route 53 from performing health checks.
- See the AWS documentation for more details on the exact implications.
U(https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/health-checks-creating-values.html)
- Defaults to C(true) when creating a new health check.
type: bool
version_added: 2.1.0
ip_address:
description:
- IP address of the end-point to check. Either this or I(fqdn) has to be provided.
Expand Down Expand Up @@ -185,6 +193,11 @@
type: str
returned: When the health check exists and a search string has been configured.
sample: 'ALIVE'
disabled:
description: Whether the health check has been disabled or not.
type: bool
returned: When the health check exists.
sample: false
'''

import uuid
Expand Down Expand Up @@ -278,6 +291,8 @@ def create_health_check(ip_addr_in, fqdn_in, type_in, request_interval_in, port_
RequestInterval=request_interval_in,
Port=port_in,
)
if module.params.get('disabled') is not None:
health_check['Disabled'] = module.params.get('disabled')
if ip_addr_in:
health_check['IPAddress'] = ip_addr_in
if fqdn_in:
Expand Down Expand Up @@ -341,6 +356,10 @@ def update_health_check(existing_check):
if failure_threshold and failure_threshold != existing_config.get('FailureThreshold'):
changes['FailureThreshold'] = failure_threshold

disabled = module.params.get('disabled', None)
if disabled is not None and disabled != existing_config.get('Disabled'):
changes['Disabled'] = module.params.get('disabled')

# No changes...
if not changes:
return False, None
Expand Down Expand Up @@ -383,6 +402,7 @@ def describe_health_check(id):
def main():
argument_spec = dict(
state=dict(choices=['present', 'absent'], default='present'),
disabled=dict(type='bool'),
ip_address=dict(),
port=dict(type='int'),
type=dict(required=True, choices=['HTTP', 'HTTPS', 'HTTP_STR_MATCH', 'HTTPS_STR_MATCH', 'TCP']),
Expand Down
Loading

0 comments on commit cf4a95a

Please sign in to comment.