mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
zabbix_host integration tests (#33184)
* Integration tests for zabbix_host using Zabbix on Ubuntu 14.04. * fix duplicate yaml key in test * .changed -> is changed, |failed -> is failed, trim configfile * zabbix_host integration test does not need BOTMETA entry, inherited from module
This commit is contained in:
parent
750f7fe132
commit
ed376abe42
16 changed files with 892 additions and 0 deletions
2
.github/BOTMETA.yml
vendored
2
.github/BOTMETA.yml
vendored
|
@ -1166,6 +1166,8 @@ files:
|
||||||
labels:
|
labels:
|
||||||
- networking
|
- networking
|
||||||
- nxos
|
- nxos
|
||||||
|
test/integration/targets/setup_zabbix:
|
||||||
|
maintainers: eikef D3DeFi
|
||||||
test/units/modules/network:
|
test/units/modules/network:
|
||||||
maintainers: $team_networking
|
maintainers: $team_networking
|
||||||
labels: networking
|
labels: networking
|
||||||
|
|
5
test/integration/targets/setup_zabbix/aliases
Normal file
5
test/integration/targets/setup_zabbix/aliases
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
destructive
|
||||||
|
posix/ci/group1
|
||||||
|
skip/osx
|
||||||
|
skip/freebsd
|
||||||
|
skip/rhel
|
10
test/integration/targets/setup_zabbix/defaults/main.yml
Normal file
10
test/integration/targets/setup_zabbix/defaults/main.yml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
db_name: 'zabbix'
|
||||||
|
db_user: 'zabbix'
|
||||||
|
db_password: 'fLhijUs3PgekNhwJ'
|
||||||
|
|
||||||
|
zabbix_release_deb: 'http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+trusty_all.deb'
|
||||||
|
|
||||||
|
zabbix_packages:
|
||||||
|
- zabbix-server-mysql
|
||||||
|
- zabbix-frontend-php
|
2
test/integration/targets/setup_zabbix/meta/main.yml
Normal file
2
test/integration/targets/setup_zabbix/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
dependencies:
|
||||||
|
- setup_mysql_db
|
6
test/integration/targets/setup_zabbix/tasks/main.yml
Normal file
6
test/integration/targets/setup_zabbix/tasks/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
# This integration test is only for Ubuntu 14.04 at the moment. This makes
|
||||||
|
# installation of a Zabbix quite a bit easier.
|
||||||
|
- include: setup.yml
|
||||||
|
when: ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'trusty'
|
48
test/integration/targets/setup_zabbix/tasks/setup.yml
Normal file
48
test/integration/targets/setup_zabbix/tasks/setup.yml
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
# sets up and starts Zabbix with default settings (works on Ubuntu 14.04,
|
||||||
|
# possibly more) using a MySQL database.
|
||||||
|
|
||||||
|
- name: create mysql user {{ db_user }}
|
||||||
|
mysql_user:
|
||||||
|
name: "{{ db_user }}"
|
||||||
|
password: "{{ db_password }}"
|
||||||
|
state: present
|
||||||
|
priv: "{{ db_name }}.*:ALL"
|
||||||
|
|
||||||
|
- name: install zabbix repository
|
||||||
|
apt: deb={{ zabbix_release_deb }} state=present
|
||||||
|
|
||||||
|
- name: install zabbix debian dependencies
|
||||||
|
apt: name={{ item }} state=latest update_cache=yes
|
||||||
|
with_items: "{{ zabbix_packages }}"
|
||||||
|
|
||||||
|
- name: install zabbix-api python package
|
||||||
|
pip:
|
||||||
|
name: zabbix-api
|
||||||
|
|
||||||
|
- name: import initial zabbix database
|
||||||
|
mysql_db:
|
||||||
|
name: "{{ db_name }}"
|
||||||
|
login_user: "{{ db_user }}"
|
||||||
|
login_password: "{{ db_password }}"
|
||||||
|
state: import
|
||||||
|
target: /usr/share/doc/zabbix-server-mysql/create.sql.gz
|
||||||
|
|
||||||
|
- name: deploy zabbix-server configuration
|
||||||
|
template:
|
||||||
|
src: zabbix_server.conf.j2
|
||||||
|
dest: /etc/zabbix/zabbix_server.conf
|
||||||
|
owner: zabbix
|
||||||
|
group: zabbix
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
|
- name: deploy zabbix web frontend configuration
|
||||||
|
template:
|
||||||
|
src: zabbix.conf.php.j2
|
||||||
|
dest: /etc/zabbix/web/zabbix.conf.php
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
|
- name: restart zabbix-server
|
||||||
|
service: name=zabbix-server state=restarted enabled=yes
|
||||||
|
|
||||||
|
- name: restart apache2
|
||||||
|
service: name=apache2 state=restarted enabled=yes
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
// Zabbix GUI configuration file
|
||||||
|
global $DB;
|
||||||
|
|
||||||
|
$DB['TYPE'] = 'MYSQL';
|
||||||
|
$DB['SERVER'] = 'localhost';
|
||||||
|
$DB['PORT'] = '0';
|
||||||
|
$DB['DATABASE'] = '{{ db_name }}';
|
||||||
|
$DB['USER'] = '{{ db_user }}';
|
||||||
|
$DB['PASSWORD'] = '{{ db_password }}';
|
||||||
|
|
||||||
|
// SCHEMA is relevant only for IBM_DB2 database
|
||||||
|
$DB['SCHEMA'] = '';
|
||||||
|
|
||||||
|
$ZBX_SERVER = 'localhost';
|
||||||
|
$ZBX_SERVER_PORT = '10051';
|
||||||
|
$ZBX_SERVER_NAME = '';
|
||||||
|
|
||||||
|
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
|
||||||
|
?>
|
|
@ -0,0 +1,6 @@
|
||||||
|
LogFile=/tmp/zabbix_server.log
|
||||||
|
DBName={{ db_name }}
|
||||||
|
DBUser={{ db_user }}
|
||||||
|
DBPassword={{ db_password }}
|
||||||
|
Timeout=4
|
||||||
|
LogSlowQueries=3000
|
5
test/integration/targets/zabbix_host/aliases
Normal file
5
test/integration/targets/zabbix_host/aliases
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
destructive
|
||||||
|
posix/ci/group1
|
||||||
|
skip/osx
|
||||||
|
skip/freebsd
|
||||||
|
skip/rhel
|
5
test/integration/targets/zabbix_host/defaults/main.yml
Normal file
5
test/integration/targets/zabbix_host/defaults/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
zabbix_server_url: http://127.0.0.1/zabbix/
|
||||||
|
zabbix_login_user: Admin
|
||||||
|
zabbix_login_password: zabbix
|
2
test/integration/targets/zabbix_host/meta/main.yml
Normal file
2
test/integration/targets/zabbix_host/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
dependencies:
|
||||||
|
- setup_zabbix
|
16
test/integration/targets/zabbix_host/tasks/main.yml
Normal file
16
test/integration/targets/zabbix_host/tasks/main.yml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
---
|
||||||
|
# setup stuff not testing zabbix_host
|
||||||
|
- include: zabbix_host_setup.yml
|
||||||
|
when: ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'trusty'
|
||||||
|
|
||||||
|
# zabbix_host module tests
|
||||||
|
- include: zabbix_host_tests.yml
|
||||||
|
when: ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'trusty'
|
||||||
|
|
||||||
|
# documentation example tests
|
||||||
|
- include: zabbix_host_doc.yml
|
||||||
|
when: ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'trusty'
|
||||||
|
|
||||||
|
# tear down stuff set up earlier
|
||||||
|
- include: zabbix_host_teardown.yml
|
||||||
|
when: ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'trusty'
|
|
@ -0,0 +1,71 @@
|
||||||
|
---
|
||||||
|
# These two tests are close to documentation example
|
||||||
|
|
||||||
|
- name: Create a new host or update an existing host's info
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
visible_name: ExampleName
|
||||||
|
description: My ExampleHost Description
|
||||||
|
host_groups:
|
||||||
|
- Linux servers
|
||||||
|
- Zabbix servers
|
||||||
|
link_templates:
|
||||||
|
- Template App IMAP Service
|
||||||
|
- Template App NTP Service
|
||||||
|
status: enabled
|
||||||
|
state: present
|
||||||
|
inventory_mode: manual
|
||||||
|
inventory_zabbix:
|
||||||
|
tag: test-tag
|
||||||
|
alias: test-alias
|
||||||
|
notes: "Special Informations: test-info"
|
||||||
|
location: test-location
|
||||||
|
site_rack: test-rack
|
||||||
|
os: test-os
|
||||||
|
hardware: test-hw
|
||||||
|
interfaces:
|
||||||
|
- type: 1
|
||||||
|
main: 1
|
||||||
|
useip: 1
|
||||||
|
ip: 10.1.1.1
|
||||||
|
dns: ""
|
||||||
|
port: 10050
|
||||||
|
- type: 4
|
||||||
|
main: 1
|
||||||
|
useip: 1
|
||||||
|
ip: 10.1.1.1
|
||||||
|
dns: ""
|
||||||
|
port: 12345
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: Update an existing host's tls settings
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost2
|
||||||
|
visible_name: ExampleName2
|
||||||
|
interfaces:
|
||||||
|
- type: 1
|
||||||
|
main: 1
|
||||||
|
useip: 1
|
||||||
|
ip: 10.1.1.2
|
||||||
|
dns: ""
|
||||||
|
port: 10050
|
||||||
|
host_groups:
|
||||||
|
- Linux servers
|
||||||
|
tls_psk_identity: test
|
||||||
|
tls_connect: 2
|
||||||
|
tls_psk: 123456789abcdef123456789abcdef12
|
||||||
|
register: zabbix_host2
|
||||||
|
|
||||||
|
- name: expect both to succeed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
- "zabbix_host2 is changed"
|
|
@ -0,0 +1,21 @@
|
||||||
|
---
|
||||||
|
# set up a zabbix proxy to test zabbix_host with
|
||||||
|
|
||||||
|
- name: Create a new proxy
|
||||||
|
local_action:
|
||||||
|
module: zabbix_proxy
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
proxy_name: ExampleProxy
|
||||||
|
description: ExampleProxy
|
||||||
|
status: active
|
||||||
|
state: present
|
||||||
|
interface:
|
||||||
|
type: 0
|
||||||
|
main: 1
|
||||||
|
useip: 1
|
||||||
|
ip: 10.5.6.7
|
||||||
|
dns: ""
|
||||||
|
port: 10050
|
||||||
|
register: zabbix_proxy
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
# remove zabbix_proxy (hopefully) created earlier
|
||||||
|
|
||||||
|
- name: remove proxy
|
||||||
|
local_action:
|
||||||
|
module: zabbix_proxy
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
proxy_name: ExampleProxy
|
||||||
|
state: absent
|
662
test/integration/targets/zabbix_host/tasks/zabbix_host_tests.yml
Normal file
662
test/integration/targets/zabbix_host/tasks/zabbix_host_tests.yml
Normal file
|
@ -0,0 +1,662 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: "test: create host with many options set"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
visible_name: ExampleName
|
||||||
|
description: My ExampleHost Description
|
||||||
|
host_groups:
|
||||||
|
- Linux servers
|
||||||
|
- Zabbix servers
|
||||||
|
link_templates:
|
||||||
|
- Template App IMAP Service
|
||||||
|
- Template App NTP Service
|
||||||
|
status: enabled
|
||||||
|
state: present
|
||||||
|
inventory_mode: manual
|
||||||
|
inventory_zabbix:
|
||||||
|
tag: test-tag
|
||||||
|
alias: test-alias
|
||||||
|
notes: "Special Informations: test-info"
|
||||||
|
location: test-location
|
||||||
|
site_rack: test-rack
|
||||||
|
os: test-os
|
||||||
|
hardware: test-hw
|
||||||
|
interfaces:
|
||||||
|
- type: 1
|
||||||
|
main: 1
|
||||||
|
useip: 1
|
||||||
|
ip: 10.1.1.1
|
||||||
|
dns: ""
|
||||||
|
port: 10050
|
||||||
|
- type: 4
|
||||||
|
main: 1
|
||||||
|
useip: 1
|
||||||
|
ip: 10.1.1.1
|
||||||
|
dns: ""
|
||||||
|
port: 12345
|
||||||
|
proxy: ExampleProxy
|
||||||
|
tls_psk_identity: test
|
||||||
|
tls_connect: 2
|
||||||
|
tls_psk: 123456789abcdef123456789abcdef12
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: try to create the same host with the same settings"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
visible_name: ExampleName
|
||||||
|
description: My ExampleHost Description
|
||||||
|
host_groups:
|
||||||
|
- Linux servers
|
||||||
|
- Zabbix servers
|
||||||
|
link_templates:
|
||||||
|
- Template App IMAP Service
|
||||||
|
- Template App NTP Service
|
||||||
|
status: enabled
|
||||||
|
state: present
|
||||||
|
inventory_mode: manual
|
||||||
|
inventory_zabbix:
|
||||||
|
tag: test-tag
|
||||||
|
alias: test-alias
|
||||||
|
notes: "Special Informations: test-info"
|
||||||
|
location: test-location
|
||||||
|
site_rack: test-rack
|
||||||
|
os: test-os
|
||||||
|
hardware: test-hw
|
||||||
|
interfaces:
|
||||||
|
- type: 1
|
||||||
|
main: 1
|
||||||
|
useip: 1
|
||||||
|
ip: 10.1.1.1
|
||||||
|
dns: ""
|
||||||
|
port: 10050
|
||||||
|
- type: 4
|
||||||
|
main: 1
|
||||||
|
useip: 1
|
||||||
|
ip: 10.1.1.1
|
||||||
|
dns: ""
|
||||||
|
port: 12345
|
||||||
|
proxy: ExampleProxy
|
||||||
|
tls_psk_identity: test
|
||||||
|
tls_connect: 2
|
||||||
|
tls_psk: 123456789abcdef123456789abcdef12
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: updating with same values should be idempotent
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "not zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change visible_name"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
visible_name: "ExampleName Changed"
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change visible_name (again)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
visible_name: "ExampleName Changed"
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: updating with same values should be idempotent
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "not zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change description"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
description: "My ExampleHost Description Changed"
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change description (again)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
description: "My ExampleHost Description Changed"
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: updating with same values should be idempotent
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "not zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change host groups (adding one group)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
host_groups:
|
||||||
|
- Linux servers
|
||||||
|
- Zabbix servers
|
||||||
|
- Virtual machines
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change host groups (remove one group)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
host_groups:
|
||||||
|
- Linux servers
|
||||||
|
- Zabbix servers
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change host groups (add one group using force=no)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
host_groups:
|
||||||
|
- Virtual machines
|
||||||
|
force: no
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
|
||||||
|
- name: "test: change host groups (check whether we are at three groups)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
host_groups:
|
||||||
|
- Linux servers
|
||||||
|
- Zabbix servers
|
||||||
|
- Virtual machines
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have not changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "not zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change host groups (attempt to remove all host groups)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
host_groups:
|
||||||
|
-
|
||||||
|
register: zabbix_host1
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: expect to fail
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is failed"
|
||||||
|
|
||||||
|
- name: "test: change host linked templates (same as before)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
link_templates:
|
||||||
|
- Template App IMAP Service
|
||||||
|
- Template App NTP Service
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have not changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "not zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change host linked templates (add one template)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
link_templates:
|
||||||
|
- Template App IMAP Service
|
||||||
|
- Template App NTP Service
|
||||||
|
- Template App HTTP Service
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change host linked templates (add one template, using force=no)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
link_templates:
|
||||||
|
- Template App LDAP Service
|
||||||
|
force: no
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change host linked templates (make sure we are at 4 templates)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
link_templates:
|
||||||
|
- Template App IMAP Service
|
||||||
|
- Template App NTP Service
|
||||||
|
- Template App HTTP Service
|
||||||
|
- Template App LDAP Service
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have not changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "not zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change host linked templates (remove all templates)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
link_templates:
|
||||||
|
-
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change host linked templates (check we have no templates left)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
link_templates:
|
||||||
|
-
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have not changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "not zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change host status"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
status: disabled
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change host status (again)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
status: disabled
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have not changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "not zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change host inventory mode"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
inventory_mode: automatic
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change host inventory mode"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
inventory_mode: automatic
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have not changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "not zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change host inventory data (one field)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
inventory_zabbix:
|
||||||
|
tag: test-tag-two
|
||||||
|
alias: test-alias
|
||||||
|
notes: "Special Informations: test-info"
|
||||||
|
location: test-location
|
||||||
|
site_rack: test-rack
|
||||||
|
os: test-os
|
||||||
|
hardware: test-hw
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change host inventory data (again)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
inventory_zabbix:
|
||||||
|
tag: test-tag-two
|
||||||
|
alias: test-alias
|
||||||
|
notes: "Special Informations: test-info"
|
||||||
|
location: test-location
|
||||||
|
site_rack: test-rack
|
||||||
|
os: test-os
|
||||||
|
hardware: test-hw
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have not changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "not zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: remove host proxy"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
proxy: ''
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: add host proxy"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
proxy: ExampleProxy
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: add host proxy (again)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
proxy: ExampleProxy
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have not changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "not zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change tls settings"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
tls_psk_identity: test2
|
||||||
|
tls_connect: 4
|
||||||
|
tls_accept: 7
|
||||||
|
tls_psk: 123456789abcdef123456789abcdef13
|
||||||
|
tls_issuer: AcmeCorp
|
||||||
|
tls_subject: AcmeCorpServer
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change tls settings (again)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
tls_psk_identity: test2
|
||||||
|
tls_connect: 4
|
||||||
|
tls_accept: 7
|
||||||
|
tls_psk: 123456789abcdef123456789abcdef13
|
||||||
|
tls_issuer: AcmeCorp
|
||||||
|
tls_subject: AcmeCorpServer
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have not changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "not zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change interface settings (remove one)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
interfaces:
|
||||||
|
- type: 1
|
||||||
|
main: 1
|
||||||
|
useip: 1
|
||||||
|
ip: 10.1.1.1
|
||||||
|
dns: ""
|
||||||
|
port: 10050
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change interface settings (again)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
interfaces:
|
||||||
|
- type: 1
|
||||||
|
main: 1
|
||||||
|
useip: 1
|
||||||
|
ip: 10.1.1.1
|
||||||
|
dns: ""
|
||||||
|
port: 10050
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have not changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "not zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change interface settings (add one interface using force=no)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
interfaces:
|
||||||
|
- type: 4
|
||||||
|
main: 1
|
||||||
|
useip: 1
|
||||||
|
ip: 10.1.1.1
|
||||||
|
dns: ""
|
||||||
|
port: 12345
|
||||||
|
force: no
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: change interface settings (verify that we are at two interfaces)"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
interfaces:
|
||||||
|
- type: 1
|
||||||
|
main: 1
|
||||||
|
useip: 1
|
||||||
|
ip: 10.1.1.1
|
||||||
|
dns: ""
|
||||||
|
port: 10050
|
||||||
|
- type: 4
|
||||||
|
main: 1
|
||||||
|
useip: 1
|
||||||
|
ip: 10.1.1.1
|
||||||
|
dns: ""
|
||||||
|
port: 12345
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: expect to succeed and that things have not changed
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "not zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: attempt to delete host created earlier"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
state: absent
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: deleting a host is a change, right?
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "zabbix_host1 is changed"
|
||||||
|
|
||||||
|
- name: "test: attempt deleting a non-existant host"
|
||||||
|
local_action:
|
||||||
|
module: zabbix_host
|
||||||
|
server_url: "{{ zabbix_server_url }}"
|
||||||
|
login_user: "{{ zabbix_login_user }}"
|
||||||
|
login_password: "{{ zabbix_login_password }}"
|
||||||
|
host_name: ExampleHost
|
||||||
|
state: absent
|
||||||
|
register: zabbix_host1
|
||||||
|
|
||||||
|
- name: deleting a non-existant host is not a change, right?
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "not zabbix_host1 is changed"
|
Loading…
Reference in a new issue