From 50c9f91060995390eb2fd4b6429e70af4b7dcd36 Mon Sep 17 00:00:00 2001 From: Eike Frost Date: Tue, 21 Nov 2017 07:19:01 +0100 Subject: [PATCH] zabbix_host: make host_groups actually optional on update (#33099) * When updating a host, host_groups need not necessarily be specified. * Also set host_groups for later equivalency tests --- lib/ansible/modules/monitoring/zabbix/zabbix_host.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/monitoring/zabbix/zabbix_host.py b/lib/ansible/modules/monitoring/zabbix/zabbix_host.py index da334f3188..daa0b3dd20 100644 --- a/lib/ansible/modules/monitoring/zabbix/zabbix_host.py +++ b/lib/ansible/modules/monitoring/zabbix/zabbix_host.py @@ -25,6 +25,7 @@ author: - "Tony Minfei Ding" - "Harrison Gu (@harrisongu)" - "Werner Dijkerman" + - "Eike Frost (@eikef)" requirements: - "python >= 2.6" - "zabbix-api >= 0.5.3" @@ -639,8 +640,11 @@ def main(): host.delete_host(host_id, host_name) module.exit_json(changed=True, result="Successfully delete host %s" % host_name) else: - if not group_ids: - module.fail_json(msg="Specify at least one group for updating host '%s'." % host_name) + if not host_groups: + # if host_groups have not been specified when updating an existing host, just + # get the group_ids from the existing host without updating them. + host_groups = host.get_host_groups_by_host_id(host_id) + group_ids = host.get_group_ids_by_group_names(host_groups) if not force: # get existing groups, interfaces and templates and merge them with ones provided as an argument