brocade / ansible

56 stars 33 forks source link

Connnection refused on switch version 8.2.1c #137

Closed RomainDusi closed 1 year ago

RomainDusi commented 1 year ago

Hello,

When porting my script into production yesterday, i encounterd an error of connection. Switch version v8.2.1c Brocade.fos collection used 1.3.3 and also tested with 1.3.0.

Bloc of code :

  brocade.fos.brocade_zoning_alias:  
    credential: "{{ credential_f1 }}" # Récupère les credentials paramétrés plus haut  
    vfid: "{{ fos_vfid_f1 }}"  
    aliases: # Il existe "aliases_to_delete" pour supprimer un alias (besoin que du nom pour la suppression)  
      - name: "s_{{ purefa_hosts_list[item] }}_dsk1"  
        members:  
          - "{{purefa_hosts_wwn_1_list[item]}}"  
  loop: "{{range(0, purefa_hosts_list | length, 1) | list}}"

Error result :

TASK [role_brocade_zoning : Création aliases F1] ************************************************************************************************************************************************************************************************************************************************
task path: /srv/stockauto/dev/roles/brocade/roles/role_brocade_zoning/tasks/Create_Aliases.yml:39
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1689702989.9939625-2481323-161366583757752 `" && echo ansible-tmp-1689702989.9939625-2481323-161366583757752="` echo /root/.ansible/tmp/ansible-tmp-1689702989.9939625-2481323-161366583757752 `" ) && sleep 0'
Using module file /root/.ansible/collections/ansible_collections/brocade/fos/plugins/modules/brocade_zoning_alias.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-2480868doec672u/tmpvelertbq TO /root/.ansible/tmp/ansible-tmp-1689702989.9939625-2481323-161366583757752/AnsiballZ_brocade_zoning_alias.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1689702989.9939625-2481323-161366583757752/ /root/.ansible/tmp/ansible-tmp-1689702989.9939625-2481323-161366583757752/AnsiballZ_brocade_zoning_alias.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/srv/stockauto/venv/bin/python3 /root/.ansible/tmp/ansible-tmp-1689702989.9939625-2481323-161366583757752/AnsiballZ_brocade_zoning_alias.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1689702989.9939625-2481323-161366583757752/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/usr/lib64/python3.6/urllib/request.py", line 1349, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib64/python3.6/http/client.py", line 1269, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1315, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1264, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.6/http/client.py", line 1040, in _send_output
    self.send(msg)
  File "/usr/lib64/python3.6/http/client.py", line 978, in send
    self.connect()
  File "/usr/lib64/python3.6/http/client.py", line 1429, in connect
    super().connect()
  File "/usr/lib64/python3.6/http/client.py", line 950, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib64/python3.6/socket.py", line 724, in create_connection
    raise err
  File "/usr/lib64/python3.6/socket.py", line 713, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1689702989.9939625-2481323-161366583757752/AnsiballZ_brocade_zoning_alias.py", line 100, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-tmp-1689702989.9939625-2481323-161366583757752/AnsiballZ_brocade_zoning_alias.py", line 92, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-tmp-1689702989.9939625-2481323-161366583757752/AnsiballZ_brocade_zoning_alias.py", line 41, in invoke_module
    run_name='__main__', alter_sys=True)
  File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_brocade.fos.brocade_zoning_alias_payload_ilabue83/ansible_brocade.fos.brocade_zoning_alias_payload.zip/ansible_collections/brocade/fos/plugins/modules/brocade_zoning_alias.py", line 225, in <module>
  File "/tmp/ansible_brocade.fos.brocade_zoning_alias_payload_ilabue83/ansible_brocade.fos.brocade_zoning_alias_payload.zip/ansible_collections/brocade/fos/plugins/modules/brocade_zoning_alias.py", line 210, in main
  File "/tmp/ansible_brocade.fos.brocade_zoning_alias_payload_ilabue83/ansible_brocade.fos.brocade_zoning_alias_payload.zip/ansible_collections/brocade/fos/plugins/module_utils/brocade_connection.py", line 55, in login
  File "/tmp/ansible_brocade.fos.brocade_zoning_alias_payload_ilabue83/ansible_brocade.fos.brocade_zoning_alias_payload.zip/ansible_collections/brocade/fos/plugins/module_utils/brocade_url.py", line 242, in url_helper
  File "/tmp/ansible_brocade.fos.brocade_zoning_alias_payload_ilabue83/ansible_brocade.fos.brocade_zoning_alias_payload.zip/ansible/module_utils/urls.py", line 1541, in open_url
  File "/tmp/ansible_brocade.fos.brocade_zoning_alias_payload_ilabue83/ansible_brocade.fos.brocade_zoning_alias_payload.zip/ansible/module_utils/urls.py", line 1446, in open
  File "/usr/lib64/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib64/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/lib64/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/lib64/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/tmp/ansible_brocade.fos.brocade_zoning_alias_payload_ilabue83/ansible_brocade.fos.brocade_zoning_alias_payload.zip/ansible/module_utils/urls.py", line 582, in https_open
  File "/usr/lib64/python3.6/urllib/request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 111] Connection refused>
failed: [localhost] (item=0) => {
    "ansible_loop_var": "item",
    "changed": false,
    "item": 0,
    "module_stderr": "Traceback (most recent call last):\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 1349, in do_open\n    encode_chunked=req.has_header('Transfer-encoding'))\n  File \"/usr/lib64/python3.6/http/client.py\", line 1269, in request\n    self._send_request(method, url, body, headers, encode_chunked)\n  File \"/usr/lib64/python3.6/http/client.py\", line 1315, in _send_request\n    self.endheaders(body, encode_chunked=encode_chunked)\n  File \"/usr/lib64/python3.6/http/client.py\", line 1264, in endheaders\n    self._send_output(message_body, encode_chunked=encode_chunked)\n  File \"/usr/lib64/python3.6/http/client.py\", line 1040, in _send_output\n    self.send(msg)\n  File \"/usr/lib64/python3.6/http/client.py\", line 978, in send\n    self.connect()\n  File \"/usr/lib64/python3.6/http/client.py\", line 1429, in connect\n    super().connect()\n  File \"/usr/lib64/python3.6/http/client.py\", line 950, in connect\n    (self.host,self.port), self.timeout, self.source_address)\n  File \"/usr/lib64/python3.6/socket.py\", line 724, in create_connection\n    raise err\n  File \"/usr/lib64/python3.6/socket.py\", line 713, in create_connection\n    sock.connect(sa)\nConnectionRefusedError: [Errno 111] Connection refused\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1689702989.9939625-2481323-161366583757752/AnsiballZ_brocade_zoning_alias.py\", line 100, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1689702989.9939625-2481323-161366583757752/AnsiballZ_brocade_zoning_alias.py\", line 92, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1689702989.9939625-2481323-161366583757752/AnsiballZ_brocade_zoning_alias.py\", line 41, in invoke_module\n    run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, pkg_name, script_name)\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_brocade.fos.brocade_zoning_alias_payload_ilabue83/ansible_brocade.fos.brocade_zoning_alias_payload.zip/ansible_collections/brocade/fos/plugins/modules/brocade_zoning_alias.py\", line 225, in <module>\n  File \"/tmp/ansible_brocade.fos.brocade_zoning_alias_payload_ilabue83/ansible_brocade.fos.brocade_zoning_alias_payload.zip/ansible_collections/brocade/fos/plugins/modules/brocade_zoning_alias.py\", line 210, in main\n  File \"/tmp/ansible_brocade.fos.brocade_zoning_alias_payload_ilabue83/ansible_brocade.fos.brocade_zoning_alias_payload.zip/ansible_collections/brocade/fos/plugins/module_utils/brocade_connection.py\", line 55, in login\n  File \"/tmp/ansible_brocade.fos.brocade_zoning_alias_payload_ilabue83/ansible_brocade.fos.brocade_zoning_alias_payload.zip/ansible_collections/brocade/fos/plugins/module_utils/brocade_url.py\", line 242, in url_helper\n  File \"/tmp/ansible_brocade.fos.brocade_zoning_alias_payload_ilabue83/ansible_brocade.fos.brocade_zoning_alias_payload.zip/ansible/module_utils/urls.py\", line 1541, in open_url\n  File \"/tmp/ansible_brocade.fos.brocade_zoning_alias_payload_ilabue83/ansible_brocade.fos.brocade_zoning_alias_payload.zip/ansible/module_utils/urls.py\", line 1446, in open\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 223, in urlopen\n    return opener.open(url, data, timeout)\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 526, in open\n    response = self._open(req, data)\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 544, in _open\n    '_open', req)\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 504, in _call_chain\n    result = func(*args)\n  File \"/tmp/ansible_brocade.fos.brocade_zoning_alias_payload_ilabue83/ansible_brocade.fos.brocade_zoning_alias_payload.zip/ansible/module_utils/urls.py\", line 582, in https_open\n  File \"/usr/lib64/python3.6/urllib/request.py\", line 1351, in do_open\n    raise URLError(err)\nurllib.error.URLError: <urlopen error [Errno 111] Connection refused>\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

That same code works fine when used on an other switch with version 9.1.1_01.

Can you please provide more insight about this error ?

Thank you.

prasad-valmeti-broadcom commented 1 year ago

Please make sure REST requests on the 8.2.1c switch are working fine. If those are working fine, then try Ansible on that switch. It looks like there is a connection failure issue. If REST is working fine and only Ansible has an issue: san_eng_zone_seed_san_a ansible_connection=local fos_ip_addr= fos_user_name=admin fos_password= fos_https=self

fos_https is self if it is for self signed certificate, if the Switch doesn't have HTTPS enabled then use fos_https=false

Please let us know your findings.

prasad-valmeti-broadcom commented 1 year ago

If there are no further issues, please suggest if we can close this issue.

RomainDusi commented 1 year ago

Hello,

Sorry for the delay. I activated HTTPS on the switch and it's now working correctly.

Thank you.