community.general.consul_kv – Manipulate entries in the key/value store of a consul cluster¶
Note
This plugin is part of the community.general collection (version 2.5.1).
To install it use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.consul_kv
.
Synopsis¶
Allows the retrieval, addition, modification and deletion of key/value entries in a consul cluster via the agent. The entire contents of the record, including the indices, flags and session are returned as
value
.If the
key
represents a prefix then note that when a value is removed, the existing value if any is returned as part of the results.See http://www.consul.io/docs/agent/http.html#kv for more details.
Requirements¶
The below requirements are needed on the host that executes this module.
python-consul
requests
Parameters¶
Examples¶
# If the key does not exist, the value associated to the "data" property in `retrieved_key` will be `None`
# If the key value is empty string, `retrieved_key["data"]["Value"]` will be `None`
- name: Retrieve a value from the key/value store
community.general.consul_kv:
key: somekey
register: retrieved_key
- name: Add or update the value associated with a key in the key/value store
community.general.consul_kv:
key: somekey
value: somevalue
- name: Remove a key from the store
community.general.consul_kv:
key: somekey
state: absent
- name: Add a node to an arbitrary group via consul inventory (see consul.ini)
community.general.consul_kv:
key: ansible/groups/dc1/somenode
value: top_secret
- name: Register a key/value pair with an associated session
community.general.consul_kv:
key: stg/node/server_birthday
value: 20160509
session: "{{ sessionid }}"
state: acquire
Authors¶
Steve Gargan (@sgargan)
Colin Nolan (@colin-nolan)