ansiblezabbix

Cant add zabbix host ansible


I dont create zabbix host via code bellow:

- name: Zabbix Agent. Create host
  vars:
    ansible_network_os: community.zabbix.zabbix
    ansible_connection: httpapi
    ansible_httpapi_port: 443
    ansible_httpapi_use_ssl: true
    ansible_httpapi_validate_certs: false
    ansible_zabbix_url_path: ""
    ansible_user: "{{ zabbix_api_user }}"
    ansible_httpapi_pass: "{{ zabbix_api_pass }}"
  become: false
  delegate_to: zabbix-server
  community.zabbix.zabbix_host:
    host_name: "{{ zabbix_agent_hostname }}"
    host_groups: "{{ zabbix_host_groups }}"
    link_templates: "{{ zabbix_templates }}"
    status: "{{ zabbix_host_status }}"
    state: present
    force: "{{ zabbix_update_host }}"
    proxy: "{{ zabbix_proxy }}"
    inventory_mode: "{{ zabbix_inventory_mode }}"
    interfaces: "{{ zabbix_agent_interfaces }}"
    visible_name: "{{ zabbix_agent_visible_name }}"
    tags: "{{ zabbix_host_tags | default(omit) }}"
  when:
    - zabbix_api_create_hosts
  changed_when: false

All variables with values. I get error bellow:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.module_utils.connection.ConnectionError: socket path /home/suser/.ansible/pc/51428b6c99 does not exist or cannot 
be found. See Troubleshooting socket path issues in the Network Debug and Troubleshooting Guide
fatal: [target-server -> zabbix-server]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/home/suser/.ansible/tmp/ansible-local-17513nk3uuvju/ansible-tmp-1701959027.4064732-17752-174814429460140/AnsiballZ_zabbix_host.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/home/suser/.ansible/tmp/ansible-local-17513nk3uuvju/ansible-tmp-1701959027.4064732-17752-174814429460140/AnsiballZ_zabbix_host.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/suser/.ansible/tmp/ansible-local-17513nk3uuvju/ansible-tmp-1701959027.4064732-17752-174814429460140/AnsiballZ_zabbix_host.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.community.zabbix.plugins.modules.zabbix_host', init_globals=dict(_module_fqn='ansible_collections.community.zabbix.plugins.modules.zabbix_host', _modlib_path=modlib_path),\n  File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_community.zabbix.zabbix_host_payload_nn0bp7d3/ansible_community.zabbix.zabbix_host_payload.zip/ansible_collections/community/zabbix/plugins/modules/zabbix_host.py\", line 1250, in <module>\n  File \"/tmp/ansible_community.zabbix.zabbix_host_payload_nn0bp7d3/ansible_community.zabbix.zabbix_host_payload.zip/ansible_collections/community/zabbix/plugins/modules/zabbix_host.py\", line 1052, in main\n  File \"/tmp/ansible_community.zabbix.zabbix_host_payload_nn0bp7d3/ansible_community.zabbix.zabbix_host_payload.zip/ansible_collections/community/zabbix/plugins/module_utils/base.py\", line 20, in __init__\n  File \"/tmp/ansible_community.zabbix.zabbix_host_payload_nn0bp7d3/ansible_community.zabbix.zabbix_host_payload.zip/ansible_collections/community/zabbix/plugins/module_utils/api_request.py\", line 53, in api_version\n  File \"/tmp/ansible_community.zabbix.zabbix_host_payload_nn0bp7d3/ansible_community.zabbix.zabbix_host_payload.zip/ansible/module_utils/connection.py\", line 194, in __rpc__\n  File \"/tmp/ansible_community.zabbix.zabbix_host_payload_nn0bp7d3/ansible_community.zabbix.zabbix_host_payload.zip/ansible/module_utils/connection.py\", line 141, in _exec_jsonrpc\nansible.module_utils.connection.ConnectionError: socket path /home/suser/.ansible/pc/51428b6c99 does not exist or cannot be found. See Troubleshooting socket path issues in the Network Debug and Troubleshooting Guide\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Finally, code for create zabbix host is working on another machines. I use Win 10 + wsl. I tried to reinstall ansible and this didnt resolve my problem. What could be the reason?


Solution

  • Anser on my quiestion. It turned out that I was using several versions of ansible. First version i installed via apt and another via pip. Ansible-galaxy collection module versions conflicted. After deleted and removed all files ansible apt version, i reinstall (ansible-galaxy collection install --force) zabbix_host module and this is work! If you have a such problem, then make sure the path of the executable file is correct (via ansible --version (executable location))