Closed markuman closed 1 year ago
I can't reproduce.
How did you get the output with expected results?
with the zabbix_hostmacro
module.
- name: host macros for zabbix.lekker.de
with_items:
- macro: '{$CERT.EXPIRY.WARN}'
value: '14'
- macro: '{$CERT.WEBSITE.HOSTNAME}'
value: 'zabbix.mydomain.tld'
- macro: '{$CERT.WEBSITE.IP}'
value: "{{ lookup('dig', 'zabbix.mydomain.tld') }}"
- macro: '{$CERT.WEBSITE.PORT}'
value: '443'
community.zabbix.zabbix_hostmacro:
host_name: zabbix.mydomain.tld
macro_name: "{{ item.macro }}"
macro_value: "{{ item.value }}"
state: present
How I am trying to re-produce:
(env_py39_ans213) ey@ls1:~/ansible$ cat module_test1.yml
(env_py39_ans213) ey@ls1:~/ansible$ cat module_test1.yml
- hosts: all
gather_facts: false
tasks:
- name: Create host group
zabbix_group:
host_groups:
- letsencrypt
- name: Create host
zabbix_host:
host_name: Example Host
interfaces:
- type: 1
main: 1
useip: 0
dns: localhost
port: "10050"
host_groups:
- letsencrypt
link_templates:
- Website certificate by Zabbix agent 2
status: enabled
state: present
tls_connect: 1
tls_accept: 1
tags:
- tag: env
value: prod
macros:
- macro: '{$CERT.EXPIRY.WARN}'
value: '14'
- macro: '{$CERT.WEBSITE.HOSTNAME}'
value: 'zabbix.mydomain.tld'
- macro: '{$CERT.WEBSITE.IP}'
value: '1.1.1.1'
- macro: '{$CERT.WEBSITE.PORT}'
value: '443'
Then running:
(env_py39_ans213) ey@ls1:~/ansible$ ansible-playbook -i inventories/modules_test.yml module_test1.yml -vv
<snip>
changed: [ls1] => {
"changed": true,
"invocation": {
"module_args": {
"ca_cert": null,
"description": null,
"force": true,
"host_groups": [
"letsencrypt"
],
"host_name": "Example Host",
"http_login_password": null,
"http_login_user": null,
"interfaces": [
{
"details": {},
"dns": "localhost",
"ip": "",
"main": 1,
"port": "10050",
"type": 1,
"useip": 0
}
],
"inventory_mode": null,
"inventory_zabbix": null,
"ipmi_authtype": null,
"ipmi_password": null,
"ipmi_privilege": null,
"ipmi_username": null,
"link_templates": [
"Website certificate by Zabbix agent 2"
],
"login_password": null,
"login_user": null,
"macros": [
{
"description": "",
"macro": "{$CERT.EXPIRY.WARN}",
"type": "0",
"value": "14"
},
{
"description": "",
"macro": "{$CERT.WEBSITE.HOSTNAME}",
"type": "0",
"value": "zabbix.mydomain.tld"
},
{
"description": "",
"macro": "{$CERT.WEBSITE.IP}",
"type": "0",
"value": "1.1.1.1"
},
{
"description": "",
"macro": "{$CERT.WEBSITE.PORT}",
"type": "0",
"value": "443"
}
],
"proxy": null,
"server_url": null,
"state": "present",
"status": "enabled",
"tags": [
{
"tag": "env",
"value": "prod"
}
],
"timeout": null,
"tls_accept": 1,
"tls_connect": 1,
"tls_psk": null,
"tls_psk_identity": null,
"tls_subject": null,
"validate_certs": null,
"visible_name": null
}
},
"result": "Successfully added host Example Host (None) and linked with template '['Website certificate by Zabbix agent 2']'"
}
and I see all the macros in the host.
(env_py39_ans213) ey@ls1:~/ansible$ ansible --version
ansible [core 2.13.0]
config file = /home/ey/ansible/ansible.cfg
configured module search path = ['/home/ey/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/ey/env_py39_ans213/lib/python3.9/site-packages/ansible
ansible collection location = /home/ey/.ansible/collections:/usr/share/ansible/collections
executable location = /home/ey/env_py39_ans213/bin/ansible
python version = 3.9.5 (default, Nov 23 2021, 15:27:38) [GCC 9.3.0]
jinja version = 3.1.2
libyaml = True
(env_py39_ans213) ey@ls1:~/ansible$ ansible-galaxy collection list | grep zabb community.zabbix 1.9.2
Please provide your `ansible --version` and `ansible-galaxy collection list | grep zabbix`, also provide full output of ansible-playbook run with `-vvv`
hmmmm I cannot reproduce it myself anymore...
sorry for your wasted time!
SUMMARY
I am using community.zabbix 1.9.2 with zabbix 6.0 LTS server and try to add an host and set some macros.
The host is set correctly, but the macros are ignored and are empty.
ISSUE TYPE
COMPONENT NAME
zabbix_host
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT / Zabbix Version
STEPS TO REPRODUCE
see example task above.
EXPECTED RESULTS
ACTUAL RESULTS
the host_info module returns below after it was set.