ansible-collections / community.zabbix

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

Issues finding map information causes role to failt to deploy. #1319

Closed DamienUKCEH closed 5 days ago

DamienUKCEH commented 5 days ago
SUMMARY

when trying to run the role to install agent on RHEL platforms ( tested only with Rocky 8 & 9) the role fails to deploy with a 'dict object' due to OS value being passed having a space ie '9 ' or '8 ' as such we get a fail.

ISSUE TYPE
ANSIBLE VERSION
 ansible --version
ansible [core 2.17.1]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ansible/ansible-2.17/lib64/python3.12/site-packages/ansible
  ansible collection location = /home/ansible/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/ansible/ansible-2.17/bin/ansible
  python version = 3.12.1 (main, Feb 19 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/home/ansible/ansible-2.17/bin/python3.12)
  jinja version = 3.1.4
  libyaml = True
CONFIGURATION

ansible-config dump --only-changed ANSIBLE_NOCOWS(/etc/ansible/ansible.cfg) = True COLOR_ERROR(/etc/ansible/ansible.cfg) = bright red COLOR_VERBOSE(/etc/ansible/ansible.cfg) = bright cyan CONFIG_FILE() = /etc/ansible/ansible.cfg DEFAULT_GATHERING(/etc/ansible/ansible.cfg) = implicit DEFAULT_HOST_LIST(/etc/ansible/ansible.cfg) = ['/home/ansible/redacted/netbox-inventory.yml'] DEFAULT_MANAGED_STR(/etc/ansible/ansible.cfg) = Ansible managed file DEFAULT_TIMEOUT(/etc/ansible/ansible.cfg) = 300 DEFAULT_VAULT_PASSWORD_FILE(/etc/ansible/ansible.cfg) = /etc/ansible/vault_key INJECT_FACTS_AS_VARS(/etc/ansible/ansible.cfg) = False PLAYBOOK_DIR(/etc/ansible/ansible.cfg) = /home/ansible/redacted TASK_TIMEOUT(/etc/ansible/ansible.cfg) = 3600


##### OS / ENVIRONMENT / Zabbix Version
OS's are clean Rocky8 and Rocky 9 installs. 

 pip freeze
ansible-base==2.10.17
ansible-core==2.17.1
certifi==2024.6.2
cffi==1.16.0
charset-normalizer==3.3.2
cryptography==42.0.8
idna==3.7
Jinja2==3.1.4
MarkupSafe==2.1.5
netaddr==1.3.0
packaging==23.2
proxmoxer==2.0.1
pycparser==2.22
pynetbox==7.3.4
pytz==2024.1
PyYAML==6.0.1
requests==2.32.3
resolvelib==1.0.1
urllib3==2.2.2

##### STEPS TO REPRODUCE
create a python venv using python3.12
install from pip ansible-core
install community.zabbix collection from ansible galaxy 

call the role 

 - role: community.zabbix.zabbix_agent
       zabbix_agent_version: "7.0"

##### EXPECTED RESULTS
as RHEL 8 / 9  is on the list of supported items I would have expected that it could be found in the map

##### ACTUAL RESULTS
map look up is failing as a space is in the value 

TASK [community.zabbix.zabbix_agent : Include OS-specific variables] **** task path: /home/ansible/.ansible/collections/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/main.yml:3 ok: [wlsc-lin67] => { "ansible_facts": { "zabbix_agent": "zabbix-agent", "zabbix_valid_agent_versions": { "8": [ 7.0, 6.4, 6.0 ], "9": [ 7.0, 6.4, 6.0 ] } }, "ansible_included_var_files": [ "/home/ansible/.ansible/collections/ansible_collections/community/zabbix/roles/zabbix_agent/vars/RedHat.yml" ], "changed": false }

TASK [community.zabbix.zabbix_agent : Determine Latest Supported Zabbix Version] **** task path: /home/ansible/.ansible/collections/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/main.yml:8 skipping: [wlsc-lin67] => { "changed": false, "false_condition": "zabbix_agent_version is not defined or zabbix_agent_version is none", "skip_reason": "Conditional result was False" }

TASK [community.zabbix.zabbix_agent : Check that version is supported] ** task path: /home/ansible/.ansible/collections/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/main.yml:15 fatal: [wlsc-lin67]: FAILED! => { "msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute '8 '\n\nThe error appears to be in '/home/ansible/.ansible/collections/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/main.yml': line 15, 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: Check that version is supported\n ^ here\n" }

PLAY RECAP ** wlsc-lin67 : ok=2 changed=0 unreachable=0 failed=1 skipped=1 rescued=0 ignored=0

TASK [community.zabbix.zabbix_agent : Include OS-specific variables] **** task path: /home/ansible/.ansible/collections/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/main.yml:3 ok: [wlsc-dd-test] => { "ansible_facts": { "zabbix_agent": "zabbix-agent", "zabbix_valid_agent_versions": { "8": [ 7.0, 6.4, 6.0 ], "9": [ 7.0, 6.4, 6.0 ] } }, "ansible_included_var_files": [ "/home/ansible/.ansible/collections/ansible_collections/community/zabbix/roles/zabbix_agent/vars/RedHat.yml" ], "changed": false }

TASK [community.zabbix.zabbix_agent : Determine Latest Supported Zabbix Version] **** task path: /home/ansible/.ansible/collections/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/main.yml:8 skipping: [wlsc-dd-test] => { "changed": false, "false_condition": "zabbix_agent_version is not defined or zabbix_agent_version is none", "skip_reason": "Conditional result was False" }

TASK [community.zabbix.zabbix_agent : Check that version is supported] ** task path: /home/ansible/.ansible/collections/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/main.yml:15 fatal: [wlsc-dd-test]: FAILED! => { "msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute '9 '\n\nThe error appears to be in '/home/ansible/.ansible/collections/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/main.yml': line 15, 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: Check that version is supported\n ^ here\n" }

PLAY RECAP ** wlsc-dd-test : ok=2 changed=0 unreachable=0 failed=1 skipped=1 rescued=0 ignored=0

DamienUKCEH commented 5 days ago

found my issue. we had an extra space in our mapping from ansible_facts to the facts as vars value.

DamienUKCEH commented 5 days ago

user cleaned up env mapping had an extras space in for more than a year but issue only started happen, but found and resolved. ansible_distribution_major_version: "{{ ansible_facts.distribution_major_version }}"