community.zabbix.zabbix_httptest module – Create/delete Zabbix httptests aka Web Scenarios
Note
This module is part of the community.zabbix collection (version 4.2.0).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.zabbix.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.zabbix.zabbix_httptest.
Synopsis
Create httptests if they do not exist.
Delete existing httptests if they exist.
Requirements
The below requirements are needed on the host that executes this module.
python >= 3.9
Parameters
Parameter |
Comments |
|---|---|
Name of host to add httptest to. |
|
Basic Auth password |
|
Basic Auth login |
|
Name of httptest to create or delete. |
|
Parameters to create/update httptest with. Required if state is “present”. Parameters as defined at https://www.zabbix.com/documentation/current/en/manual/api/reference/httptest/object Additionally supported parameters are below. |
|
User agent string used by the httptest. |
|
Number of attempts before failing the httptest Alias for “retries” in API docs |
|
HTTP authentication method used by the httptest. Choices:
|
|
Status of the httptest. Overrides “status” in API docs. Choices:
|
|
HTTP headers used when performing the httptest. Overriden by steps headers. |
|
Name of the header field. |
|
Value of the header field. |
|
HTTP(S) proxy used by the httptest |
|
Update interval of the httptest. Alias for “delay” in API docs. |
|
New name for httptest |
|
Password to authenticate with the host. Used if Alias for “http_password” in API docs. |
|
Public SSL key file path for client authentication. |
|
Private SSL key file path for client authentication. |
|
Password of the private SSL key file. |
|
Status of the httptest. Choices:
|
|
Scenario steps for the httptest Required if state is “present” and creating an httptest. |
|
Whether to follow HTTP redirects. Choices:
|
|
HTTP headers used when performing the scenario step. Overrides params headers. |
|
Name of the header field. |
|
Value of the header field. |
|
Name of the scenario step. |
|
POST variables for the scenario step. |
|
Name of the POST field. |
|
Value of the POST field. |
|
Query fields used when performing the scenario step. |
|
Name of the query field. |
|
Value of the query field. |
|
Text that must be present in the response. |
|
Part of the HTTP response that the scenario step must retrieve. Choices:
|
|
Expected response status code. |
|
Request timeout of the scenario step. |
|
URL to be checked. |
|
Variables used when performing the scenario step. Overrides params variables. |
|
Name of the variable field. |
|
Value of the variable field. |
|
Tags of the httptest. |
|
Name of the httptest tag. |
|
Value of the httptest tag. |
|
Username to authenticate with the host. Used if Alias for “http_user” in API docs. |
|
httptest variables. Overriden by steps variables. |
|
Name of the variable field. |
|
Value of the variable field. |
|
Whether the httptest should verify the host’s hostname. Choices:
|
|
Whether the httptest should verify the host’s certificate. Choices:
|
|
Create or delete httptest. Choices:
|
Examples
# If you want to use Username and Password to be authenticated by Zabbix Server
- name: Set credentials to access Zabbix Server API
ansible.builtin.set_fact:
ansible_user: Admin
ansible_httpapi_pass: zabbix
# If you want to use API token to be authenticated by Zabbix Server
# https://www.zabbix.com/documentation/current/en/manual/web_interface/frontend_sections/administration/general#api-tokens
- name: Set API token
ansible.builtin.set_fact:
ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895
# Create a web scenario on example_host
- name: create httptest
# set task level variables as we change ansible_connection plugin here
vars:
ansible_network_os: community.zabbix.zabbix
ansible_connection: httpapi
ansible_httpapi_port: 443
ansible_httpapi_use_ssl: true
ansible_httpapi_validate_certs: false
ansible_zabbix_url_path: 'zabbixeu' # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu
ansible_host: zabbix-example-fqdn.org
community.zabbix.zabbix_httptest:
name: example_host_website
host_name: example_host
params:
steps:
- name: Test
url: https://zabbix-example-fqdn.org
status_code: [200]
interval: 1h
enabled: True
state: present
# Change interval for existing Zabbix web scenario
- name: update rule
# set task level variables as we change ansible_connection plugin here
vars:
ansible_network_os: community.zabbix.zabbix
ansible_connection: httpapi
ansible_httpapi_port: 443
ansible_httpapi_use_ssl: true
ansible_httpapi_validate_certs: false
ansible_zabbix_url_path: 'zabbixeu' # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu
ansible_host: zabbix-example-fqdn.org
community.zabbix.zabbix_discoveryrule:
name: example_host_website
host_name: example_host
params:
interval: 2h
state: present
# Delete web scenario
- name: delete rule
# set task level variables as we change ansible_connection plugin here
vars:
ansible_network_os: community.zabbix.zabbix
ansible_connection: httpapi
ansible_httpapi_port: 443
ansible_httpapi_use_ssl: true
ansible_httpapi_validate_certs: false
ansible_zabbix_url_path: 'zabbixeu' # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu
ansible_host: zabbix-example-fqdn.org
community.zabbix.zabbix_discoveryrule:
name: example_host_website
host_name: example_host
state: absent
- name: Rename Zabbix web scenario
# set task level variables as we change ansible_connection plugin here
vars:
ansible_network_os: community.zabbix.zabbix
ansible_connection: httpapi
ansible_httpapi_port: 443
ansible_httpapi_use_ssl: true
ansible_httpapi_validate_certs: false
ansible_zabbix_url_path: "zabbixeu" # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu
ansible_host: zabbix-example-fqdn.org
community.zabbix.zabbix_discoveryrule:
name: example_host_website
host_name: example_host
params:
new_name: new_example_host_website
state: present