documentation tweaks to fix missing arguments and specification of defaults
This commit is contained in:
parent
b5faf88494
commit
e1ff0feb58
4 changed files with 143 additions and 47 deletions
|
@ -24,19 +24,19 @@ short_description: "Add, modify & delete services within a consul cluster.
|
||||||
description:
|
description:
|
||||||
- registers services and checks for an agent with a consul cluster. A service
|
- registers services and checks for an agent with a consul cluster. A service
|
||||||
is some process running on the agent node that should be advertised by
|
is some process running on the agent node that should be advertised by
|
||||||
consul's discovery mechanism. It may optionally supply a check definition
|
consul's discovery mechanism. It may optionally supply a check definition,
|
||||||
that will be used to notify the consul cluster of the health of the service.
|
a periodic service test to notify the consul cluster of service's health.
|
||||||
Checks may also be registered per node e.g. disk usage, or cpu usage and
|
Checks may also be registered per node e.g. disk usage, or cpu usage and
|
||||||
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 Currently,
|
Node level checks require a check_name and optionally a check_id.
|
||||||
there is no complete way to retrieve the script, interval or ttl metadata for
|
Currently, there is no complete way to retrieve the script, interval or ttl
|
||||||
a registered check. Without this metadata it is not possible to tell if
|
metadata for a registered check. Without this metadata it is not possible to
|
||||||
the data supplied with ansible represents a change to a check. As a result
|
tell if the data supplied with ansible represents a change to a check. As a
|
||||||
this does not attempt to determine changes and will always report a changed
|
result this does not attempt to determine changes and will always report a
|
||||||
occurred. An api method is planned to supply this metadata so at that stage
|
changed occurred. An api method is planned to supply this metadata so at that
|
||||||
change management will be added.
|
stage change management will be added.
|
||||||
version_added: "1.9"
|
version_added: "1.9"
|
||||||
author: Steve Gargan (steve.gargan@gmail.com)
|
author: Steve Gargan (steve.gargan@gmail.com)
|
||||||
options:
|
options:
|
||||||
|
@ -45,71 +45,105 @@ options:
|
||||||
- register or deregister the consul service, defaults to present
|
- register or deregister the consul service, defaults to present
|
||||||
required: true
|
required: true
|
||||||
choices: ['present', 'absent']
|
choices: ['present', 'absent']
|
||||||
service_id:
|
|
||||||
description:
|
|
||||||
- the ID for the service, must be unique per node, defaults to the
|
|
||||||
service name
|
|
||||||
required: false
|
|
||||||
host:
|
|
||||||
description:
|
|
||||||
- host of the consul agent with which to register the service,
|
|
||||||
defaults to localhost
|
|
||||||
required: false
|
|
||||||
notes:
|
|
||||||
description:
|
|
||||||
- Notes to attach to check when registering it.
|
|
||||||
service_name:
|
service_name:
|
||||||
desciption:
|
desciption:
|
||||||
- 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 ommitted if registering
|
required if registering a service. May be ommitted if registering
|
||||||
a node level check
|
a node level check
|
||||||
required: false
|
required: false
|
||||||
|
service_id:
|
||||||
|
description:
|
||||||
|
- the ID for the service, must be unique per node, defaults to the
|
||||||
|
service name if the service name is supplied
|
||||||
|
required: false
|
||||||
|
default: service_name if supplied
|
||||||
|
host:
|
||||||
|
description:
|
||||||
|
- host of the consul agent defaults to localhost
|
||||||
|
required: false
|
||||||
|
default: localhost
|
||||||
|
port:
|
||||||
|
description:
|
||||||
|
- the port on which the consul agent is running
|
||||||
|
required: false
|
||||||
|
default: 8500
|
||||||
|
notes:
|
||||||
|
description:
|
||||||
|
- Notes to attach to check when registering it.
|
||||||
|
required: false
|
||||||
|
default: None
|
||||||
service_port:
|
service_port:
|
||||||
description:
|
description:
|
||||||
- the port on which the service is listening required for
|
- the port on which the service is listening required for
|
||||||
registration of a service.
|
registration of a service, i.e. if service_name or service_id is set
|
||||||
required: true
|
required: false
|
||||||
tags:
|
tags:
|
||||||
description:
|
description:
|
||||||
- a list of tags that will be attached to the service registration.
|
- a list of tags that will be attached to the service registration.
|
||||||
required: false
|
required: false
|
||||||
|
default: None
|
||||||
script:
|
script:
|
||||||
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
|
of the service. Scripts require an interval and vise versa
|
||||||
required: false
|
required: false
|
||||||
|
default: None
|
||||||
interval:
|
interval:
|
||||||
description:
|
description:
|
||||||
- the interval at which the service check will be run. This is by
|
- the interval at which the service check will be run. This is a number
|
||||||
convention a number with a s or m to signify the units of seconds
|
with a s or m suffix to signify the units of seconds or minutes e.g
|
||||||
or minutes. if none is supplied, m will be appended
|
15s or 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.
|
||||||
|
required: false
|
||||||
|
default: None
|
||||||
check_id:
|
check_id:
|
||||||
description:
|
description:
|
||||||
- an ID for the service check, defaults to the check name, ignored if
|
- an ID for the service check, defaults to the check name, ignored if
|
||||||
part of service definition.
|
part of a service definition.
|
||||||
|
required: false
|
||||||
|
default: None
|
||||||
check_name:
|
check_name:
|
||||||
description:
|
description:
|
||||||
- a name for the service check, defaults to the check id. required if
|
- a name for the service check, defaults to the check id. required if
|
||||||
standalone, ignored if part of service definition.
|
standalone, ignored if part of service definition.
|
||||||
|
required: false
|
||||||
|
default: None
|
||||||
|
ttl:
|
||||||
|
description:
|
||||||
|
- checks can be registered with a ttl instead of a script and interval
|
||||||
|
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.
|
||||||
|
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
|
||||||
|
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. 1 will be 1m
|
||||||
|
required: false
|
||||||
|
default: None
|
||||||
|
token:
|
||||||
|
description:
|
||||||
|
- the token key indentifying an ACL rule set. May be required to
|
||||||
|
register services.
|
||||||
|
required: false
|
||||||
|
default: None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
- name: register nginx service with the local consul agent
|
- name: register nginx service with the local consul agent
|
||||||
consul:
|
consul:
|
||||||
name: nginx
|
name: nginx
|
||||||
port: 80
|
service_port: 80
|
||||||
|
|
||||||
- name: register nginx service with curl check
|
- name: register nginx service with curl check
|
||||||
consul:
|
consul:
|
||||||
name: nginx
|
name: nginx
|
||||||
port: 80
|
service_port: 80
|
||||||
script: "curl http://localhost"
|
script: "curl http://localhost"
|
||||||
interval: 60s
|
interval: 60s
|
||||||
|
|
||||||
- name: register nginx with some service tags
|
- name: register nginx with some service tags
|
||||||
consul:
|
consul:
|
||||||
name: nginx
|
name: nginx
|
||||||
port: 80
|
service_port: 80
|
||||||
tags:
|
tags:
|
||||||
- prod
|
- prod
|
||||||
- webservers
|
- webservers
|
||||||
|
@ -432,23 +466,22 @@ class ConsulCheck():
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
|
host=dict(default='localhost'),
|
||||||
|
port=dict(default=8500, type='int'),
|
||||||
check_id=dict(required=False),
|
check_id=dict(required=False),
|
||||||
check_name=dict(required=False),
|
check_name=dict(required=False),
|
||||||
host=dict(default='localhost'),
|
|
||||||
interval=dict(required=False, type='str'),
|
|
||||||
ttl=dict(required=False, type='str'),
|
|
||||||
check_node=dict(required=False),
|
check_node=dict(required=False),
|
||||||
check_host=dict(required=False),
|
check_host=dict(required=False),
|
||||||
notes=dict(required=False),
|
notes=dict(required=False),
|
||||||
port=dict(default=8500, type='int'),
|
|
||||||
script=dict(required=False),
|
script=dict(required=False),
|
||||||
service_id=dict(required=False),
|
service_id=dict(required=False),
|
||||||
service_name=dict(required=False),
|
service_name=dict(required=False),
|
||||||
service_port=dict(required=False, type='int'),
|
service_port=dict(required=False, type='int'),
|
||||||
state=dict(default='present', choices=['present', 'absent']),
|
state=dict(default='present', choices=['present', 'absent']),
|
||||||
|
interval=dict(required=False, type='str'),
|
||||||
|
ttl=dict(required=False, type='str'),
|
||||||
tags=dict(required=False, type='list'),
|
tags=dict(required=False, type='list'),
|
||||||
token=dict(required=False),
|
token=dict(required=False)
|
||||||
url=dict(default='http://localhost:8500')
|
|
||||||
),
|
),
|
||||||
supports_check_mode=False,
|
supports_check_mode=False,
|
||||||
)
|
)
|
||||||
|
|
|
@ -22,7 +22,8 @@ module: consul_acl
|
||||||
short_description: "manipulate consul acl keys and rules"
|
short_description: "manipulate consul acl keys and rules"
|
||||||
description:
|
description:
|
||||||
- allows the addition, modification and deletion of ACL keys and associated
|
- allows the addition, modification and deletion of ACL keys and associated
|
||||||
rules in a consul cluster via the agent.
|
rules in a consul cluster via the agent. For more details on using and
|
||||||
|
configuring ACLs, see https://www.consul.io/docs/internals/acl.html
|
||||||
version_added: "1.9"
|
version_added: "1.9"
|
||||||
author: Steve Gargan (steve.gargan@gmail.com)
|
author: Steve Gargan (steve.gargan@gmail.com)
|
||||||
options:
|
options:
|
||||||
|
@ -53,6 +54,16 @@ options:
|
||||||
description:
|
description:
|
||||||
- an list of the rules that should be associated with a given key/token.
|
- an list of the rules that should be associated with a given key/token.
|
||||||
required: false
|
required: false
|
||||||
|
host:
|
||||||
|
description:
|
||||||
|
- host of the consul agent defaults to localhost
|
||||||
|
required: false
|
||||||
|
default: localhost
|
||||||
|
port:
|
||||||
|
description:
|
||||||
|
- the port on which the consul agent is running
|
||||||
|
required: false
|
||||||
|
default: 8500
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
|
|
|
@ -42,8 +42,9 @@ options:
|
||||||
'release' respectively. a valid session must be supplied to make the
|
'release' respectively. a valid session must be supplied to make the
|
||||||
attempt changed will be true if the attempt is successful, false
|
attempt changed will be true if the attempt is successful, false
|
||||||
otherwise.
|
otherwise.
|
||||||
required: true
|
required: false
|
||||||
choices: ['present', 'absent', 'acquire', 'release']
|
choices: ['present', 'absent', 'acquire', 'release']
|
||||||
|
default: present
|
||||||
key:
|
key:
|
||||||
description:
|
description:
|
||||||
- the key at which the value should be stored.
|
- the key at which the value should be stored.
|
||||||
|
@ -57,30 +58,43 @@ options:
|
||||||
description:
|
description:
|
||||||
- if the key represents a prefix, each entry with the prefix can be
|
- if the key represents a prefix, each entry with the prefix can be
|
||||||
retrieved by setting this to true.
|
retrieved by setting this to true.
|
||||||
required: true
|
required: false
|
||||||
|
default: false
|
||||||
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
|
||||||
|
required: false
|
||||||
|
default: None
|
||||||
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
|
||||||
required: false
|
required: false
|
||||||
url:
|
default: None
|
||||||
description:
|
|
||||||
- location of the consul agent with which access the keay/value store,
|
|
||||||
defaults to http://localhost:8500
|
|
||||||
required: false
|
|
||||||
cas:
|
cas:
|
||||||
description:
|
description:
|
||||||
- used when acquiring a lock with a session. If the cas is 0, then
|
- used when acquiring a lock with a session. If the cas is 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
|
||||||
cas value is non-zero, then the key is only set if the index matches
|
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.
|
||||||
|
required: false
|
||||||
|
default: None
|
||||||
flags:
|
flags:
|
||||||
description:
|
description:
|
||||||
- opaque integer value that can be passed when setting a value.
|
- opaque integer value that can be passed when setting a value.
|
||||||
|
required: false
|
||||||
|
default: None
|
||||||
|
host:
|
||||||
|
description:
|
||||||
|
- host of the consul agent defaults to localhost
|
||||||
|
required: false
|
||||||
|
default: localhost
|
||||||
|
port:
|
||||||
|
description:
|
||||||
|
- the port on which the consul agent is running
|
||||||
|
required: false
|
||||||
|
default: 8500
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
@ -214,8 +228,8 @@ def main():
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
cas=dict(required=False),
|
cas=dict(required=False),
|
||||||
flags=dict(required=False),
|
flags=dict(required=False),
|
||||||
host=dict(default='localhost'),
|
|
||||||
key=dict(required=True),
|
key=dict(required=True),
|
||||||
|
host=dict(default='localhost'),
|
||||||
port=dict(default=8500, type='int'),
|
port=dict(default=8500, type='int'),
|
||||||
recurse=dict(required=False, type='bool'),
|
recurse=dict(required=False, type='bool'),
|
||||||
retrieve=dict(required=False, default=True),
|
retrieve=dict(required=False, default=True),
|
||||||
|
|
|
@ -39,35 +39,73 @@ options:
|
||||||
node name or session id is required as parameter.
|
node name or session id is required as parameter.
|
||||||
required: false
|
required: false
|
||||||
choices: ['present', 'absent', 'info', 'node', 'list']
|
choices: ['present', 'absent', 'info', 'node', 'list']
|
||||||
|
default: present
|
||||||
name:
|
name:
|
||||||
description:
|
description:
|
||||||
- the name that should be associated with the session. This is opaque
|
- the name that should be associated with the session. This is opaque
|
||||||
to Consul and not required.
|
to Consul and not required.
|
||||||
required: false
|
required: false
|
||||||
|
default: None
|
||||||
delay:
|
delay:
|
||||||
description:
|
description:
|
||||||
- the optional lock delay that can be attached to the session when it
|
- the optional lock delay that can be attached to the session when it
|
||||||
is created. Locks for invalidated sessions ar blocked from being
|
is created. Locks for invalidated sessions ar blocked from being
|
||||||
acquired until this delay has expired.
|
acquired until this delay has expired.
|
||||||
default: 15s
|
default: 15s
|
||||||
|
required: false
|
||||||
node:
|
node:
|
||||||
description:
|
description:
|
||||||
- the name of the node that with which the session will be associated.
|
- the name of the node that with which the session will be associated.
|
||||||
by default this is the name of the agent.
|
by default this is the name of the agent.
|
||||||
|
required: false
|
||||||
|
default: None
|
||||||
datacenter:
|
datacenter:
|
||||||
description:
|
description:
|
||||||
- name of the datacenter in which the session exists or should be
|
- name of the datacenter in which the session exists or should be
|
||||||
created.
|
created.
|
||||||
|
required: false
|
||||||
|
default: None
|
||||||
checks:
|
checks:
|
||||||
description:
|
description:
|
||||||
- a list of checks that will be used to verify the session health. If
|
- a list of checks that will be used to verify the session health. If
|
||||||
all the checks fail, the session will be invalidated and any locks
|
all the checks fail, the session will be invalidated and any locks
|
||||||
associated with the session will be release and can be acquired once
|
associated with the session will be release and can be acquired once
|
||||||
the associated lock delay has expired.
|
the associated lock delay has expired.
|
||||||
|
required: false
|
||||||
|
default: None
|
||||||
|
host:
|
||||||
|
description:
|
||||||
|
- host of the consul agent defaults to localhost
|
||||||
|
required: false
|
||||||
|
default: localhost
|
||||||
|
port:
|
||||||
|
description:
|
||||||
|
- the port on which the consul agent is running
|
||||||
|
required: false
|
||||||
|
default: 8500
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
|
- name: register basic session with consul
|
||||||
|
consul_session:
|
||||||
|
name: session1
|
||||||
|
|
||||||
|
- name: register a session with an existing check
|
||||||
|
consul_session:
|
||||||
|
name: session_with_check
|
||||||
|
checks:
|
||||||
|
- existing_check_name
|
||||||
|
|
||||||
|
- name: register a session with lock_delay
|
||||||
|
consul_session:
|
||||||
|
name: session_with_delay
|
||||||
|
delay: 20
|
||||||
|
|
||||||
|
- name: retrieve info about session by id
|
||||||
|
consul_session: id=session_id state=info
|
||||||
|
|
||||||
|
- name: retrieve active sessions
|
||||||
|
consul_session: state=list
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
Loading…
Reference in a new issue