Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds soft-update logic if force is set to no in zabbix_host module in… #22614

Merged
merged 2 commits into from
Sep 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion lib/ansible/modules/monitoring/zabbix_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,26 @@ def main():
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 existing groups, interfaces and templates and merge them with ones provided as an argument
# we do not want to overwrite anything if force: no is explicitly used, we just want to add new ones
for group_id in host.get_group_ids_by_group_names(host.get_host_groups_by_host_id(host_id)):
if group_id not in group_ids:
group_ids.append(group_id)

for interface in host._zapi.hostinterface.get({'output': 'extend', 'hostids': host_id}):
# remove values not used during hostinterface.add/update calls
for key in interface.keys():
if key in ['interfaceid', 'hostid', 'bulk']:
interface.pop(key, None)

for index in interface.keys():
if index in ['useip', 'main', 'type', 'port']:
interface[index] = int(interface[index])

if interface not in interfaces:
interfaces.append(interface)

template_ids = list(set(template_ids + host.get_host_templates_by_host_id(host_id)))

# get exist host's interfaces
exist_interfaces = host._zapi.hostinterface.get({'output': 'extend', 'hostids': host_id})
Expand Down