Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to connect to socket error while running task for multiple server #1112

Closed
solick opened this issue Nov 3, 2023 · 20 comments
Closed

Comments

@solick
Copy link

solick commented Nov 3, 2023

SUMMARY

Running a task against one server is working, running it against a server group cause "unable to connect to socket" error

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.zabbix.zabbix_hostmacro:

ANSIBLE VERSION
ansible [core 2.15.3]
  config file = /Users/xxx/Development/Ansible/lmc-ansible/ansible.cfg
  configured module search path = ['/Users/xxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/8.3.0/libexec/lib/python3.11/site-packages/ansible
  ansible collection location = /Users/xxx/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.11.5 (main, Aug 24 2023, 15:18:16) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/usr/local/Cellar/ansible/8.3.0/libexec/bin/python)
  jinja version = 3.1.2
  libyaml = True

CONFIGURATION
CONFIG_FILE() = /Users/xxx/Development/Ansible/lmc-ansible/ansible.cfg
DEFAULT_HOST_LIST(/Users/xxx/Development/Ansible/lmc-ansible/ansible.cfg) = ['/Users/xxx/Development/Ansible/lmc-ansible/hosts']
DEFAULT_REMOTE_USER(/Users/xxx/Development/Ansible/lmc-ansible/ansible.cfg) = root
DEFAULT_VAULT_PASSWORD_FILE(/Users/xxx/Development/Ansible/lmc-ansible/ansible.cfg) = /Users/xxx/Development/Ansible/lmc-ansible-vault-password
EDITOR(env: EDITOR) = nano

OS / ENVIRONMENT / Zabbix Version

Zabbix 6.0
MacOS 17.1

STEPS TO REPRODUCE

Set macros via zabbix_hostmacro module.
Use the tasks for a single server is working, use the task for a group of servers is not working.

---

- name: add maccro trigger_threshold_processes to host
  vars:
    gather_facts: false
    ansible_network_os: community.zabbix.zabbix
    ansible_connection: httpapi
    ansible_httpapi_port: 443
    ansible_httpapi_use_ssl: true  # Set to true for HTTPS
    ansible_httpapi_validate_certs: true  # For HTTPS et to true to validate server's certificate
  community.zabbix.zabbix_hostmacro:
    host_name: "{{ inventory_hostname }}"
    macro_name: "{$TRIGGER_THRESHOLD_PROCESSES}"
    macro_value: "{{ zabbix_proxmox_threshold_processes }}"
    macro_description: "extended value because proxmox server"
  become: false
  delegate_to: "{{ zabbix_api_server_host }}"

- name: add maccro trigger_threshold_processes_running to host
  vars:
    gather_facts: false
    ansible_network_os: community.zabbix.zabbix
    ansible_connection: httpapi
    ansible_httpapi_port: 443
    ansible_httpapi_use_ssl: true  # Set to true for HTTPS
    ansible_httpapi_validate_certs: true  # For HTTPS et to true to validate server's certificate
  community.zabbix.zabbix_hostmacro:
    host_name: "{{ inventory_hostname }}"
    macro_name: "{$TRIGGER_THRESHOLD_PROCESSES_RUNNING}"
    macro_value: "{{ zabbix_proxmox_threshold_processes_running }}"
    macro_description: "extended value because proxmox server"
  become: false
  delegate_to: "{{ zabbix_api_server_host }}"
  
EXPECTED RESULTS

The task should be able to run against a group of servers without error.

ACTUAL RESULTS

The error does not occur for all servers (I tested with a group of 6 servers) but occurs for part of them.

fatal: [server3.xxx -> zabbix.xxx]: FAILED! => {"msg": "Traceback (most recent call last):\n  File \"/usr/local/Cellar/ansible/8.3.0/libexec/lib/python3.11/site-packages/ansible/module_utils/connection.py\", line 207, in send\n    sf.connect(self.socket_path)\nConnectionRefusedError: [Errno 61] Connection refused\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/usr/local/Cellar/ansible/8.3.0/libexec/lib/python3.11/site-packages/ansible/cli/scripts/ansible_connection_cli_stub.py\", line 315, in main\n    conn.set_options(direct=options)\n  File \"/usr/local/Cellar/ansible/8.3.0/libexec/lib/python3.11/site-packages/ansible/module_utils/connection.py\", line 194, in __rpc__\n    response = self._exec_jsonrpc(name, *args, **kwargs)\n               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/Cellar/ansible/8.3.0/libexec/lib/python3.11/site-packages/ansible/module_utils/connection.py\", line 155, in _exec_jsonrpc\n    out = self.send(data)\n          ^^^^^^^^^^^^^^^\n  File \"/usr/local/Cellar/ansible/8.3.0/libexec/lib/python3.11/site-packages/ansible/module_utils/connection.py\", line 214, in send\n    raise ConnectionError(\nansible.module_utils.connection.ConnectionError: unable to connect to socket /Users/xxx/.ansible/pc/615f7cd59a. See the socket path issue category in Network Debug and Troubleshooting Guide\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/usr/local/bin/ansible-connection\", line 8, in <module>\n    sys.exit(main())\n             ^^^^^^\n  File \"/usr/local/Cellar/ansible/8.3.0/libexec/lib/python3.11/site-packages/ansible/cli/scripts/ansible_connection_cli_stub.py\", line 318, in main\n    raise ConnectionError('Unable to decode JSON from response set_options. See the debug log for more information.')\nansible.module_utils.connection.ConnectionError: Unable to decode JSON from response set_options. See the debug log for more information.\n"}
@pyrodie18
Copy link
Collaborator

Not sure I totally follow what you mean by use it for a group of servers.

@solick
Copy link
Author

solick commented Nov 4, 2023

@pyrodie18 i have in my hosts file a group called proxmox_servers where are 6 server assigned. When I start the playbook with the --limit proxmox_servers the problem occurs.

@pyrodie18
Copy link
Collaborator

As I read the output of the error (granted I'm not an expert), I don't see it even trying to execute the module, but instead failing trying to connect to the host. I suspect (again, a bit of a guess) that because you're delegating to zabbix_api_server_host that because you are limiting, that its not adding that host into your inventory in memory and so when it tries to connect to it, it has no idea how to connect to it. Or I could be completely wrong.

@BGmot
Copy link
Collaborator

BGmot commented Nov 6, 2023

@pyrodie18
Copy link
Collaborator

Any feedback @solick ?

@solick
Copy link
Author

solick commented Nov 20, 2023

@pyrodie18 @BGmot sorry für my late response. I was very busy the last weeks. I will try to troubleshoot within the next days and will than give feedback.

@nerdalertdk
Copy link

I have the same problem after migration to the new connect method.

out of 10 server, maybe 2 goes ok

@nerdalertdk
Copy link

nerdalertdk commented Dec 4, 2023

Looks like it runs it multiple time on each host.

This is the web log for 11 hosts

zabbix: 6.2

zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:52 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 89 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:52 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 592 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:52 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 592 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:52 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 584 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:52 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 584 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:52 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 176 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:52 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 586 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:52 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 179 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:52 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 176 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:52 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 273 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:53 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 179 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:53 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 618 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:53 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 273 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:53 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 946 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:53 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 616 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:53 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 297 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:53 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 946 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:53 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 273 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:53 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 296 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:53 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 1092 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:53 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 273 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:54 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 1594 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:55 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 592 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:55 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 592 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:55 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 631 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:55 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 631 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:55 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 176 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:55 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 176 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:55 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 179 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:55 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 179 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:55 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 273 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:55 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 273 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:55 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 596 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:56 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 598 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:56 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 960 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:56 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 929 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:56 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 286 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:56 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 287 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:56 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 273 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:56 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 273 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:56 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 1139 "-" "Python-urllib/3.12" "-"
zabbix-web                  | 100.117.160.3 - - [04/Dec/2023:21:55:56 +0100] "POST /api_jsonrpc.php HTTP/1.1" 200 1139 "-" "Python-urllib/3.12" "-"
PLAY RECAP **************************************************************************************************
RANDOMSERVERNAME1.net : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
RANDOMSERVERNAME2.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
RANDOMSERVERNAME3.net : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
RANDOMSERVERNAME4.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
RANDOMSERVERNAME5.net : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
RANDOMSERVERNAME6.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
RANDOMSERVERNAME7.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
RANDOMSERVERNAME8.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
RANDOMSERVERNAME9.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
RANDOMSERVERNAME10.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
RANDOMSERVERNAME11.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0  
- name: Zabbix | Create a new host or update an existing host's info
  vars:
    gather_facts: false
    ansible_network_os: community.zabbix.zabbix
    ansible_connection: httpapi
    ansible_httpapi_port: 80
    ansible_httpapi_use_ssl: false
    ansible_httpapi_validate_certs: false
    ansible_zabbix_url_path: ''
    ansible_zabbix_auth_key: "{{ secure_zabbix_api_token }}"
  become: false
  delegate_to: "{{ secure_zabbix_host_url }}"
  community.zabbix.zabbix_host:
    host_name: "{{ inventory_hostname }}"
    host_groups:
      - 'Linux servers'
    link_templates: "{{ zabbix_link_templates }}"
    interfaces:
      - type: 'agent'
        main: 1
        useip: 0
        dns: "{{ inventory_hostname }}"

run_once: true, do not help

some fail with ConnectionRefusedError: [Errno 61] Connection refused others Unable to decode JSON from response set_options. See the debug log for more information.

it's not isolated to one host,
This is the result from two runs, no changes made

HOST1.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
HOST2.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
HOST3.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
HOST4.net : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
HOST5.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
HOST6.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
HOST7.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
HOST8.net : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
HOST9.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
HOST10.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
HOST11.net : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0  

HOST1.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
HOST2.net : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
HOST3.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
HOST4.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
HOST5.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
HOST6.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
HOST7.net : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
HOST8.net : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
HOST9.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
HOST10.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
HOST11.net : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0  

@BGmot
Copy link
Collaborator

BGmot commented Dec 4, 2023

One execution of zabbix_host module (and almost all modules) involves multiple API calls, I believe this is what you are seeing not several execution of zabbix_host on each server.
Would you be able to provide full tcpdump between your Ansible controller and Zabbix server for the whole playbook run?

@nerdalertdk
Copy link

One execution of zabbix_host module (and almost all modules) involves multiple API calls, I believe this is what you are seeing not several execution of zabbix_host on each server. Would you be able to provide full tcpdump between your Ansible controller and Zabbix server for the whole playbook run?

Hi,
Sorry really don't have time too do a deep debug of this now

For everyone else, fixed it by using version 1.9.3
now my old role just work

requirements.yaml

collections:
  - name: community.zabbix
    version: 1.9.3

@snk26
Copy link

snk26 commented Jan 16, 2024

Hi,
I specified the following variables for the test:

      zabbix_api_server_host: zabbix.example.com
      zabbix_api_server_port: 80
      ansible_zabbix_url_path: '/'

I performed a tcpdump on the Zabbix server and saw that in the “Host:” header the IP address was indicated instead of the host name.

POST ///api_jsonrpc.php HTTP/1.1
Accept-Encoding: identity
Content-Length: 162
Host: xxx.xxx.xxx.xxx:80
User-Agent: Python-urllib/3.10
Content-Type: application/json-rpc
Accept: application/json
Auth: fake
Connection: close

I process all such requests in NGINX with server_name _;, so requests do not go to Zabbix.
Requests without a hostname are sent over both HTTP and HTTPS.

I think if you remove the conversion of the host name to IP address, the problem will be solved.

@leomuso
Copy link

leomuso commented Jan 24, 2024

Same issue with version 2.3.1. The task will randomly fail on some hosts when executing against a group. When running the task against the hosts one by one, not against the group, it finishes successfully every time.

Zabbix Server is 6.4.2

Edit: looks like this might be related.

@BGmot
Copy link
Collaborator

BGmot commented Mar 4, 2024

Finally got time to investigate this interesting problem. Cannot reproduce.
My environment:
Zabbix version 6.4.12 (I don't think it matters).

ey@ls1:~/ansible$ ansible --version
ansible [core 2.12.4]
  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 = /usr/local/lib/python3.8/dist-packages/ansible
  ansible collection location = /home/ey/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.8.10 (default, Nov 22 2023, 10:22:35) [GCC 9.4.0]
  jinja version = 2.10.1
  libyaml = True

Tested with much newer version of Ansible/Python too:

(env_py312_ans216) ey@ls1:~/ansible$ ansible --version
ansible [core 2.16.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_py312_ans216/lib/python3.12/site-packages/ansible
  ansible collection location = /home/ey/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/ey/env_py312_ans216/bin/ansible
  python version = 3.12.2 (main, Feb 25 2024, 16:36:57) [GCC 9.4.0] (/home/ey/env_py312_ans216/bin/python)
  jinja version = 3.1.3
  libyaml = True

Collection version is 2.3.1.

My inventory:

ey@ls1:~/ansible$ cat inventories/multiple_hosts_fail.yml 
RANDOMSERVERNAME1.net
RANDOMSERVERNAME2.net
RANDOMSERVERNAME3.net
RANDOMSERVERNAME4.net
RANDOMSERVERNAME5.net
RANDOMSERVERNAME6.net
RANDOMSERVERNAME7.net
RANDOMSERVERNAME8.net
RANDOMSERVERNAME9.net
RANDOMSERVERNAME10.net
RANDOMSERVERNAME11.net

My playbook:

ey@ls1:~/ansible$ cat multiple_hosts_fail.yml 
---
- hosts: all
  gather_facts: false
  vars:
    secure_zabbix_host_url: 'ls1'
    secure_zabbix_api_token: 'df8288ac524a826e4c0aabd7fdde40d0caf0e349adf18ea4d8cbd023b8eebc71'
    zabbix_link_templates:
      - 'Linux by Zabbix agent'
  tasks:
  - name: Zabbix | Create a new host or update an existing host's info
    vars:
      gather_facts: false
      ansible_network_os: community.zabbix.zabbix
      ansible_connection: httpapi
      ansible_httpapi_port: 8080
      ansible_httpapi_use_ssl: false
      ansible_httpapi_validate_certs: false
      ansible_zabbix_url_path: ''
      ansible_zabbix_auth_key: "{{ secure_zabbix_api_token }}"
    become: false
    delegate_to: "{{ secure_zabbix_host_url }}"
    community.zabbix.zabbix_host:
      host_name: "{{ inventory_hostname }}"
      host_groups:
        - 'Linux servers'
      link_templates: "{{ zabbix_link_templates }}"
      interfaces:
        - type: 'agent'
          main: 1
          useip: 0
          dns: "{{ inventory_hostname }}"

Running:

ey@ls1:~/ansible$ ansible-playbook -i inventories/multiple_hosts_fail.yml multiple_hosts_fail.yml

PLAY [all] ***********************************************************************************************************************************************************************************************************************************************************************

TASK [Zabbix | Create a new host or update an existing host's info] **************************************************************************************************************************************************************************************************************
changed: [RANDOMSERVERNAME4.net -> ls1]
changed: [RANDOMSERVERNAME5.net -> ls1]
changed: [RANDOMSERVERNAME3.net -> ls1]
changed: [RANDOMSERVERNAME2.net -> ls1]
changed: [RANDOMSERVERNAME1.net -> ls1]
changed: [RANDOMSERVERNAME6.net -> ls1]
changed: [RANDOMSERVERNAME7.net -> ls1]
changed: [RANDOMSERVERNAME8.net -> ls1]
changed: [RANDOMSERVERNAME9.net -> ls1]
changed: [RANDOMSERVERNAME10.net -> ls1]
changed: [RANDOMSERVERNAME11.net -> ls1]

PLAY RECAP ***********************************************************************************************************************************************************************************************************************************************************************
RANDOMSERVERNAME1.net      : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
RANDOMSERVERNAME10.net     : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
RANDOMSERVERNAME11.net     : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
RANDOMSERVERNAME2.net      : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
RANDOMSERVERNAME3.net      : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
RANDOMSERVERNAME4.net      : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
RANDOMSERVERNAME5.net      : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
RANDOMSERVERNAME6.net      : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
RANDOMSERVERNAME7.net      : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
RANDOMSERVERNAME8.net      : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
RANDOMSERVERNAME9.net      : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

And in WebUI I see all the hosts successfully added.
Any thoughts how to proceed?

@leomuso
Copy link

leomuso commented Apr 10, 2024

Hey @BGmot, after some tests we discovered that the issue, at least for us, is mostly happening when running the playbooks on macOS. Running the same on Linux works just fine.

@BGmot
Copy link
Collaborator

BGmot commented Apr 10, 2024

Hey @BGmot, after some tests we discovered that the issue, at least for us, is mostly happening when running the playbooks on macOS. Running the same on Linux works just fine.

Bingo! On MacOS it fails indeed. On Ubuntu running without any problems. The same versions of Ansible + Python.
I don't know how to troubleshoot this, does not look like the collection code related but rather "persistent connection" implementation by Ansible...

@nerdalertdk
Copy link

nerdalertdk commented Apr 11, 2024

Also on MacOS here

System Software Overview:

  System Version: macOS 14.4.1 (23E224)
  Kernel Version: Darwin 23.4.0

@texnocobra
Copy link

+1
same problem on MacOS Ventura

@pyrodie18
Copy link
Collaborator

Since it sounds like this is definitely a problem with Ansible and not the collection, I'm going to close this out and encourage someone to open a ticket in the Ansible project.

@matt604-adjust
Copy link

Since it sounds like this is definitely a problem with Ansible and not the collection, I'm going to close this out and encourage someone to open a ticket in the Ansible project.

Hello @pyrodie18 ! Can you elaborate on how you came to the conclusion that this issue is with Ansible rather than the zabbix module? Could it not be an interaction with this module specifically and MacOS?

m!

@BGmot
Copy link
Collaborator

BGmot commented Jun 6, 2024

Since it sounds like this is definitely a problem with Ansible and not the collection, I'm going to close this out and encourage someone to open a ticket in the Ansible project.

Hello @pyrodie18 ! Can you elaborate on how you came to the conclusion that this issue is with Ansible rather than the zabbix module? Could it not be an interaction with this module specifically and MacOS?

m!

HttpAPI connection plugin is provided by Ansible, our modules just use it. The issue is not happening on Linux OS. Do you have any idea how we can troubleshoot this? I am all for it but don't know how to approach it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants