Skip to content

Commit

Permalink
adjusted doc and argument spec in zabbix modules to match sanity requ…
Browse files Browse the repository at this point in the history
…irements (#66176)

(cherry picked from commit 3456700)
  • Loading branch information
D3DeFi authored and mattclay committed Jan 13, 2020
1 parent de0936f commit c94aa6d
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 90 deletions.
9 changes: 6 additions & 3 deletions lib/ansible/modules/monitoring/zabbix/zabbix_group.py
Expand Up @@ -13,7 +13,7 @@
'supported_by': 'community'}


DOCUMENTATION = '''
DOCUMENTATION = r'''
---
module: zabbix_group
short_description: Create/delete Zabbix host groups
Expand All @@ -33,12 +33,15 @@
description:
- Create or delete host group.
required: false
type: str
default: "present"
choices: [ "present", "absent" ]
host_groups:
description:
- List of host groups to create or delete.
required: true
type: list
elements: str
aliases: [ "host_group" ]
extends_documentation_fragment:
Expand All @@ -48,7 +51,7 @@
- Too many concurrent updates to the same group may cause Zabbix to return errors, see examples for a workaround if needed.
'''

EXAMPLES = '''
EXAMPLES = r'''
# Base create host groups example
- name: Create host groups
local_action:
Expand Down Expand Up @@ -144,7 +147,7 @@ def main():
http_login_password=dict(type='str', required=False, default=None, no_log=True),
validate_certs=dict(type='bool', required=False, default=True),
host_groups=dict(type='list', required=True, aliases=['host_group']),
state=dict(default="present", choices=['present', 'absent']),
state=dict(type='str', default="present", choices=['present', 'absent']),
timeout=dict(type='int', default=10)
),
supports_check_mode=True
Expand Down
8 changes: 5 additions & 3 deletions lib/ansible/modules/monitoring/zabbix/zabbix_group_info.py
Expand Up @@ -12,7 +12,7 @@
'status': ['preview'],
'supported_by': 'community'}

RETURN = '''
RETURN = r'''
---
host_groups:
description: List of Zabbix groups.
Expand All @@ -21,7 +21,7 @@
sample: [ { "flags": "0", "groupid": "33", "internal": "0", "name": "Hostgruup A" } ]
'''

DOCUMENTATION = '''
DOCUMENTATION = r'''
---
module: zabbix_group_info
short_description: Gather information about Zabbix hostgroup
Expand All @@ -40,11 +40,13 @@
- Name of the hostgroup in Zabbix.
- hostgroup is the unique identifier used and cannot be updated using this module.
required: true
type: list
elements: str
extends_documentation_fragment:
- zabbix
'''

EXAMPLES = '''
EXAMPLES = r'''
- name: Get hostgroup info
local_action:
module: zabbix_group_info
Expand Down
35 changes: 29 additions & 6 deletions lib/ansible/modules/monitoring/zabbix/zabbix_host.py
Expand Up @@ -13,7 +13,7 @@
'supported_by': 'community'}


DOCUMENTATION = '''
DOCUMENTATION = r'''
---
module: zabbix_host
short_description: Create/update/delete Zabbix hosts
Expand All @@ -35,48 +35,61 @@
- Name of the host in Zabbix.
- I(host_name) is the unique identifier used and cannot be updated using this module.
required: true
type: str
visible_name:
description:
- Visible name of the host in Zabbix.
version_added: '2.3'
type: str
description:
description:
- Description of the host in Zabbix.
version_added: '2.5'
type: str
host_groups:
description:
- List of host groups the host is part of.
type: list
elements: str
link_templates:
description:
- List of templates linked to the host.
type: list
elements: str
inventory_mode:
description:
- Configure the inventory mode.
choices: ['automatic', 'manual', 'disabled']
version_added: '2.1'
type: str
inventory_zabbix:
description:
- Add Facts for a zabbix inventory (e.g. Tag) (see example below).
- Please review the interface documentation for more information on the supported properties
- U(https://www.zabbix.com/documentation/3.2/manual/api/reference/host/object#host_inventory)
version_added: '2.5'
type: dict
status:
description:
- Monitoring status of the host.
choices: ['enabled', 'disabled']
default: 'enabled'
type: str
state:
description:
- State of the host.
- On C(present), it will create if host does not exist or update the host if the associated data is different.
- On C(absent) will remove a host if it exists.
choices: ['present', 'absent']
default: 'present'
type: str
proxy:
description:
- The name of the Zabbix proxy to be used.
type: str
interfaces:
type: list
elements: dict
description:
- List of interfaces to be created for the host (see example below).
- For more information, review host interface documentation at
Expand Down Expand Up @@ -143,6 +156,7 @@
- Works only with >= Zabbix 3.0
default: 1
version_added: '2.5'
type: int
tls_accept:
description:
- Specifies what types of connections are allowed for incoming connections.
Expand All @@ -152,29 +166,34 @@
- Works only with >= Zabbix 3.0
default: 1
version_added: '2.5'
type: int
tls_psk_identity:
description:
- It is a unique name by which this specific PSK is referred to by Zabbix components
- Do not put sensitive information in the PSK identity string, it is transmitted over the network unencrypted.
- Works only with >= Zabbix 3.0
version_added: '2.5'
type: str
tls_psk:
description:
- PSK value is a hard to guess string of hexadecimal digits.
- The preshared key, at least 32 hex digits. Required if either I(tls_connect) or I(tls_accept) has PSK enabled.
- Works only with >= Zabbix 3.0
version_added: '2.5'
type: str
ca_cert:
description:
- Required certificate issuer.
- Works only with >= Zabbix 3.0
version_added: '2.5'
aliases: [ tls_issuer ]
type: str
tls_subject:
description:
- Required certificate subject.
- Works only with >= Zabbix 3.0
version_added: '2.5'
type: str
ipmi_authtype:
description:
- IPMI authentication algorithm.
Expand All @@ -186,6 +205,7 @@
any of the I(ipmi_)-options; this means that if you attempt to set any of the four
options individually, the rest will be reset to default values.
version_added: '2.5'
type: int
ipmi_privilege:
description:
- IPMI privilege level.
Expand All @@ -195,16 +215,19 @@
being the API default.
- also see the last note in the I(ipmi_authtype) documentation
version_added: '2.5'
type: int
ipmi_username:
description:
- IPMI username.
- also see the last note in the I(ipmi_authtype) documentation
version_added: '2.5'
type: str
ipmi_password:
description:
- IPMI password.
- also see the last note in the I(ipmi_authtype) documentation
version_added: '2.5'
type: str
force:
description:
- Overwrite the host configuration, even if already present.
Expand All @@ -215,7 +238,7 @@
- zabbix
'''

EXAMPLES = '''
EXAMPLES = r'''
- name: Create a new host or update an existing host's info
local_action:
module: zabbix_host
Expand Down Expand Up @@ -676,9 +699,9 @@ def main():
validate_certs=dict(type='bool', required=False, default=True),
host_groups=dict(type='list', required=False),
link_templates=dict(type='list', required=False),
status=dict(default="enabled", choices=['enabled', 'disabled']),
state=dict(default="present", choices=['present', 'absent']),
inventory_mode=dict(required=False, choices=['automatic', 'manual', 'disabled']),
status=dict(type='str', default="enabled", choices=['enabled', 'disabled']),
state=dict(type='str', default="present", choices=['present', 'absent']),
inventory_mode=dict(type='str', required=False, choices=['automatic', 'manual', 'disabled']),
ipmi_authtype=dict(type='int', default=None),
ipmi_privilege=dict(type='int', default=None),
ipmi_username=dict(type='str', required=False, default=None),
Expand All @@ -689,7 +712,7 @@ def main():
tls_psk=dict(type='str', required=False),
ca_cert=dict(type='str', required=False, aliases=['tls_issuer']),
tls_subject=dict(type='str', required=False),
inventory_zabbix=dict(required=False, type='dict'),
inventory_zabbix=dict(type='dict', required=False),
timeout=dict(type='int', default=10),
interfaces=dict(type='list', required=False),
force=dict(type='bool', default=True),
Expand Down
14 changes: 10 additions & 4 deletions lib/ansible/modules/monitoring/zabbix/zabbix_host_info.py
Expand Up @@ -13,7 +13,7 @@
'status': ['preview'],
'supported_by': 'community'}

RETURN = '''
RETURN = r'''
---
hosts:
description: List of Zabbix hosts. See https://www.zabbix.com/documentation/3.4/manual/api/reference/host/get for list of host values.
Expand All @@ -22,7 +22,7 @@
sample: [ { "available": "1", "description": "", "disable_until": "0", "error": "", "flags": "0", "groups": ["1"], "host": "Host A", ... } ]
'''

DOCUMENTATION = '''
DOCUMENTATION = r'''
---
module: zabbix_host_info
short_description: Gather information about Zabbix host
Expand All @@ -40,11 +40,16 @@
description:
- Name of the host in Zabbix.
- host_name is the unique identifier used and cannot be updated using this module.
required: true
- Required when I(host_ip) is not used.
required: false
type: str
host_ip:
description:
- Host interface IP of the host in Zabbix.
- Required when I(host_name) is not used.
required: false
type: list
elements: str
exact_match:
description:
- Find the exact match
Expand All @@ -60,13 +65,14 @@
- List of host inventory keys to display in result.
- Whole host inventory is retrieved if keys are not specified.
type: list
elements: str
required: false
version_added: 2.8
extends_documentation_fragment:
- zabbix
'''

EXAMPLES = '''
EXAMPLES = r'''
- name: Get host info
local_action:
module: zabbix_host_info
Expand Down
16 changes: 10 additions & 6 deletions lib/ansible/modules/monitoring/zabbix/zabbix_hostmacro.py
Expand Up @@ -13,7 +13,7 @@
'supported_by': 'community'}


DOCUMENTATION = '''
DOCUMENTATION = r'''
---
module: zabbix_hostmacro
short_description: Create/update/delete Zabbix host macros
Expand All @@ -31,21 +31,25 @@
description:
- Name of the host.
required: true
type: str
macro_name:
description:
- Name of the host macro without the enclosing curly braces and the leading dollar sign.
required: true
type: str
macro_value:
description:
- Value of the host macro.
required: true
- Required if I(state=present).
type: str
state:
description:
- State of the macro.
- On C(present), it will create if macro does not exist or update the macro if the associated data is different.
- On C(absent) will remove a macro if it exists.
required: false
choices: ['present', 'absent']
type: str
default: "present"
force:
description:
Expand All @@ -58,8 +62,8 @@
- zabbix
'''

EXAMPLES = '''
- name: Create a new host macro or update an existing macro's value
EXAMPLES = r'''
- name: Create new host macro or update an existing macro's value
local_action:
module: zabbix_hostmacro
server_url: http://monitor.example.com
Expand Down Expand Up @@ -159,8 +163,8 @@ def main():
validate_certs=dict(type='bool', required=False, default=True),
host_name=dict(type='str', required=True),
macro_name=dict(type='str', required=True),
macro_value=dict(type='str', required=True),
state=dict(default="present", choices=['present', 'absent']),
macro_value=dict(type='str', required=False),
state=dict(type='str', default='present', choices=['present', 'absent']),
timeout=dict(type='int', default=10),
force=dict(type='bool', default=True)
),
Expand Down

0 comments on commit c94aa6d

Please sign in to comment.