ansible-collections / community.zabbix

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

The conditional check 'zabbix_agent2_tlspskfile' failed #613

Closed PrismaComputer closed 2 years ago

PrismaComputer commented 2 years ago
SUMMARY

The conditional check 'zabbix_agent2_tlspskfile' failed

ISSUE TYPE
COMPONENT NAME

community.zabbix:1.5.1

ANSIBLE VERSION
ansible 2.9.6
  config file = /root/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, Sep 28 2021, 16:10:42) [GCC 9.3.0]
CONFIGURATION
DEFAULT_HOST_LIST(/root/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/ansible.cfg) = ['/root/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/hosts']
HOST_KEY_CHECKING(/root/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/ansible.cfg) = False
INTERPRETER_PYTHON(/root/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/ansible.cfg) = /usr/bin/python3
RETRY_FILES_ENABLED(/root/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/ansible.cfg) = True
OS / ENVIRONMENT / Zabbix Version

Ubuntu 20.04

STEPS TO REPRODUCE

We had the role configured same same on other servers. See yml below. Worked before. Then updated community.zabbix:1.4.0 -> community.zabbix:1.5.1 -> Error

     - 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 Linux Active
         - MySQL by Zabbix agent 2 active
         - Website certificate by Zabbix agent 2 active
       zabbix_agent2_tlsaccept: psk
       zabbix_agent2_tlsconnect: psk
       zabbix_agent2_tlspskidentity: '{{ enc_zabbix_agent_tlspskidentity }}'
       zabbix_agent2_tlspskfile: '/etc/zabbix/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
       zabbix_macros:
         - macro_key: "{$MYSQL.DSN}"
           macro_value: "tcp://127.0.0.1:3306"
         - macro_key: "{$MYSQL.USER}"
           macro_value: '{{ enc_zabbix_mysql_monitor_user }}'
         - macro_key: "{$MYSQL.PASSWORD}"
           macro_value: '{{ enc_zabbix_mysql_monitor_password }}'
         - macro_key: "{$CERT.WEBSITE.HOSTNAME}"
           macro_value: '{{ ansible_host }}'
EXPECTED RESULTS

OK

ACTUAL RESULTS

fatal

[DEPRECATION WARNING]: evaluating 'zabbix_agent2_tlspskfile' as a bare variable, this behaviour will go away and you might need to add |bool to the expression in the future. Also see CONDITIONAL_BARE_VARS configuration toggle. This feature
 will be removed in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
fatal: [ionos1]: FAILED! => {"msg": "The conditional check 'zabbix_agent2_tlspskfile' failed. The error was: template error while templating string: unexpected '/'. String: {% if /etc/zabbix/zabbix_agentd.psk %} True {% else %} False {% endif %}\n\nThe error appears to be in '/root/.ansible/collections/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Linux.yml': line 140, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"Create directory for PSK file if not exist (zabbix-agent2)\"\n  ^ here\n"}
PrismaComputer commented 2 years ago

As I learned from #614, this "seems" to be a known issue and "might" already have been fixed in 1.6.0. It would be very appreciated if this report would be marked as bug, if it's really a bug. Because, even if it's not fixed in 1.6.0, then it may be fixed later...

ragingpastry commented 2 years ago

You can check to see if its fixed by installing the collection from master

PrismaComputer commented 2 years ago

Is 1.6.0 available in galaxy as beta? I would rather prefer installing via command. ansible-galaxy install community.zabbix:1.6.0-beta.X ? Which nomenclature? And would it be compatible to 5.x Zabbix? Or why will 1.6.0 be released together with Zabbix 6.0?

PrismaComputer commented 2 years ago

Problem is introduced through a mixture of zabbix_agent and zabbix_agent2 properties. Through this, some "isset" decisions are misled. Which is on the one hand clearly our fault but on the other hand caused by a questionable design.