From 26fe42776c4205e9cd5d701f93320b9b2981cbe9 Mon Sep 17 00:00:00 2001 From: raspbeguy Date: Sat, 19 Oct 2024 12:49:18 +0200 Subject: [PATCH] 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 --------- Co-authored-by: Felix Fontein --- changelogs/fragments/9026-consul_kv-datacenter.yml | 2 ++ plugins/modules/consul_kv.py | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/9026-consul_kv-datacenter.yml diff --git a/changelogs/fragments/9026-consul_kv-datacenter.yml b/changelogs/fragments/9026-consul_kv-datacenter.yml new file mode 100644 index 0000000000..73ddd69266 --- /dev/null +++ b/changelogs/fragments/9026-consul_kv-datacenter.yml @@ -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). diff --git a/plugins/modules/consul_kv.py b/plugins/modules/consul_kv.py index 84169fc6b7..fd3a1fce06 100644 --- a/plugins/modules/consul_kv.py +++ b/plugins/modules/consul_kv.py @@ -111,6 +111,12 @@ options: - Whether to verify the tls certificate of the consul agent. type: bool 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'), scheme=module.params.get('scheme'), 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): @@ -305,6 +312,7 @@ def main(): module = AnsibleModule( argument_spec=dict( cas=dict(type='str'), + datacenter=dict(type='str', default=None), flags=dict(type='str'), key=dict(type='str', required=True, no_log=False), host=dict(type='str', default='localhost'),