consul: Always fail if no service_name was provided. (#25877)

Fixes a subtile bug introduced in PR #21737
pull/28816/merge
Steffen Neubauer 7 years ago committed by ansibot
parent 754ef34acb
commit bf73377394

@ -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…
Cancel
Save