mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
consul: Always fail if no service_name was provided. (#25877)
Fixes a subtile bug introduced in PR #21737
This commit is contained in:
parent
754ef34acb
commit
bf73377394
2 changed files with 13 additions and 2 deletions
|
@ -389,8 +389,8 @@ def parse_service(module):
|
|||
module.params.get('service_port'),
|
||||
module.params.get('tags'),
|
||||
)
|
||||
elif module.params.get('service_port') and not module.params.get('service_name'):
|
||||
module.fail_json(msg="service_port supplied but no service_name, a name is required to configure a service.")
|
||||
elif not module.params.get('service_name'):
|
||||
module.fail_json(msg="service_name is required to configure a service.")
|
||||
|
||||
|
||||
class ConsulService():
|
||||
|
|
|
@ -47,6 +47,17 @@
|
|||
- basic2_result.service_id == 'service2'
|
||||
- basic2_result.service_name == 'Basic Service'
|
||||
|
||||
- name: register service without name
|
||||
consul:
|
||||
service_id: this_will_fail
|
||||
register: noname_result
|
||||
ignore_errors: True
|
||||
|
||||
- name: verify registering service without name fails
|
||||
assert:
|
||||
that:
|
||||
- noname_result | failed
|
||||
|
||||
- name: register very basic service without service_port
|
||||
consul:
|
||||
service_name: Basic Service Without Port
|
||||
|
|
Loading…
Reference in a new issue