dj-wasabi / ansible-zabbix-agent

Installing and maintaining zabbix-agent for RedHat/Debian/Ubuntu/Windows/Suse.
https://galaxy.ansible.com/dj-wasabi/zabbix-agent
MIT License
327 stars 249 forks source link

creating hosts / linking templates fails #57

Closed kamilkrzeminski closed 7 years ago

kamilkrzeminski commented 7 years ago

I have issue similar to this #31, but now there's no Library folder anymore.

    },
    "msg": "Hostgroup not found: Containers"
}
},
    "msg": "Template not found: Template App Zabbix Agent"
}

My config is:

My code:

    - role: dj-wasabi.zabbix-agent
      agent_server: "{{monitoring_server_ip}}"
      agent_serveractive: "{{monitoring_server_ip}}"
      zabbix_repo: zabbix
      zabbix_url: "{{monitoring_server_url}}"
      zabbix_api_use: true
      zabbix_api_user: "{{monitoring_api_user}}"
      zabbix_api_pass: "{{monitoring_api_password}}"
      zabbix_create_host: present
      zabbix_api_create_hosts: True
      zabbix_host_groups:
        - Containers
      zabbix_link_templates: 
        - "Template App Zabbix Agent"

Both group and template exist.

dj-wasabi commented 7 years ago

The Library folder is removed a while back, as the modules are now available within Ansible itself.

Are you sure that the provided username and password works correctly? Does the user have enough rights in Zabbix?

kamilkrzeminski commented 7 years ago

Yes, I'm sure that credentials are ok, I event created a temporary user with superadmin rights to rule out misconfiguration issue. Are you sure that your role works fine with Zabbix 3.2? I've noticed that zabbix-api in the newest version (0.4) supports Zabbix<=2.4, so I think that might be a problem.

dj-wasabi commented 7 years ago

Hi @kamilkrzeminski

I deleted an host in my environment (CentOS 7, Zabbix 3.2.3) and executed the role and host is created via the API.

TASK [zabbix-agent : Make sure the zabbix-agent service is running] ************
ok: [vserver-209]

TASK [zabbix-agent : Create hostgroups] ****************************************
ok: [vserver-209 -> localhost]

TASK [zabbix-agent : Create a new host or update an existing host's info] ******
changed: [vserver-209 -> localhost]

TASK [zabbix-agent : Updating host configuration with macros] ******************

PLAY RECAP *********************************************************************
vserver-209                : ok=13   changed=1    unreachable=0    failed=0 
kamilkrzeminski commented 7 years ago

@dj-wasabi could you please provide your version of Ansible and zabbix-api library?

dj-wasabi commented 7 years ago

Yes:

 (master) $ pip list | grep -i zabb
zabbix-api (0.4)

Ansible version:

 (master) $ ansible --version
ansible 2.2.0.0
  config file = /git/ansible/environment/ansible.cfg
  configured module search path = ['Library']
kamilkrzeminski commented 7 years ago

Well, it seems that we have exactly the same software versions. I purged my Ansible configuration, purged and reinstalled zabbix-api, and reprovisioned Zabbix Server - and now it works like charm. Seems to be some issue by my side. Apologies for taking your time and thanks for help.

"result": "Successfully added host host02 (172.23.0.24) and linked with template '['Template OS Linux']'"
dj-wasabi commented 7 years ago

No worries @kamilkrzeminski Glad to help and enjoy your setup. :-)