Skip to content

Commit

Permalink
Merge pull request #599 from msekania/feature/extend_tests_for_host_m…
Browse files Browse the repository at this point in the history
…odule

Extend host module tests
  • Loading branch information
robin-checkmk authored Apr 30, 2024
2 parents a5e8ddb + 857804d commit a866c1f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
48 changes: 32 additions & 16 deletions tests/integration/targets/host/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
attributes:
site: "{{ outer_item.site }}"
ipaddress: 127.0.0.1
Expand All @@ -40,14 +40,30 @@
delegate_to: localhost
run_once: true # noqa run-once[task]

- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify host folder."
ansible.builtin.assert:
that: "(item.folder | default('/')) == extensions.folder"
vars:
extensions: "{{ lookup('checkmk.general.host',
item.name,
server_url=checkmk_var_server_url,
site=outer_item.site,
validate_certs=False,
automation_user=checkmk_var_automation_user,
automation_secret=checkmk_var_automation_secret)
}}"
delegate_to: localhost
run_once: true # noqa run-once[task]
loop: "{{ checkmk_hosts }}"

- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete hosts."
host:
server_url: "{{ checkmk_var_server_url }}"
site: "{{ outer_item.site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
state: "absent"
delegate_to: localhost
run_once: true # noqa run-once[task]
Expand Down Expand Up @@ -134,7 +150,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
state: "absent"
delegate_to: localhost
run_once: true # noqa run-once[task]
Expand All @@ -160,7 +176,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
attributes:
site: "{{ outer_item.site }}"
ipaddress: 127.0.0.1
Expand Down Expand Up @@ -188,7 +204,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
nodes: "{{ item.nodes }}"
attributes:
site: "{{ outer_item.site }}"
Expand Down Expand Up @@ -217,7 +233,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
nodes: "{{ item.nodes }}"
attributes:
site: "{{ outer_item.site }}"
Expand All @@ -234,7 +250,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ first.name }}"
folder: "{{ first.folder }}"
folder: "{{ first.folder | default(omit) }}"
nodes: "{{ second.nodes }}"
attributes:
site: "{{ outer_item.site }}"
Expand Down Expand Up @@ -265,7 +281,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ first.name }}"
folder: "{{ first.folder }}"
folder: "{{ first.folder | default(omit) }}"
nodes: "{{ second.nodes }}"
attributes:
site: "{{ outer_item.site }}"
Expand All @@ -284,7 +300,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
add_nodes: "{{ item.add_nodes }}"
attributes:
site: "{{ outer_item.site }}"
Expand Down Expand Up @@ -313,7 +329,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
add_nodes: "{{ item.add_nodes }}"
attributes:
site: "{{ outer_item.site }}"
Expand Down Expand Up @@ -342,7 +358,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
remove_nodes: "{{ item.remove_nodes }}"
attributes:
site: "{{ outer_item.site }}"
Expand Down Expand Up @@ -371,7 +387,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
remove_nodes: "{{ item.remove_nodes }}"
attributes:
site: "{{ outer_item.site }}"
Expand Down Expand Up @@ -401,7 +417,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
state: "absent"
delegate_to: localhost
run_once: true # noqa run-once[task]
Expand All @@ -426,7 +442,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
state: "absent"
delegate_to: localhost
run_once: true # noqa run-once[task]
Expand Down Expand Up @@ -506,7 +522,7 @@
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
nodes: "{{ item.nodes }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
state: "absent"
delegate_to: localhost
run_once: true # noqa run-once[task]
Expand All @@ -519,7 +535,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
state: "absent"
delegate_to: localhost
run_once: true # noqa run-once[task]
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/targets/host/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ checkmk_var_folders:
name: Digital

checkmk_hosts:
- name: test0.tld
- name: test1.tld
folder: "/"
- name: test2.tld
Expand All @@ -36,6 +37,10 @@ checkmk_hosts:
folder: "/foo/bar1"

checkmk_cluster_hosts:
- name: cluster_test0.tld
nodes:
- "test0.tld"
- "test4.tld"
- name: cluster_test1.tld
folder: "/"
nodes:
Expand Down

0 comments on commit a866c1f

Please sign in to comment.