Forum Discussion

Edson_Araujo's avatar
Edson_Araujo
Icon for Nimbostratus rankNimbostratus
Jul 15, 2021

Connection Refused error when running Ansible Playbook

I'm trying to run an Ansible playbook to create a new local user account on a Big-IP VE running 13.1.3.4 using the bigip_user module. I'm able to run tasks using bigip_device_info and bigip_config modules successfully, but whenever I try to run a playbook with a module to change settings (i.e. bigip_user or bigip_snmp_community) it errors out with the message: "An exception occurred during task execution. To see the full traceback, use -vvv. The error was: urllib.error.URLError: <urlopen error [Errno 111] Connection refused>"

I'm new to Ansible on Big-IP platform. Any help on this is greatly appreciated.

Playbook:

---
- name: Add users playbook
  hosts: "{{ devices }}"
  strategy: free
  order: sorted
  connection: local
  gather_facts: no
  become: no
  become_method: enable
  ignore_errors: no

  collections:
    - f5networks.f5_modules

  vars:
    provider:
      server: "{{ ansible_host }}"
      user: <username>
      password: <password>
      validate_certs: no
      server_port: 443

  tasks:
  - name: Add or update the user
    bigip_user:
	  provider: "{{ provider }}"
	  username_credential: user
	  password_credential: password
	  update_password: always
	  full_name: User
	  shell: bash
	  partition_access:
	    - all:admin
	  state: present
    delegate_to: localhost

Error:

The full traceback is:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/urllib/request.py", line 1350, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/local/lib/python3.7/http/client.py", line 1277, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1323, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1272, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1032, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.7/http/client.py", line 972, in send
    self.connect()
  File "/usr/local/lib/python3.7/http/client.py", line 1439, in connect
    super().connect()
  File "/usr/local/lib/python3.7/http/client.py", line 944, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/local/lib/python3.7/socket.py", line 728, in create_connection
    raise err
  File "/usr/local/lib/python3.7/socket.py", line 716, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

Thanks,

-Edson

4 Replies

  • Zuke's avatar
    Zuke
    Icon for Cirrostratus rankCirrostratus

    I have a similar error, though I don't get a connection refused issue.

    The error was: urllib.error.URLError: <urlopen error timed out>

    Did you ever find a fix to your issue, Edson?

  • I too notice the same error when using bigip_device_info module on BIG-IP VE v13, But not on the Physical VIPRION Chassis, 

    Error:

    \\'ansible_collections.f5networks.f5_modules.plugins.modules.bigip_device_info\\

    "ansible_facts": {

            "job_errors": "Role=>'unknown'\\n Module=>'unknown'\\n Task=>'Collect BIG-IP information'\\n  Result=> '{'failed': True, '_ansible_parsed': False, 'module_stdout': '', 'module_stderr': 'Traceback (most recent call last):\\\\n 

    \\\n    raise URLError(err)\\\\nurllib.error.URLError: <urlopen error timed out>\\\\n', 'msg': 'MODULE FAILURE\\\\nSee stdout/stderr for the exact error', 'rc': 1, '_ansible_no_log': False, 'changed': False, '_ansible_delegated_vars': {'ansible_delegated_host': 'localhost', 'ansible_remote_tmp': None, 'ansible_system_tmpdirs': None, 'ansible_async_dir': None, 'ansible_admin_users': None, 'ansible_shell_allow_world_readable_temp': None}}'",

            "job_result": "FAILURE"

  • Hi Guys, I managed to resolve this issue, It's definitely a connectivity issue, In my case TCP443 was not allowed in the Openstack Security group configured on the Mgmt interface of the BIG-VE instances.