community.zabbix
community.zabbix copied to clipboard
Cannot change "zabbix_api_*" variables via inventory/group_vars
ISSUE TYPE
- Bug Report
SUMMARY
While setting the following variables in playbook or in group_vars/all.yml works:
zabbix_api_server_host: HOST
zabbix_api_server_port: 80
ansible_zabbix_url_path: "api_jsonrpc.php"
zabbix_api_login_pass: PASS
zabbix_api_login_user: USER
We cannot figure out how to overwrite some of these variables via group_vars/GROUP.yml as per standard Ansible behavior. The only one that seems working is "zabbix_api_server_host" var.
COMPONENT NAME
community.zabbix.zabbix_agent v2.1.0
ANSIBLE VERSION
# ansible --version
ansible [core 2.15.2]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /root/.local/lib/python3.9/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /root/.local/bin/ansible
python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
CONFIGURATION
# ansible-config dump --only-changed
CONFIG_FILE() = /etc/ansible/ansible.cfg
DEFAULT_HOST_LIST(/etc/ansible/ansible.cfg) = ['/etc/ansible/inventory.d']
DEFAULT_LOAD_CALLBACK_PLUGINS(/etc/ansible/ansible.cfg) = True
DEFAULT_STDOUT_CALLBACK(/etc/ansible/ansible.cfg) = yaml
OS / ENVIRONMENT / Zabbix Version
OS (ansible): Debian 11 OS (zabbix server): Debian 12 Target OS: windows 2016,2019,2022; Debian 11, Fedora Zabbix: 6.4.2
STEPS TO REPRODUCE
Playbook:
---
- name: "Install & configure zabbix-agent playbook"
hosts: "{{ variable_host|default('all') }}"
roles:
- role: community.zabbix.zabbix_agent
vars:
zabbix_agent2: true
zabbix_agent2_tlspsk_auto: true
zabbix_api_create_hostgroup: true
zabbix_api_server_host: zabbix-server-01.example.com
#zabbix_api_server_port: 80 (DEFAULT)
ansible_zabbix_url_path: "api_jsonrpc.php"
zabbix_api_login_pass: PASS
#zabbix_api_login_user: Admin (DEFAULT)
zabbix_api_create_hosts: true
zabbix_agent_hostgroups_state: present
zabbix_agent_host_state: present
zabbix_agent_inventory_mode: automatic
zabbix_useuip: 0
zabbix_agent_interfaces:
- type: 1
main: 1
useip: "{{ zabbix_useuip }}"
ip: "{{ zabbix_agent_ip }}"
dns: "{{ zabbix_agent2_hostname }}"
port: "{{ zabbix_agent_listenport }}"
Inventory
---
linux:
children:
cluster:
children:
managers:
hosts:
server-00:
workers:
hosts:
server-[01:03]:
fedora:
hosts:
server-FF:
windows:
children:
server_2016:
hosts:
WIN-2016:
server_2019:
hosts:
WIN-2019:
server_2022:
hosts:
WIN-2022:
Group variables (inventory/group_vars/windows.yml)
---
zabbix_host_groups:
- Windows Servers
ansible_user: "administrator"
ansible_shell_type: powershell
zabbix_api_server_host: zabbix-server-02.example.com
zabbix_api_server_port: 8080
EXPECTED RESULTS
We exepect the the role honor group dedicated variables
Eg. zabbix_api_server_port
for windows
group is set 8080
but the role connects to the default 80 (verified with tcpdump).
ACTUAL RESULTS
Only zabbix_api_server_host
is inherited from group_vars.
WORKAROUND
To work around the problem we have the same credendial, url, port, user and password on both zabbix servers (prod and test).