community / community.general / 8.5.0 / lookup / consul_kv Fetch metadata from a Consul key value store. Authors: Unknown (!UNKNOWN)community.general.consul_kv (8.5.0) — lookup
Install with ansible-galaxy collection install community.general:==8.5.0
collections: - name: community.general version: 8.5.0
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)
- 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') }}"
url: description: - The target to connect to. - 'Should look like this: V(https://my.consul.server:8500).' env: - name: ANSIBLE_CONSUL_URL ini: - key: url section: lookup_consul type: str version_added: 1.0.0 version_added_collection: community.general _raw: description: List of key(s) to retrieve. elements: string type: list host: default: localhost description: - The target to connect to, must be a resolvable address. - Will be determined from E(ANSIBLE_CONSUL_URL) if that is set. ini: - key: host section: lookup_consul port: default: 8500 description: - The port of the target host to connect to. - If you use E(ANSIBLE_CONSUL_URL) this value will be used from there. 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. scheme: default: http description: - Whether to use http or https. - If you use E(ANSIBLE_CONSUL_URL) this value will be used from there. recurse: default: false description: If true, will retrieve all the values that have the given key as prefix. type: boolean datacenter: description: - Retrieve the key from a consul datacenter other than the default for the consul host. client_cert: description: The client cert to verify the ssl connection. env: - name: ANSIBLE_CONSUL_CLIENT_CERT ini: - key: client_cert section: lookup_consul validate_certs: default: true description: Whether to verify the ssl connection or not. env: - name: ANSIBLE_CONSUL_VALIDATE_CERTS ini: - key: validate_certs section: lookup_consul
_raw: description: - Value(s) stored in consul. type: dict