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

Finish task with failed if host_group parameter is empty list #1168

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- zabbix_host - Finish task with failed if host_group parameter is empty list
7 changes: 5 additions & 2 deletions plugins/modules/zabbix_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,8 +1038,11 @@ def main():

group_ids = []

if host_groups:
group_ids = host.get_group_ids_by_group_names(host_groups)
if host_groups is not None:
if len(host_groups) >= 1:
group_ids = host.get_group_ids_by_group_names(host_groups)
else:
module.fail_json(msg="host_groups must be not empty list.")

interfaces, ip = host.construct_host_interfaces(interfaces)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,23 @@
that:
- "zabbix_ipmi_host is not changed"

- name: "test: create host with host group(empty list)"
community.zabbix.zabbix_host:
host_name: ExampleHost
visible_name: ExampleName
description: My ExampleHost Description
host_groups: []
status: disabled
state: present
ignore_errors: true
register: zbx_host_create_hostgroup_empty_list

- name: expect to fail updating
ansible.builtin.assert:
that:
- zbx_host_create_hostgroup_empty_list is failed
- zbx_host_create_hostgroup_empty_list.msg == "host_groups must be not empty list."

- name: "cleanup"
community.zabbix.zabbix_host:
host_name: ExampleHost
Expand Down