ansible-collections / community.zabbix

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

Fix agent role when zabbix_agent_listenip is undefined #1245

Closed sblaisot closed 1 month ago

sblaisot commented 1 month ago
SUMMARY

zabbix.agent role in 2.5.0 fails when zabbix_agent_listenip is undefined

This poull request fixes the role

ISSUE TYPE
COMPONENT NAME

agent

This fixes #1244

sblaisot commented 1 month ago

How about https://github.com/ansible-collections/community.zabbix/blob/main/roles/zabbix_agent/tasks/Linux.yml#L54 https://github.com/ansible-collections/community.zabbix/blob/main/roles/zabbix_agent/tasks/Linux.yml#L63 https://github.com/ansible-collections/community.zabbix/blob/main/roles/zabbix_agent/tasks/Linux.yml#L82

:shrug:

TASK [community.zabbix.zabbix_agent : Configure Agent] *************************
included: /path/to/collections/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Linux.yml for target

TASK [community.zabbix.zabbix_agent : Set default ip address for zabbix_agent_ip] ***
ok: [target]

TASK [community.zabbix.zabbix_agent : Get Total Private IP Addresses] **********
ok: [target]

TASK [community.zabbix.zabbix_agent : Set first public ip address for zabbix_agent_ip] ***
skipping: [target]

TASK [community.zabbix.zabbix_agent : Set first private ip address for zabbix_agent_ip] ***
skipping: [target]

TASK [community.zabbix.zabbix_agent : Fail invalid specified agent_listeninterface] ***
skipping: [target]

TASK [community.zabbix.zabbix_agent : Set network interface] *******************
skipping: [target]

TASK [community.zabbix.zabbix_agent : Get IP of agent_listeninterface when no agent_listenip specified] ***
skipping: [target]

TASK [community.zabbix.zabbix_agent : Default agent_listenip to all when not specified] ***
fatal: [target]: FAILED! => {"msg": "The conditional check 'not (zabbix_agent_listenip)' failed. The error was: error while evaluating conditional (not (zabbix_agent_listenip)): 'zabbix_agent_listenip' is undefined. 'zabbix_agent_listenip' is undefined\n\nThe error appears to be in '/etc/ansible/collections/ansible_collections/cozycloud/zabbix-scaleway/collections/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Linux.yml': line 68, 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: \"Default agent_listenip to all when not specified\"\n  ^ here\n"}
sblaisot commented 1 month ago

How about https://github.com/ansible-collections/community.zabbix/blob/main/roles/zabbix_agent/tasks/Linux.yml#L54 https://github.com/ansible-collections/community.zabbix/blob/main/roles/zabbix_agent/tasks/Linux.yml#L63 https://github.com/ansible-collections/community.zabbix/blob/main/roles/zabbix_agent/tasks/Linux.yml#L82

you're right, these should be fixed too.

sblaisot commented 1 month ago

oh no, third one is uneeded because set_fact on line 59 and 69

sblaisot commented 1 month ago

ok, commit updated

BGmot commented 1 month ago

Thank you for PR. @pyrodie18 please review and merge.