Skip to content

Commit

Permalink
Merge pull request #100 from tribe29/feature-twopointone-support
Browse files Browse the repository at this point in the history
Add capabilities to test the collection against several Checkmk versions. Closes #43.
  • Loading branch information
robin-checkmk committed Aug 26, 2022
2 parents 0d2afb2 + 7fd2504 commit 936087c
Show file tree
Hide file tree
Showing 20 changed files with 270 additions and 212 deletions.
11 changes: 8 additions & 3 deletions tests/integration/targets/activation/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
---
- name: "Run preparations."
ansible.builtin.import_tasks: prep.yml
ansible.builtin.include_tasks: prep.yml

- name: "Wait for site to be ready."
ansible.builtin.pause:
seconds: 5
when: "'OVERALL 1' in item.stdout_lines"
loop: "{{ site_status.results }}"

- name: "Run tests."
ansible.builtin.import_tasks: test.yml
- name: "Testing."
ansible.builtin.include_tasks: test.yml
loop: "{{ checkmk_versions }}"
loop_control:
loop_var: outer_item
25 changes: 16 additions & 9 deletions tests/integration/targets/activation/tasks/prep.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
---
- name: "Download Checkmk {{ checkmk_version }}."
- name: "Download Checkmk Versions."
ansible.builtin.get_url:
url: "{{ download_url }}"
dest: /tmp/checkmk-server.deb
dest: /tmp/checkmk-server-{{ item.site }}.deb
mode: 0640
loop: "{{ checkmk_versions }}"

- name: "Install Checkmk {{ checkmk_version }}."
- name: "Install Checkmk Versions."
ansible.builtin.apt:
deb: /tmp/checkmk-server.deb
deb: /tmp/checkmk-server-{{ item.site }}.deb
state: present
loop: "{{ checkmk_versions }}"

- name: "Create site {{ site }}."
ansible.builtin.command: "omd create --no-tmpfs --admin-password {{ automation_secret }} {{ site }}"
- name: "Create Sites."
ansible.builtin.command: "omd create --no-tmpfs --admin-password {{ automation_secret }} {{ item.site }}"
args:
creates: "/omd/sites/{{ site }}"
creates: "/omd/sites/{{ item.site }}"
loop: "{{ checkmk_versions }}"

- name: "Start site {{ site }}."
ansible.builtin.shell: "omd status -b {{ site }} || omd start {{ site }}"
- name: "Start Sites."
ansible.builtin.shell: "omd status -b {{ item.site }} || omd start {{ item.site }}"
register: site_status
changed_when: site_status.rc == "0"
loop: "{{ checkmk_versions }}"
32 changes: 16 additions & 16 deletions tests/integration/targets/activation/tasks/test.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
---
- name: "Create hosts."
- name: "{{ outer_item.version }} - Create hosts."
host:
server_url: "{{ server_url }}"
site: "{{ site }}"
site: "{{ outer_item.site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
host_name: "{{ item.name }}"
folder: "{{ item.folder }}"
attributes:
site: "{{ site }}"
site: "{{ outer_item.site }}"
ipaddress: 127.0.0.1
state: "present"
delegate_to: localhost
run_once: 'yes'
run_once: true
loop: "{{ checkmk_hosts }}"

- name: "Activate."
- name: "{{ outer_item.version }} - Activate."
activation:
server_url: "{{ server_url }}"
site: "{{ site }}"
site: "{{ outer_item.site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
force_foreign_changes: 'false'
sites:
- "{{ site }}"
- "{{ outer_item.site }}"
delegate_to: localhost
run_once: 'true'
run_once: true

- name: "Delete hosts."
- name: "{{ outer_item.version }} - Delete hosts."
host:
server_url: "{{ server_url }}"
site: "{{ site }}"
site: "{{ outer_item.site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
host_name: "{{ item.name }}"
folder: "{{ item.folder }}"
state: "absent"
delegate_to: localhost
run_once: 'yes'
run_once: true
loop: "{{ checkmk_hosts }}"

- name: "Activate forcing foreign changes."
- name: "{{ outer_item.version }} - Activate forcing foreign changes."
activation:
server_url: "{{ server_url }}"
site: "{{ site }}"
site: "{{ outer_item.site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
force_foreign_changes: 'true'
force_foreign_changes: true
sites:
- "{{ site }}"
- "{{ outer_item.site }}"
delegate_to: localhost
run_once: 'true'
run_once: true
9 changes: 6 additions & 3 deletions tests/integration/targets/activation/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
---
checkmk_version: "2.0.0p26"
download_url: "https://download.checkmk.com/checkmk/{{ checkmk_version }}/check-mk-raw-{{ checkmk_version }}_0.{{ ansible_distribution_release }}_amd64.deb"
site: "test"
checkmk_versions:
- version: "2.1.0p10"
site: "stable"
- version: "2.0.0p27"
site: "oldstable"
download_url: "https://download.checkmk.com/checkmk/{{ item.version }}/check-mk-raw-{{ item.version }}_0.{{ ansible_distribution_release }}_amd64.deb"
server_url: "http://127.0.0.1/"
automation_user: "cmkadmin"
automation_secret: "d7589df1-01db-4eda-9858-dbcff8d0c361"
Expand Down
11 changes: 8 additions & 3 deletions tests/integration/targets/discovery/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
---
- name: "Run preparations."
ansible.builtin.import_tasks: prep.yml
ansible.builtin.include_tasks: prep.yml

- name: "Wait for site to be ready."
ansible.builtin.pause:
seconds: 5
when: "'OVERALL 1' in item.stdout_lines"
loop: "{{ site_status.results }}"

- name: "Run tests."
ansible.builtin.import_tasks: test.yml
- name: "Testing."
ansible.builtin.include_tasks: test.yml
loop: "{{ checkmk_versions }}"
loop_control:
loop_var: outer_item
25 changes: 16 additions & 9 deletions tests/integration/targets/discovery/tasks/prep.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
---
- name: "Download Checkmk {{ checkmk_version }}."
- name: "Download Checkmk Versions."
ansible.builtin.get_url:
url: "{{ download_url }}"
dest: /tmp/checkmk-server.deb
dest: /tmp/checkmk-server-{{ item.site }}.deb
mode: 0640
loop: "{{ checkmk_versions }}"

- name: "Install Checkmk {{ checkmk_version }}."
- name: "Install Checkmk Versions."
ansible.builtin.apt:
deb: /tmp/checkmk-server.deb
deb: /tmp/checkmk-server-{{ item.site }}.deb
state: present
loop: "{{ checkmk_versions }}"

- name: "Create site {{ site }}."
ansible.builtin.command: "omd create --no-tmpfs --admin-password {{ automation_secret }} {{ site }}"
- name: "Create Sites."
ansible.builtin.command: "omd create --no-tmpfs --admin-password {{ automation_secret }} {{ item.site }}"
args:
creates: "/omd/sites/{{ site }}"
creates: "/omd/sites/{{ item.site }}"
loop: "{{ checkmk_versions }}"

- name: "Start site {{ site }}."
ansible.builtin.shell: "omd status -b {{ site }} || omd start {{ site }}"
- name: "Start Sites."
ansible.builtin.shell: "omd status -b {{ item.site }} || omd start {{ item.site }}"
register: site_status
changed_when: site_status.rc == "0"
loop: "{{ checkmk_versions }}"
38 changes: 19 additions & 19 deletions tests/integration/targets/discovery/tasks/test.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
---
- name: "Create hosts."
- name: "{{ outer_item.version }} - Create hosts."
host:
server_url: "{{ server_url }}"
site: "{{ site }}"
site: "{{ outer_item.site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
host_name: "{{ item.name }}"
folder: "{{ item.folder }}"
attributes:
site: "{{ site }}"
site: "{{ outer_item.site }}"
ipaddress: 127.0.0.1
state: "present"
delegate_to: localhost
run_once: 'yes'
run_once: true
loop: "{{ checkmk_hosts }}"

- name: "Discover hosts."
- name: "{{ outer_item.version }} - Discover hosts."
discovery:
server_url: "{{ server_url }}"
site: "{{ site }}"
site: "{{ outer_item.site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
host_name: "{{ item.name }}"
state: "fix_all"
delegate_to: localhost
run_once: 'yes'
run_once: true
loop: "{{ checkmk_hosts }}"

- name: "Activate."
- name: "{{ outer_item.version }} - Activate."
activation:
server_url: "{{ server_url }}"
site: "{{ site }}"
site: "{{ outer_item.site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
force_foreign_changes: 'true'
force_foreign_changes: true
sites:
- "{{ site }}"
- "{{ outer_item.site }}"
delegate_to: localhost
run_once: 'true'
run_once: true

- name: "Delete hosts."
- name: "{{ outer_item.version }} - Delete hosts."
host:
server_url: "{{ server_url }}"
site: "{{ site }}"
site: "{{ outer_item.site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
host_name: "{{ item.name }}"
folder: "{{ item.folder }}"
state: "absent"
delegate_to: localhost
run_once: 'yes'
run_once: true
loop: "{{ checkmk_hosts }}"

- name: "Activate."
- name: "{{ outer_item.version }} - Activate."
activation:
server_url: "{{ server_url }}"
site: "{{ site }}"
site: "{{ outer_item.site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
sites:
- "{{ site }}"
- "{{ outer_item.site }}"
delegate_to: localhost
run_once: 'true'
run_once: true
15 changes: 9 additions & 6 deletions tests/integration/targets/discovery/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
---
checkmk_version: "2.0.0p23"
download_url: "https://download.checkmk.com/checkmk/{{ checkmk_version }}/check-mk-raw-{{ checkmk_version }}_0.bionic_amd64.deb"
site: "test"
checkmk_versions:
- version: "2.1.0p10"
site: "stable"
- version: "2.0.0p27"
site: "oldstable"
download_url: "https://download.checkmk.com/checkmk/{{ item.version }}/check-mk-raw-{{ item.version }}_0.{{ ansible_distribution_release }}_amd64.deb"
server_url: "http://127.0.0.1/"
automation_user: "cmkadmin"
automation_secret: "d7589df1-01db-4eda-9858-dbcff8d0c361"
Expand All @@ -10,10 +13,10 @@ checkmk_hosts:
- name: test1.tld
folder: "/"
- name: test2.tld
folder: "/"
folder: "/"
- name: test3.tld
folder: "/"
- name: test4.tld
folder: "/"
folder: "/"
- name: test5.tld
folder: "/"
folder: "/"
11 changes: 8 additions & 3 deletions tests/integration/targets/downtime/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
---
- name: "Run preparations."
ansible.builtin.import_tasks: prep.yml
ansible.builtin.include_tasks: prep.yml

- name: "Wait for site to be ready."
ansible.builtin.pause:
seconds: 5
when: "'OVERALL 1' in item.stdout_lines"
loop: "{{ site_status.results }}"

- name: "Run tests."
ansible.builtin.import_tasks: test.yml
- name: "Testing."
ansible.builtin.include_tasks: test.yml
loop: "{{ checkmk_versions }}"
loop_control:
loop_var: outer_item
25 changes: 16 additions & 9 deletions tests/integration/targets/downtime/tasks/prep.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
---
- name: "Download Checkmk {{ checkmk_version }}."
- name: "Download Checkmk Versions."
ansible.builtin.get_url:
url: "{{ download_url }}"
dest: /tmp/checkmk-server.deb
dest: /tmp/checkmk-server-{{ item.site }}.deb
mode: 0640
loop: "{{ checkmk_versions }}"

- name: "Install Checkmk {{ checkmk_version }}."
- name: "Install Checkmk Versions."
ansible.builtin.apt:
deb: /tmp/checkmk-server.deb
deb: /tmp/checkmk-server-{{ item.site }}.deb
state: present
loop: "{{ checkmk_versions }}"

- name: "Create site {{ site }}."
ansible.builtin.command: "omd create --no-tmpfs --admin-password {{ automation_secret }} {{ site }}"
- name: "Create Sites."
ansible.builtin.command: "omd create --no-tmpfs --admin-password {{ automation_secret }} {{ item.site }}"
args:
creates: "/omd/sites/{{ site }}"
creates: "/omd/sites/{{ item.site }}"
loop: "{{ checkmk_versions }}"

- name: "Start site {{ site }}."
ansible.builtin.shell: "omd status -b {{ site }} || omd start {{ site }}"
- name: "Start Sites."
ansible.builtin.shell: "omd status -b {{ item.site }} || omd start {{ item.site }}"
register: site_status
changed_when: site_status.rc == "0"
loop: "{{ checkmk_versions }}"
Loading

0 comments on commit 936087c

Please sign in to comment.