From 73ee9702dbdff271a1919ef05c086d1fbfe69b45 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sat, 3 Sep 2022 12:23:02 +0200 Subject: [PATCH] consul: add support for session token (#5193) (#5222) Signed-off-by: Wilfried Roset Signed-off-by: Wilfried Roset (cherry picked from commit feabe20c63b8845290baad674d55e439c4bf5445) Co-authored-by: wilfriedroset --- changelogs/fragments/5193-consul-session-token.yaml | 2 ++ plugins/modules/clustering/consul/consul_kv.py | 2 +- plugins/modules/clustering/consul/consul_session.py | 10 +++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/5193-consul-session-token.yaml diff --git a/changelogs/fragments/5193-consul-session-token.yaml b/changelogs/fragments/5193-consul-session-token.yaml new file mode 100644 index 0000000000..f58ded12f0 --- /dev/null +++ b/changelogs/fragments/5193-consul-session-token.yaml @@ -0,0 +1,2 @@ +minor_changes: + - consul_session - adds ``token`` parameter for session (https://github.com/ansible-collections/community.general/pull/5193). diff --git a/plugins/modules/clustering/consul/consul_kv.py b/plugins/modules/clustering/consul/consul_kv.py index 2b0391389a..ed64a86d18 100644 --- a/plugins/modules/clustering/consul/consul_kv.py +++ b/plugins/modules/clustering/consul/consul_kv.py @@ -279,7 +279,7 @@ def remove_value(module): data=existing) -def get_consul_api(module, token=None): +def get_consul_api(module): return consul.Consul(host=module.params.get('host'), port=module.params.get('port'), scheme=module.params.get('scheme'), diff --git a/plugins/modules/clustering/consul/consul_session.py b/plugins/modules/clustering/consul/consul_session.py index 7c664a0e55..6c06f9a139 100644 --- a/plugins/modules/clustering/consul/consul_session.py +++ b/plugins/modules/clustering/consul/consul_session.py @@ -101,6 +101,12 @@ options: - Specifies the duration of a session in seconds (between 10 and 86400). type: int version_added: 5.4.0 + token: + description: + - The token key identifying an ACL rule set that controls access to + the key value pair. + type: str + version_added: 5.6.0 ''' EXAMPLES = ''' @@ -241,7 +247,8 @@ def get_consul_api(module): return consul.Consul(host=module.params.get('host'), port=module.params.get('port'), scheme=module.params.get('scheme'), - verify=module.params.get('validate_certs')) + verify=module.params.get('validate_certs'), + token=module.params.get('token')) def test_dependencies(module): @@ -265,6 +272,7 @@ def main(): node=dict(type='str'), state=dict(type='str', default='present', choices=['absent', 'info', 'list', 'node', 'present']), datacenter=dict(type='str'), + token=dict(type='str', no_log=True), ) module = AnsibleModule(