community.general.consul_kv – Fetch metadata from a Consul key value store.¶
Note
This plugin is part of the community.general collection (version 1.3.6).
To install it use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.consul_kv
.
Synopsis¶
Lookup metadata for a playbook from the key value store in a Consul cluster. Values can be easily set in the kv store with simple rest commands
curl -X PUT -d 'some-value' http://localhost:8500/v1/kv/ansible/somedata
Requirements¶
The below requirements are needed on the local controller node that executes this lookup.
python-consul python library https://python-consul.readthedocs.io/en/latest/#installation
Parameters¶
Examples¶
- ansible.builtin.debug:
msg: 'key contains {{item}}'
with_community.general.consul_kv:
- 'key/to/retrieve'
- name: Parameters can be provided after the key be more specific about what to retrieve
ansible.builtin.debug:
msg: 'key contains {{item}}'
with_community.general.consul_kv:
- 'key/to recurse=true token=E6C060A9-26FB-407A-B83E-12DDAFCB4D98'
- name: retrieving a KV from a remote cluster on non default port
ansible.builtin.debug:
msg: "{{ lookup('community.general.consul_kv', 'my/key', host='10.10.10.10', port='2000') }}"
Return Values¶
Common return values are documented here, the following are the fields unique to this lookup:
Key | Returned | Description |
---|---|---|
_raw
dictionary
|
success |
Value(s) stored in consul.
|
Authors¶
Unknown (!UNKNOWN)