ansible-collections / community.zabbix

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

zabbix_agentd.conf ServerActive= and Server= is actively set to empty #404

Closed PrismaComputer closed 3 years ago

PrismaComputer commented 3 years ago
SUMMARY

zabbix_agentd.conf ServerActive= and Server= is actively set to empty

ISSUE TYPE
COMPONENT NAME

zabbix_agent

ANSIBLE VERSION
ansible 2.9.6
  config file = /var/xxx-server-config/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.5 (default, May 27 2021, 13:30:53) [GCC 9.3.0]
CONFIGURATION
DEFAULT_ASK_VAULT_PASS(/var/xxx-server-config/ansible.cfg) = True
DEFAULT_HOST_LIST(/var/xxx-server-config/ansible.cfg) = ['/var/xxx-server-config/hosts']
HOST_KEY_CHECKING(/var/xxx-server-config/ansible.cfg) = False
RETRY_FILES_ENABLED(/var/xxx-server-config/ansible.cfg) = True
OS / ENVIRONMENT / Zabbix Version

Ubuntu 20.04

STEPS TO REPRODUCE

The aim is to set up a zabbix agent in ACTIVE mode. Problem:

zabbix_agentd.conf server and serveractive is actively set to empty EVEN THOUGH I already tried fixed strings instead of {{ zabbix_server }}. By the way, zabbix_url: 'https://{{ zabbix_server }}' works and host and host_groups are created on Zabbix 5.2 server. So, this proofs the variable is filled. But anyway, tried already fixed strings.

Could it have to do with zabbix_agent_interfaces? We have manually set up hosts in zabbix server which work perfectly in ACTIVE mode, and they have the interface configuration shown in yml below. So I adapted it.

hosts file:

[xxx] master1 ansible_host=master1.xxx.com ansible_port=22 hosted_by=SuperHoster master2 ansible_host=master2.xxx.com ansible_port=22 hosted_by=SuperHoster

[xxx:vars] ansible_user=xxx ansible_ssh_private_key_file=./.ssh/id_rsa ansible_sudo_pass={{ enc_ansible_sudo_pass }} zabbix_server=zabbix.xxx.com

- hosts: '{{ host_group }}'
  become: true
  collections:
    - community.zabbix

  roles:
     - role: zabbix_agent
       agent_server: '{{ zabbix_server }}'
       agent_serveractive: '{{ zabbix_server }}'
       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
       zabbix_agent_tlsaccept: psk
       zabbix_agent_tlsconnect: psk
       zabbix_agent_tlspskidentity: '{{ enc_zabbix_agent_tlspskidentity }}'
       zabbix_agent_tlspsk_secret: '{{ enc_zabbix_agent_tlspsk_secret  }}'
       zabbix_agent_tlspskfile: /etc/zabbix/zabbix_agentd.psk
       zabbix_agent_interfaces:
         - type: '1'
           main: 1
           useip: 1
           ip: 127.0.0.1
EXPECTED RESULTS

zabbix_agentd.conf server=zabbix.xxx.com and serveractive=zabbix.xxx.com

ACTUAL RESULTS

zabbix_agentd.conf server= and serveractive= is actively set to empty.

dj-wasabi commented 3 years ago

Hi @PrismaComputer

You'll need to configure it with:

       zabbix_agent_server: '{{ zabbix_server }}'
       zabbix_agent_serveractive: '{{ zabbix_server }}'

See the documentation on: https://github.com/ansible-collections/community.zabbix/blob/main/docs/ZABBIX_AGENT_ROLE.md