Skip to content

Commit

Permalink
consul: add support for session token (ansible-collections#5193)
Browse files Browse the repository at this point in the history
Signed-off-by: Wilfried Roset <wilfriedroset@users.noreply.github.com>

Signed-off-by: Wilfried Roset <wilfriedroset@users.noreply.github.com>
  • Loading branch information
wilfriedroset authored and Dušan Markovič committed Nov 7, 2022
1 parent 78e97ef commit cfe69a1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/5193-consul-session-token.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- consul_session - adds ``token`` parameter for session (https://github.com/ansible-collections/community.general/pull/5193).
2 changes: 1 addition & 1 deletion plugins/modules/clustering/consul/consul_kv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
10 changes: 9 additions & 1 deletion plugins/modules/clustering/consul/consul_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@
- 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 = '''
Expand Down Expand Up @@ -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):
Expand All @@ -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(
Expand Down

0 comments on commit cfe69a1

Please sign in to comment.