ansible / ansible.builtin / v2.7.18 / 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.7.18) — lookup
pip
Install with pip install ansible==2.7.18
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. Will be determined from C(ANSIBLE_CONSUL_URL) if that is set. - 'C(ANSIBLE_CONSUL_URL) should look like this: C(https://my.consul.server:8500)' env: - name: ANSIBLE_CONSUL_URL ini: - key: host section: lookup_consul version_added: '2.8' version_added_collection: ansible.builtin port: default: 8500 description: - The port of the target host to connect to. - If you use C(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 C(ANSIBLE_CONSUL_URL) this value will be used from there. version_added: '2.8' version_added_collection: ansible.builtin recurse: default: false description: If true, will retrieve all the values that have the given key as prefix. type: boolean client_cert: default: None description: The client cert to verify the ssl connection. env: - name: ANSIBLE_CONSUL_CLIENT_CERT ini: - key: client_cert section: lookup_consul version_added: '2.8' version_added_collection: ansible.builtin 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 version_added: '2.8' version_added_collection: ansible.builtin
_raw: description: - Value(s) stored in consul.