Repository URL to install this package:
|
Version:
6.0.0 ▾
|
---
- name: "API | Installing the Zabbix-api package on localhost"
pip:
name: zabbix-api
state: present
register: zabbix_api_package_installed
until: zabbix_api_package_installed is succeeded
delegate_to: localhost
run_once: true
become: "{{ zabbix_agent_become_on_localhost }}"
when:
- zabbix_install_pip_packages | bool
- (zabbix_api_create_hostgroup | bool) or (zabbix_api_create_hosts | bool)
- name: "API | Create host groups"
zabbix_group:
server_url: "{{ zabbix_api_server_url }}"
http_login_user: "{{ zabbix_api_http_user | default(zabbix_http_user | default(omit)) }}"
http_login_password: "{{ zabbix_api_http_password | default(zabbix_http_password | default(omit)) }}"
login_user: "{{ zabbix_api_login_user }}"
login_password: "{{ zabbix_api_login_pass }}"
host_group: "{{ zabbix_host_groups }}"
state: "{{ zabbix_agent_hostgroups_state }}"
validate_certs: "{{ zabbix_api_validate_certs|default(omit) }}"
timeout: "{{ zabbix_api_timeout }}"
when:
- zabbix_api_create_hostgroup | bool
register: zabbix_api_hostgroup_created
until: zabbix_api_hostgroup_created is succeeded
delegate_to: localhost
become: false
tags:
- api
- name: "API | Create a new host or update an existing host's info"
zabbix_host:
server_url: "{{ zabbix_api_server_url }}"
http_login_user: "{{ zabbix_api_http_user | default(zabbix_http_user | default(omit)) }}"
http_login_password: "{{ zabbix_api_http_password | default(zabbix_http_password | default(omit)) }}"
login_user: "{{ zabbix_api_login_user }}"
login_password: "{{ zabbix_api_login_pass }}"
host_name: "{{ zabbix_agent_hostname }}"
host_groups: "{{ zabbix_host_groups }}"
link_templates: "{{ zabbix_agent_link_templates }}"
status: "{{ zabbix_host_status }}"
state: "{{ zabbix_agent_host_state }}"
force: "{{ zabbix_agent_host_update }}"
proxy: "{{ zabbix_agent_proxy }}"
inventory_mode: "{{ zabbix_agent_inventory_mode }}"
interfaces: "{{ zabbix_agent_interfaces }}"
visible_name: "{{ zabbix_agent_visible_hostname | default(zabbix_agent_hostname) }}"
tls_psk: "{{ zabbix_agent_tlspsk_secret | default(omit) }}"
tls_psk_identity: "{{ zabbix_agent_tlspskidentity | default(omit) }}"
tls_issuer: "{{ zabbix_agent_tlsservercertissuer | default(omit) }}"
tls_subject: "{{ zabbix_agent_tls_subject | default(omit) }}"
tls_accept: "{{ zabbix_agent_tls_config[zabbix_agent_tlsaccept if zabbix_agent_tlsaccept else 'unencrypted'] }}"
tls_connect: "{{ zabbix_agent_tls_config[zabbix_agent_tlsconnect if zabbix_agent_tlsconnect else 'unencrypted'] }}"
validate_certs: "{{ zabbix_api_validate_certs | default(omit) }}"
timeout: "{{ zabbix_api_timeout }}"
description: "{{ zabbix_agent_description | default(omit) }}"
inventory_zabbix: "{{ zabbix_agent_inventory_zabbix | default({}) }}"
ipmi_authtype: "{{ zabbix_agent_ipmi_authtype | default(omit) }}"
ipmi_password: "{{ zabbix_agent_ipmi_password| default(omit) }}"
ipmi_privilege: "{{ zabbix_agent_ipmi_privilege | default(omit) }}"
ipmi_username: "{{ zabbix_agent_ipmi_username | default(omit) }}"
when:
- not zabbix_agent2
register: zabbix_api_host_created
until: zabbix_api_host_created is succeeded
delegate_to: localhost
become: false
changed_when: false
tags:
- api
- name: "API | Create a new host using agent2 or update an existing host's info"
zabbix_host:
server_url: "{{ zabbix_api_server_url }}"
http_login_user: "{{ zabbix_api_http_user | default(zabbix_http_user | default(omit)) }}"
http_login_password: "{{ zabbix_api_http_password | default(zabbix_http_password | default(omit)) }}"
login_user: "{{ zabbix_api_login_user }}"
login_password: "{{ zabbix_api_login_pass }}"
host_name: "{{ zabbix_agent2_hostname }}"
host_groups: "{{ zabbix_host_groups }}"
link_templates: "{{ zabbix_agent_link_templates }}"
status: "{{ zabbix_host_status }}"
state: "{{ zabbix_agent_host_state }}"
force: "{{ zabbix_agent_host_update }}"
proxy: "{{ zabbix_agent_proxy }}"
inventory_mode: "{{ zabbix_agent_inventory_mode }}"
interfaces: "{{ zabbix_agent_interfaces }}"
visible_name: "{{ zabbix_agent_visible_hostname | default(zabbix_agent2_hostname) }}"
tls_psk: "{{ zabbix_agent2_tlspsk_secret | default(omit) }}"
tls_psk_identity: "{{ zabbix_agent2_tlspskidentity | default(omit) }}"
tls_issuer: "{{ zabbix_agent2_tlsservercertissuer | default(omit) }}"
tls_subject: "{{ zabbix_agent2_tls_subject | default(omit) }}"
tls_accept: "{{ zabbix_agent_tls_config[zabbix_agent2_tlsaccept if zabbix_agent2_tlsaccept else 'unencrypted'] }}"
tls_connect: "{{ zabbix_agent_tls_config[zabbix_agent2_tlsconnect if zabbix_agent2_tlsconnect else 'unencrypted'] }}"
validate_certs: "{{ zabbix_api_validate_certs | default(omit) }}"
timeout: "{{ zabbix_api_timeout }}"
description: "{{ zabbix_agent_description | default(omit) }}"
inventory_zabbix: "{{ zabbix_agent_inventory_zabbix | default({}) }}"
ipmi_authtype: "{{ zabbix_agent_ipmi_authtype | default(omit) }}"
ipmi_password: "{{ zabbix_agent_ipmi_password| default(omit) }}"
ipmi_privilege: "{{ zabbix_agent_ipmi_privilege | default(omit) }}"
ipmi_username: "{{ zabbix_agent_ipmi_username | default(omit) }}"
when:
- zabbix_agent2 | bool
register: zabbix_api_host_created
until: zabbix_api_host_created is succeeded
delegate_to: localhost
become: false
changed_when: false
tags:
- api
- name: "API | Updating host configuration with macros"
zabbix_hostmacro:
server_url: "{{ zabbix_api_server_url }}"
http_login_user: "{{ zabbix_api_http_user | default(zabbix_http_user | default(omit)) }}"
http_login_password: "{{ zabbix_api_http_password | default(zabbix_http_password | default(omit)) }}"
login_user: "{{ zabbix_api_login_user }}"
login_password: "{{ zabbix_api_login_pass }}"
host_name: "{{ (zabbix_agent2 | bool) | ternary(zabbix_agent2_hostname, zabbix_agent_hostname) }}"
macro_name: "{{ item.macro_key }}"
macro_value: "{{ item.macro_value }}"
macro_type: "{{ item.macro_type|default('text') }}"
validate_certs: "{{ zabbix_api_validate_certs | default(omit) }}"
timeout: "{{ zabbix_api_timeout }}"
with_items: "{{ zabbix_agent_macros | default([]) }}"
when:
- zabbix_agent_macros is defined
- item.macro_key is defined
register: zabbix_api_hostmarcro_created
until: zabbix_api_hostmarcro_created is succeeded
delegate_to: localhost
become: false
tags:
- api