1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

added force option to zabbix_hostmacro to allow control of overwriting (#35516)

* added force option to hostmacro to allow control of overwriting existing macro

* wording changes as suggested by eikef in PR 35516

* further wording changes from eikef

* added 'version_added: 2.5' to the documenation for the force option
This commit is contained in:
Abby Howe 2018-02-01 08:37:11 +00:00 committed by ansibot
parent ea70b49b11
commit 2479b6d635

View file

@ -47,6 +47,12 @@ options:
required: false
choices: ['present', 'absent']
default: "present"
force:
description:
- Only updates an existing macro if set to C(yes).
default: 'yes'
choices: ['yes', 'no']
version_added: 2.5
extends_documentation_fragment:
- zabbix
@ -157,7 +163,8 @@ def main():
macro_name=dict(type='str', required=True),
macro_value=dict(type='str', required=True),
state=dict(default="present", choices=['present', 'absent']),
timeout=dict(type='int', default=10)
timeout=dict(type='int', default=10),
force=dict(type='bool', default=True)
),
supports_check_mode=True
)
@ -176,6 +183,7 @@ def main():
macro_value = module.params['macro_value']
state = module.params['state']
timeout = module.params['timeout']
force = module.params['force']
zbx = None
# login to zabbix
@ -202,9 +210,11 @@ def main():
if not host_macro_obj:
# create host macro
host_macro_class_obj.create_host_macro(macro_name, macro_value, host_id)
else:
elif force:
# update host macro
host_macro_class_obj.update_host_macro(host_macro_obj, macro_name, macro_value)
else:
module.exit_json(changed=False, result="Host macro %s already exists and force is set to no" % macro_name)
if __name__ == '__main__':