ansible-collections / community.zabbix

Zabbix Ansible modules
http://galaxy.ansible.com/community/zabbix
Other
315 stars 265 forks source link

Zabbix Agent2 Deployment fails under Windows #1265

Closed david-sieg closed 1 month ago

david-sieg commented 1 month ago
SUMMARY

Zabbix Agent2 deployment fails due to wrong definition of config file in task.

- name: "Windows | Set variables specific to Zabbix"
  ansible.builtin.set_fact:
    zabbix_win_svc_name: Zabbix Agent
    zabbix_win_exe_path: '{{ zabbix_win_install_dir }}\bin\zabbix_agentd.exe'
    zabbix_win_config_name: "zabbix_agentd.conf"
    zabbix2_win_svc_name: Zabbix Agent 2
    zabbix2_win_exe_path: '{{ zabbix_win_install_dir }}\bin\zabbix_agent2.exe'
    zabbix2_win_config_name: "zabbix_agentd2.conf"
  tags:
    - always

Using older version resolves problem, due to correct defined var.

Filename is "zabbix_agent2.conf" after extraction of archive not "zabbix_agentd2.conf".

ISSUE TYPE
COMPONENT NAME

win_command tasks fails:

- name: "Windows | Register Service"
  ansible.windows.win_command: '"{{ zabbix_win_exe_path }}" --config "{{ zabbix_win_install_dir_conf }}\{{ zabbix_win_config_name }}" --install'
  when: not zabbix_windows_service.exists
  tags:
    - service
ANSIBLE VERSION

Ansible 2.15

OS / ENVIRONMENT / Zabbix Version

Windows Server 2022

STEPS TO REPRODUCE

Deploy of zabbix-agent-role with newest collection version.

EXPECTED RESULTS

Successful deployment of Zabbix Agent.

ACTUAL RESULTS
fatal: [windows-test.domain.local]:
FAILED! => {"changed": true, "cmd": "\"C:\\Program Files\\Zabbix Agent 2\\\\bin\\zabbix_agent2.exe\" --config \"C:\\Program Files\\Zabbix Agent 2\\\\conf\\zabbix_agentd2.conf\" --install",
"delta": "0:00:01.316045",
"end": "2024-06-03 06:52:35.137037",
"msg": "non-zero return code",
"rc": 1,
"start": "2024-06-03 06:52:33.820992",
"stderr": "zabbix_agent2 [456]: ERROR: cannot open configuration file: open C:\\Program Files\\Zabbix Agent 2\\\\conf\\zabbix_agentd2.conf: The system cannot find the file specified.\n",
"stderr_lines": ["zabbix_agent2 [456]: ERROR: cannot open configuration file: open C:\\Program Files\\Zabbix Agent 2\\\\conf\\zabbix_agentd2.conf: The system cannot find the file specified."],
"stdout": "",
"stdout_lines": []}
david-sieg commented 1 month ago

PR #1267

Should fixe the issue.