ansible-collections / community.zabbix

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

Windows | missing task for adding a TLS-PSK file #619

Closed PrismaComputer closed 2 years ago

PrismaComputer commented 2 years ago
SUMMARY

The TLS-PSK file is not transfered / created

ISSUE TYPE
COMPONENT NAME

community.zabbix.zabbix_agent 1.51 but also github master!!

IMPORTANT

You fixed a bug here, unclear for me if fixed in GitHub master: https://gitlab.gtmh-telecom.com/kaungchit/ansible-zabbix-agent/-/commit/d184071ca53c6926385bc6253a4084859561a1f0 But does this fix really work also for agent2 when only zabbix_agent2_tlspskfile variables is set?

ANSIBLE VERSION
ansible [core 2.12.1]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/xxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/xxx/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, Sep 28 2021, 16:10:42) [GCC 9.3.0]
  jinja version = 2.10.1
  libyaml = True
OS / ENVIRONMENT / Zabbix Version

Ubuntu 20.04

STEPS TO REPRODUCE

Just try to setup agent2 on a fresh Windows machine. Like this, nothing more.

     - name: Install zabbix-agent2
       role: zabbix_agent
       zabbix_agent2: true
       zabbix_agent_server: '127.0.0.1'
       zabbix_agent_serveractive: '{{ zabbix_server }}'
       zabbix_agent_hostname: '{{ ansible_host }}'
       zabbix_agent2_hostname: '{{ ansible_host }}'
       zabbix_visible_hostname: '{{ ansible_hostname }}'
       zabbix_url: 'https://{{ zabbix_server }}'
       zabbix_api_user: '{{ enc_zabbix_api_user }}'
       zabbix_api_pass: '{{ enc_zabbix_api_pass }}'
       zabbix_api_create_hosts: true
       zabbix_api_create_hostgroup: true
       zabbix_create_host: present
       zabbix_host_groups:
         - "{{ host_group }}"
         - "{{ hosted_by }}"
       zabbix_link_templates:
         - Template OS Windows Active
       zabbix_agent2_tlsaccept: psk
       zabbix_agent2_tlsconnect: psk
       zabbix_agent2_tlspskidentity: '{{ enc_zabbix_agent_tlspskidentity }}'
       zabbix_agent2_tlspskfile: '{{ zabbix_win_install_dir }}\zabbix_agentd.psk'
       zabbix_agent2_tlspsk_secret: '{{ enc_zabbix_agent_tlspsk_secret  }}'
       zabbix_agent_interfaces:
         - type: '1'
           main: True
           useip: True
           ip: 127.0.0.1
       zabbix_inventory_mode: automatic
EXPECTED RESULTS

Service permanently running.

ACTUAL RESULTS

Service does start and terminates immediately because of missing PSK file.

2022/01/27 20:25:27.591566 Starting Zabbix Agent 2 (5.2.4)
2022/01/27 20:25:28.121859 cannot use encryption configuration: invalid TLSPSKFile configuration parameter: open C:\Zabbix\zabbix_agentd.psk: Das System kann die angegebene Datei nicht finden.
PrismaComputer commented 2 years ago

Inspected the code:

windows.yml misses the transfer of tlspskfile content when tlspsk_auto is false. linux.yml does transfer tlspskfile when tlspsk_auto is false.