Closed Bubbgump209 closed 1 year ago
I did a bit more digging and it seems my issue is a mix of bad documentation and unexpected behavior.
zabbix_api_server_url
does not work despite the UPGRADE docs suggesting that it should. Instead, this documentation and zabbix_api_server_host
does work.zabbix_api_use_ssl: true
, 80 is still the port that is used. One must explicitly set zabbix_api_server_port: 443
. This specifically seems to be a bug or at least very suboptimal. I would expect zabbix_api_use_ssl: true
to automatically use 443 and only require zabbix_api_server_port:
for non-standard ports.What finally worked:
- hosts: "{{ hostvars['localhost']['fqdn'] | default(host) }}"
roles:
- role: community.zabbix.zabbix_agent
zabbix_agent_become_on_localhost: true
zabbix_agent_hostname: "{{ansible_hostname}}"
zabbix_agent_server: 192.168.30.20
zabbix_agent_serveractive: 192.168.30.20
zabbix_api_server_host: zabbix.camdenacres.stream
zabbix_api_server_port: 443
ansible_zabbix_url_path: ""
zabbix_api_use: true
zabbix_api_use_ssl: true
zabbix_useuip: 0 # Use FQDN instead of IP.
zabbix_api_login_user: Admin
zabbix_api_login_pass: zabbix
zabbix_agent_host_state: present
zabbix_agent_version: 6.0
zabbix_api_create_hosts: true
zabbix_agent_tlsconnect: psk
zabbix_agent_tlsaccept: psk
zabbix_agent_tlspskidentity: "{{ UUID.stdout }}"
zabbix_agent_tlspskfile: /etc/zabbix/zabbix_agent.psk
zabbix_agent_tlspsk_secret: "{{ PSK.stdout }}"
zabbix_host_groups:
- Linux servers
zabbix_agent_link_templates:
- Template OS Linux LXC Container by Zabbix agent
zabbix_agent_userparameters:
- name: LXCZabbixAgent
SUMMARY
Registering an agent to the Zabbix server fails.
ISSUE TYPE
COMPONENT NAME
community.zabbix.zabbix_agent
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT / Zabbix Version
Tried to run against target hosts on Debian 11 and 12 VM (cloud image) and LXC.
Zabbix server 6.0.17 LTS.
community.zabbix 2.0.1 and 2.1.0 with both netcommon 4.1.0 and 5.1.2.
STEPS TO REPRODUCE
Command
InstallZabbixLXC.yml
EXPECTED RESULTS
I expect the Host to be registered in the Zabbix server using the PSK and ID provided by the playbook.
ACTUAL RESULTS
Everything in the role works until it reaches the point it needs to register with the Zabbix server at which case it fails. What is very curious is it appears to be calling https://localhost:80/api_jsonrpc.php instead of https://zabbix.camdenacres.stream/api_jsonrpc.php. I can't see where that would be coming from in the playbook.
Also, I have confirmed that I can indeed reach the Zabbix API from the target host as well as my localhost which is running Ansible.
Failed step output