consul modules: update documentation (#56408)

* consul modules: Python 2.6 is always required on managed node, document all types, improve parameter descriptions, fix typos
* consul_kv: add doc for retrieve parameter
pull/56540/head
Pilou 5 years ago committed by Alicia Cozine
parent 7e997fdca2
commit 98246f6032

@ -24,16 +24,15 @@ description:
notify the health of the entire node to the cluster. notify the health of the entire node to the cluster.
Service level checks do not require a check name or id as these are derived Service level checks do not require a check name or id as these are derived
by Consul from the Service name and id respectively by appending 'service:' by Consul from the Service name and id respectively by appending 'service:'
Node level checks require a check_name and optionally a check_id." Node level checks require a I(check_name) and optionally a I(check_id)."
- Currently, there is no complete way to retrieve the script, interval or ttl - Currently, there is no complete way to retrieve the script, interval or ttl
metadata for a registered check. Without this metadata it is not possible to metadata for a registered check. Without this metadata it is not possible to
tell if the data supplied with ansible represents a change to a check. As a tell if the data supplied with ansible represents a change to a check. As a
result this does not attempt to determine changes and will always report a result this does not attempt to determine changes and will always report a
changed occurred. An api method is planned to supply this metadata so at that changed occurred. An API method is planned to supply this metadata so at that
stage change management will be added. stage change management will be added.
- "See http://consul.io for more details." - "See U(http://consul.io) for more details."
requirements: requirements:
- "python >= 2.6"
- python-consul - python-consul
- requests - requests
version_added: "2.0" version_added: "2.0"
@ -42,96 +41,112 @@ options:
state: state:
description: description:
- register or deregister the consul service, defaults to present - register or deregister the consul service, defaults to present
required: true default: present
choices: ['present', 'absent'] choices: ['present', 'absent']
service_name: service_name:
type: str
description: description:
- Unique name for the service on a node, must be unique per node, - Unique name for the service on a node, must be unique per node,
required if registering a service. May be omitted if registering required if registering a service. May be omitted if registering
a node level check a node level check
service_id: service_id:
type: str
description: description:
- the ID for the service, must be unique per node, defaults to the - the ID for the service, must be unique per node. If I(state=absent),
service name if the service name is supplied defaults to the service name if supplied.
default: service_name if supplied
host: host:
type: str
description: description:
- host of the consul agent defaults to localhost - host of the consul agent defaults to localhost
default: localhost default: localhost
port: port:
type: int
description: description:
- the port on which the consul agent is running - the port on which the consul agent is running
default: 8500 default: 8500
scheme: scheme:
type: str
description: description:
- the protocol scheme on which the consul agent is running - the protocol scheme on which the consul agent is running
default: http default: http
version_added: "2.1" version_added: "2.1"
validate_certs: validate_certs:
description: description:
- whether to verify the tls certificate of the consul agent - whether to verify the TLS certificate of the consul agent
type: bool type: bool
default: 'yes' default: 'yes'
version_added: "2.1" version_added: "2.1"
notes: notes:
type: str
description: description:
- Notes to attach to check when registering it. - Notes to attach to check when registering it.
service_port: service_port:
type: int
description: description:
- the port on which the service is listening. Can optionally be supplied for - the port on which the service is listening. Can optionally be supplied for
registration of a service, i.e. if service_name or service_id is set registration of a service, i.e. if I(service_name) or I(service_id) is set
service_address: service_address:
type: str
description: description:
- the address to advertise that the service will be listening on. - the address to advertise that the service will be listening on.
This value will be passed as the I(Address) parameter to Consul's This value will be passed as the I(address) parameter to Consul's
U(/v1/agent/service/register) API method, so refer to the Consul API U(/v1/agent/service/register) API method, so refer to the Consul API
documentation for further details. documentation for further details.
version_added: "2.1" version_added: "2.1"
tags: tags:
type: list
description: description:
- a list of tags that will be attached to the service registration. - tags that will be attached to the service registration.
script: script:
type: str
description: description:
- the script/command that will be run periodically to check the health - the script/command that will be run periodically to check the health
of the service. Scripts require an interval and vise versa of the service. Scripts require I(interval) and vice versa.
interval: interval:
type: str
description: description:
- the interval at which the service check will be run. This is a number - the interval at which the service check will be run. This is a number
with a s or m suffix to signify the units of seconds or minutes e.g with a s or m suffix to signify the units of seconds or minutes e.g
15s or 1m. If no suffix is supplied, m will be used by default e.g. C(15s) or C(1m). If no suffix is supplied, m will be used by default e.g.
1 will be 1m. Required if the script param is specified. C(1) will be C(1m). Required if the I(script) parameter is specified.
check_id: check_id:
type: str
description: description:
- an ID for the service check, defaults to the check name, ignored if - an ID for the service check. If I(state=absent), defaults to
part of a service definition. I(check_name). Ignored if part of a service definition.
check_name: check_name:
type: str
description: description:
- a name for the service check, defaults to the check id. required if - a name for the service check. Required if standalone, ignored if
standalone, ignored if part of service definition. part of service definition.
ttl: ttl:
type: str
description: description:
- checks can be registered with a ttl instead of a script and interval - checks can be registered with a ttl instead of a I(script) and I(interval)
this means that the service will check in with the agent before the this means that the service will check in with the agent before the
ttl expires. If it doesn't the check will be considered failed. ttl expires. If it doesn't the check will be considered failed.
Required if registering a check and the script an interval are missing Required if registering a check and the script an interval are missing
Similar to the interval this is a number with a s or m suffix to Similar to the interval this is a number with a s or m suffix to
signify the units of seconds or minutes e.g 15s or 1m. If no suffix signify the units of seconds or minutes e.g C(15s) or C(1m). If no suffix
is supplied, m will be used by default e.g. 1 will be 1m is supplied, C(m) will be used by default e.g. C(1) will be C(1m)
http: http:
type: str
description: description:
- checks can be registered with an http endpoint. This means that consul - checks can be registered with an HTTP endpoint. This means that consul
will check that the http endpoint returns a successful http status. will check that the http endpoint returns a successful HTTP status.
Interval must also be provided with this option. I(interval) must also be provided with this option.
version_added: "2.0" version_added: "2.0"
timeout: timeout:
type: str
description: description:
- A custom HTTP check timeout. The consul default is 10 seconds. - A custom HTTP check timeout. The consul default is 10 seconds.
Similar to the interval this is a number with a s or m suffix to Similar to the interval this is a number with a C(s) or C(m) suffix to
signify the units of seconds or minutes, e.g. 15s or 1m. signify the units of seconds or minutes, e.g. C(15s) or C(1m).
version_added: "2.0" version_added: "2.0"
token: token:
type: str
description: description:
- the token key indentifying an ACL rule set. May be required to register services. - the token key identifying an ACL rule set. May be required to register services.
""" """
EXAMPLES = ''' EXAMPLES = '''

@ -34,7 +34,7 @@ options:
default: present default: present
token_type: token_type:
description: description:
- the type of token that should be created, either management or client - the type of token that should be created
choices: ['client', 'management'] choices: ['client', 'management']
default: client default: client
name: name:
@ -48,8 +48,9 @@ options:
this will be a UUID this will be a UUID
required: false required: false
rules: rules:
type: list
description: description:
- a list of the rules that should be associated with a given token - rules that should be associated with a given token
required: false required: false
host: host:
description: description:
@ -57,6 +58,7 @@ options:
required: false required: false
default: localhost default: localhost
port: port:
type: int
description: description:
- the port on which the consul agent is running - the port on which the consul agent is running
required: false required: false
@ -68,13 +70,13 @@ options:
default: http default: http
version_added: "2.1" version_added: "2.1"
validate_certs: validate_certs:
type: bool
description: description:
- whether to verify the tls certificate of the consul agent - whether to verify the tls certificate of the consul agent
required: false required: false
default: True default: True
version_added: "2.1" version_added: "2.1"
requirements: requirements:
- "python >= 2.6"
- python-consul - python-consul
- pyhcl - pyhcl
- requests - requests
@ -469,7 +471,7 @@ class Configuration:
self.scheme = scheme # type: str self.scheme = scheme # type: str
self.validate_certs = validate_certs # type: bool self.validate_certs = validate_certs # type: bool
self.name = name # type: str self.name = name # type: str
self.port = port # type: bool self.port = port # type: int
self.rules = rules # type: RuleCollection self.rules = rules # type: RuleCollection
self.state = state # type: str self.state = state # type: str
self.token = token # type: str self.token = token # type: str

@ -19,12 +19,11 @@ short_description: Manipulate entries in the key/value store of a consul cluster
description: description:
- Allows the retrieval, addition, modification and deletion of key/value entries in a - 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 consul cluster via the agent. The entire contents of the record, including
the indices, flags and session are returned as 'value'. the indices, flags and session are returned as C(value).
- If the key represents a prefix then Note that when a value is removed, the existing - If the C(key) represents a prefix then note that when a value is removed, the existing
value if any is returned as part of the results. value if any is returned as part of the results.
- See http://www.consul.io/docs/agent/http.html#kv for more details. - See http://www.consul.io/docs/agent/http.html#kv for more details.
requirements: requirements:
- python >= 2.6
- python-consul - python-consul
- requests - requests
version_added: "2.0" version_added: "2.0"
@ -49,11 +48,13 @@ options:
key: key:
description: description:
- The key at which the value should be stored. - The key at which the value should be stored.
type: str
required: yes required: yes
value: value:
description: description:
- The value should be associated with the given key, required if C(state) - The value should be associated with the given key, required if C(state)
is C(present). is C(present).
type: str
required: yes required: yes
recurse: recurse:
description: description:
@ -61,34 +62,47 @@ options:
retrieved by setting this to C(yes). retrieved by setting this to C(yes).
type: bool type: bool
default: 'no' default: 'no'
retrieve:
description:
- If the I(state) is C(present) and I(value) is set, perform a
read after setting the value and return this value.
default: True
type: bool
session: session:
description: description:
- The session that should be used to acquire or release a lock - The session that should be used to acquire or release a lock
associated with a key/value pair. associated with a key/value pair.
type: str
token: token:
description: description:
- The token key indentifying an ACL rule set that controls access to - The token key indentifying an ACL rule set that controls access to
the key value pair the key value pair
type: str
cas: cas:
description: description:
- Used when acquiring a lock with a session. If the C(cas) is C(0), then - Used when acquiring a lock with a session. If the C(cas) is C(0), then
Consul will only put the key if it does not already exist. If the Consul will only put the key if it does not already exist. If the
C(cas) value is non-zero, then the key is only set if the index matches C(cas) value is non-zero, then the key is only set if the index matches
the ModifyIndex of that key. the ModifyIndex of that key.
type: str
flags: flags:
description: description:
- Opaque integer value that can be passed when setting a value. - Opaque positive integer value that can be passed when setting a value.
type: str
host: host:
description: description:
- Host of the consul agent. - Host of the consul agent.
type: str
default: localhost default: localhost
port: port:
description: description:
- The port on which the consul agent is running. - The port on which the consul agent is running.
type: int
default: 8500 default: 8500
scheme: scheme:
description: description:
- The protocol scheme on which the consul agent is running. - The protocol scheme on which the consul agent is running.
type: str
default: http default: http
version_added: "2.1" version_added: "2.1"
validate_certs: validate_certs:

@ -309,9 +309,6 @@ lib/ansible/modules/cloud/vmware/vmware_guest.py E322
lib/ansible/modules/cloud/vmware/vsphere_copy.py E322 lib/ansible/modules/cloud/vmware/vsphere_copy.py E322
lib/ansible/modules/cloud/vmware/vsphere_copy.py E309 lib/ansible/modules/cloud/vmware/vsphere_copy.py E309
lib/ansible/modules/clustering/consul.py E322 lib/ansible/modules/clustering/consul.py E322
lib/ansible/modules/clustering/consul.py E324
lib/ansible/modules/clustering/consul_kv.py E322
lib/ansible/modules/clustering/consul_kv.py E324
lib/ansible/modules/clustering/consul_session.py E322 lib/ansible/modules/clustering/consul_session.py E322
lib/ansible/modules/clustering/etcd3.py E326 lib/ansible/modules/clustering/etcd3.py E326
lib/ansible/modules/clustering/znode.py E326 lib/ansible/modules/clustering/znode.py E326

Loading…
Cancel
Save