Open emilbasv3 opened 10 months ago
Can you add debugging before this task https://github.com/ansible-collections/community.zabbix/blob/main/roles/zabbix_agent/tasks/main.yml#L74 just to show value of zabbix_api_server_port when you set this variable in group_vars/windows.yml ?
community.zabbix.zabbix_agent
role uses delegation https://github.com/ansible-collections/community.zabbix/blob/main/roles/zabbix_agent/tasks/api.yml#L10
delegate_to: "{{ zabbix_api_server_host }}"
zabbix_api_server_host
is not a member of your windows host group this is why zabbix_api_server_port
is not set correctly for API operations.
Can you add debugging before this task https://github.com/ansible-collections/community.zabbix/blob/main/roles/zabbix_agent/tasks/main.yml#L74 just to show value of zabbix_api_server_port when you set this variable in group_vars/windows.yml ?
Hi, i am is the emilbasv3's team we created a task before line 74:
- name: "Activate Debug"
debug:
var: "zabbix_api_server_port"
we changed port from 80
to 8080
, the print show that the variable is readed as below:
TASK [community.zabbix.zabbix_agent : Activate Debug] ************************************************************************************************************************************************************************************************************************************
ok: [WIN-23H3PDJ0CRT.example.com] =>
zabbix_api_server_port: 8080
ok: [WIN-QVJ14UN8PL2.example.com] =>
zabbix_api_server_port: 8080
ok: [WIN-33RUVE5NKBH.example.com] =>
zabbix_api_server_port: 8080
Our server is working on port 80
and all work on port 80
, so port 8080
is ignored (?)
TASK [community.zabbix.zabbix_agent : Run the API calls to Zabbix Server] ****************************************************************************************************************************************************************************************************************
included: /root/.local/lib/python3.9/site-packages/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/api.yml for WIN-23H3PDJ0CRT.example.com, WIN-QVJ14UN8PL2.example.com, WIN-33RUVE5NKBH.example.com
TASK [community.zabbix.zabbix_agent : API | Create host groups] **************************************************************************************************************************************************************************************************************************
ok: [WIN-33RUVE5NKBH.example.com -> v3-re-docker-test.example.com]
ok: [WIN-23H3PDJ0CRT.example.com -> v3-re-docker-test.example.com
ok: [WIN-QVJ14UN8PL2.example.com -> v3-re-docker-test.example.com]
TASK [community.zabbix.zabbix_agent : API | Create a new host or update an existing host's info] *****************************************************************************************************************************************************************************************
skipping: [WIN-23H3PDJ0CRT.example.com]
skipping: [WIN-QVJ14UN8PL2.example.com]
skipping: [WIN-33RUVE5NKBH.example.com]
TASK [community.zabbix.zabbix_agent : API | Create a new host using agent2 or update an existing host's info] ****************************************************************************************************************************************************************************
ok: [WIN-QVJ14UN8PL2.example.com -> v3-re-docker-test.example.com]
ok: [WIN-23H3PDJ0CRT.example.com -> v3-re-docker-test.example.com]
ok: [WIN-33RUVE5NKBH.example.com -> v3-re-docker-test.example.com]
TASK [community.zabbix.zabbix_agent : API | Updating host configuration with macros] *****************************************************************************************************************************************************************************************************
skipping: [WIN-23H3PDJ0CRT.example.com]
skipping: [WIN-QVJ14UN8PL2.example.com]
skipping: [WIN-33RUVE5NKBH.example.com]
TASK [community.zabbix.zabbix_agent : Including userparameters] **************************************************************************************************************************************************************************************************************************
skipping: [WIN-23H3PDJ0CRT.example.com]
skipping: [WIN-QVJ14UN8PL2.example.com]
skipping: [WIN-33RUVE5NKBH.example.com]
community.zabbix.zabbix_agent
role uses delegation https://github.com/ansible-collections/community.zabbix/blob/main/roles/zabbix_agent/tasks/api.yml#L10delegate_to: "{{ zabbix_api_server_host }}"
zabbix_api_server_host
is not a member of your windows host group this is whyzabbix_api_server_port
is not set correctly for API operations.
So.. is there any way to customize these variables per inventory host?
zabbix_api_server_host
zabbix_api_server_port
zabbix_api_login_pass
zabbix_api_login_user
Other than to have two or more distinct playbooks..
ISSUE TYPE
SUMMARY
While setting the following variables in playbook or in group_vars/all.yml works:
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
ANSIBLE VERSION
CONFIGURATION
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:
Inventory
Group variables (inventory/group_vars/windows.yml)
EXPECTED RESULTS
We exepect the the role honor group dedicated variables Eg.
zabbix_api_server_port
forwindows
group is set8080
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).