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

consul: deprecate params incompatible with state=absent #5772

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deprecated_features:
- consul - deprecate using parameters unused for ``state=absent`` (https://github.com/ansible-collections/community.general/pull/5772).
26 changes: 23 additions & 3 deletions plugins/modules/consul.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@
type: str
description:
- The token key identifying an ACL rule set. May be required to register services.
ack_params_state_absent:
type: bool
description:
- Disable deprecation warning when using parameters incompatible with I(state=absent).
'''

EXAMPLES = '''
Expand Down Expand Up @@ -584,22 +588,38 @@ def main():
http=dict(type='str'),
timeout=dict(type='str'),
tags=dict(type='list', elements='str'),
token=dict(no_log=True)
token=dict(no_log=True),
ack_params_state_absent=dict(type='bool'),
),
required_if=[
('state', 'present', ['service_name']),
('state', 'absent', ['service_id', 'service_name', 'check_id', 'check_name'], True),
],
supports_check_mode=False,
)
p = module.params

test_dependencies(module)
if p['state'] == 'absent' and any(p[x] for x in ['script', 'ttl', 'tcp', 'http', 'interval']) and not p['ack_params_state_absent']:
module.deprecate(
"The use of parameters 'script', 'ttl', 'tcp', 'http', 'interval' along with 'state=absent' is deprecated. "
"In community.general 8.0.0 their use will become an error. "
"To suppress this deprecation notice, set parameter ack_params_state_absent=true.",
version="8.0.0",
collection_name="community.general",
)
# When reaching c.g 8.0.0:
# - Replace the deprecation with a fail_json(), remove the "ack_params_state_absent" condition from the "if"
# - Add mutually_exclusive for ('script', 'ttl', 'tcp', 'http'), then remove that validation from parse_check()
# - Add required_by {'script': 'interval', 'http': 'interval', 'tcp': 'interval'}, then remove checks for 'interval' in ConsulCheck.__init__()
# - Deprecate the parameter ack_params_state_absent

try:
register_with_consul(module)
except SystemExit:
raise
except ConnectionError as e:
module.fail_json(msg='Could not connect to consul agent at %s:%s, error was %s' % (
module.params['host'], module.params['port'], str(e)))
module.fail_json(msg='Could not connect to consul agent at %s:%s, error was %s' % (p['host'], p['port'], str(e)))
except Exception as e:
module.fail_json(msg=str(e))

Expand Down