diff --git a/lib/ansible/modules/extras/monitoring/zabbix_host.py b/lib/ansible/modules/extras/monitoring/zabbix_host.py index b17a259039..717baa6232 100644 --- a/lib/ansible/modules/extras/monitoring/zabbix_host.py +++ b/lib/ansible/modules/extras/monitoring/zabbix_host.py @@ -88,6 +88,13 @@ options: - 'https://www.zabbix.com/documentation/2.0/manual/appendix/api/hostinterface/definitions#host_interface' required: false default: [] + force: + description: + - Overwrite the host configuration, even if already present + required: false + default: "yes" + choices: [ "yes", "no" ] + version_added: "2.0" ''' EXAMPLES = ''' @@ -367,6 +374,7 @@ def main(): state=dict(default="present", choices=['present', 'absent']), timeout=dict(type='int', default=10), interfaces=dict(required=False), + force=dict(default='yes', choices='bool'), proxy=dict(required=False) ), supports_check_mode=True @@ -385,6 +393,7 @@ def main(): state = module.params['state'] timeout = module.params['timeout'] interfaces = module.params['interfaces'] + force = module.params['force'] proxy = module.params['proxy'] # convert enabled to 0; disabled to 1 @@ -436,6 +445,9 @@ def main(): if not group_ids: module.fail_json(msg="Specify at least one group for updating host '%s'." % host_name) + if not force: + module.fail_json(changed=False, result="Host present, Can't update configuration without force") + # get exist host's interfaces exist_interfaces = host._zapi.hostinterface.get({'output': 'extend', 'hostids': host_id}) exist_interfaces_copy = copy.deepcopy(exist_interfaces)