Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for disabling route53 health checks #756

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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