ansible / ansible.builtin / v2.6.10 / lookup / consul_kv Fetch metadata from a Consul key value store. | "added in version" 1.9 of ansible.builtin" Authors: unknownansible.builtin.consul_kv (v2.6.10) — lookup
pip
Install with pip install ansible==2.6.10
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
C(curl -X PUT -d 'some-value' http://localhost:8500/v1/kv/ansible/somedata)
- debug: msg: 'key contains {{item}}' with_consul_kv: - 'key/to/retrieve'
- name: Parameters can be provided after the key be more specific about what to retrieve debug: msg: 'key contains {{item}}' with_consul_kv: - 'key/to recurse=true token=E6C060A9-26FB-407A-B83E-12DDAFCB4D98'
- name: retrieving a KV from a remote cluster on non default port debug: msg: "{{ lookup('consul_kv', 'my/key', host='10.10.10.10', port='2000') }}"
_raw: description: List of key(s) to retrieve. required: true type: list host: default: localhost description: - The target to connect to, must be a resolvable address. env: - name: ANSIBLE_CONSUL_URL port: default: 8500 description: The port of the target host to connect to. index: description: If the key has a value with the specified index then this is returned allowing access to historical values. token: description: The acl token to allow access to restricted values. recurse: default: false description: If true, will retrieve all the values that have the given key as prefix. type: boolean
_raw: description: - Value(s) stored in consul.