- name: Test Zabbix plugin
hosts: all
tasks:
# Set following variables for Zabbix Server host in play or inventory
- name: Set connection specific variables
set_fact:
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: ""
when: inventory_hostname in groups["zabbix"]
# If you want to use Username and Password to be authenticated by Zabbix Server
- name: Set credentials to access Zabbix Server API
set_fact:
ansible_user: "ansible"
ansible_httpapi_pass: "..."
delegate_to: "{{ zabbix_host }}"
##### Add Zabbix agent on Zabbix server
- name: create host in Zabbix
community.zabbix.zabbix_host:
host_name: "testhost.example.com"
host_groups:
- Linux servers
link_templates:
- Linux by Zabbix agent
interfaces:
- type: 1
main: 1
useip: 1
ip: "127.0.0.1"
dns: "testhost.example.com"
port: 10050
delegate_to: "{{ zabbix_host }}"
EXPECTED RESULTS
New host "testhost.example.com" is created in zabbix.
ACTUAL RESULTS
API plugin cannot be loaded. No connection to zabbix can be established.
Not sure if this is the correct way, but it seems that the file plugins/httpapi/zabbix.py needs to be in the directory plugins/connection.
At least that worked for me, can't estimate if there are any side effects.
fatal: [...]: FAILED! => {"msg": "unable to load API plugin for network_os community.zabbix.zabbix"}
SUMMARY
When using the example code from https://docs.ansible.com/ansible/latest/collections/community/zabbix/zabbix_host_module.html to use the host module, a error "unable to load API plugin for platform type community.zabbix" appears.
ISSUE TYPE
COMPONENT NAME
community.zabbix.zabbix httpapi
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT / Zabbix Version
OS: Debian 11 Zabbix: 6.4.2 Zabbix Collection: 2.0.0 Zabbix API: 0.5.6
STEPS TO REPRODUCE
EXPECTED RESULTS
New host "testhost.example.com" is created in zabbix.
ACTUAL RESULTS
API plugin cannot be loaded. No connection to zabbix can be established.
Not sure if this is the correct way, but it seems that the file plugins/httpapi/zabbix.py needs to be in the directory plugins/connection.
At least that worked for me, can't estimate if there are any side effects.