consul_kv: add argument for the datacenter option on consul api (#9026)

* consul_kv: add argument for the datacenter option on consul api

* changelog: add fragment for #9026

* Apply suggestions from code review

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
pull/9040/head
raspbeguy 2024-10-19 12:49:18 +02:00 committed by GitHub
parent 5874711c6e
commit 26fe42776c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -0,0 +1,2 @@
minor_changes:
- consul_kv - add argument for the datacenter option on Consul API (https://github.com/ansible-collections/community.general/pull/9026).

View File

@ -111,6 +111,12 @@ options:
- Whether to verify the tls certificate of the consul agent. - Whether to verify the tls certificate of the consul agent.
type: bool type: bool
default: true default: true
datacenter:
description:
- The name of the datacenter to query. If unspecified, the query will default
to the datacenter of the Consul agent on O(host).
type: str
version_added: 10.0.0
''' '''
@ -291,7 +297,8 @@ def get_consul_api(module):
port=module.params.get('port'), port=module.params.get('port'),
scheme=module.params.get('scheme'), scheme=module.params.get('scheme'),
verify=module.params.get('validate_certs'), verify=module.params.get('validate_certs'),
token=module.params.get('token')) token=module.params.get('token'),
dc=module.params.get('datacenter'))
def test_dependencies(module): def test_dependencies(module):
@ -305,6 +312,7 @@ def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
cas=dict(type='str'), cas=dict(type='str'),
datacenter=dict(type='str', default=None),
flags=dict(type='str'), flags=dict(type='str'),
key=dict(type='str', required=True, no_log=False), key=dict(type='str', required=True, no_log=False),
host=dict(type='str', default='localhost'), host=dict(type='str', default='localhost'),