Connection refused despite proper credentials

Tower 3.6.1
Ansible 2.9.2

I am trying to execute a playbook that lists repositories in (on-prem) Bitbucket project. This playbook is in a separate repo. Note that the project to which this repo is linked shows ‘Update Succeeded’ and the template which uses this playbook is able to fetch it, for this, a credential ‘Source Control’ type is used which has the private key and Bitbucket has the public key.

# Create and configure repository playbook
---
- name: "List repos in a project"
  hosts: localhost
  connection: local
  vars:
    bitbucket_token: "{{ bb_admin_token }}"

  roles:
    - role: list_repos

The role:

---
- name: user_private_repositories
  uri:
    method: GET
    headers:
      Authorization: "Bearer {{ bitbucket_token }}"
    return_content: yes
    force_basic_auth: yes
    url: "{{ bitbucket_rest_url }}/{{ bitbucket.project.name }}/repos"
  register: bitbucketResponse

- name: show bitbucket reponse
  debug:
    msg: "{{ bitbucketResponse }}"
...

The inventory(it’s immaterial if the ‘Variables’ is left empty or the following entries are added, I still get the error):

all: hosts: localhost 127.0.0.1

The template execution:

ansible-playbook 2.9.2 config file = /etc/ansible/ansible.cfg configured module search path = [u'/var/lib/awx/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible-playbook python version = 2.7.5 (default, Jun 11 2019, 14:33:56) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] Using /etc/ansible/ansible.cfg as config file PLAYBOOK: list_operations_playbook.yml ***************************************** 1 plays in list_operations_playbook.yml PLAY [List repos in a project] ************************************************* TASK [Gathering Facts] ********************************************************* task path: /tmp/awx_897_usiyawjw/project/list_operations_playbook.yml:3 ok: [localhost] META: ran handlers TASK [list_repos : user_private_repositories] ********************************** task path: /tmp/awx_897_usiyawjw/project/roles/list_repos/tasks/main.yml:2 fatal: [localhost]: FAILED! => {"changed": false, "content": "", "elapsed": 0, "msg": "Status code was -1 and not [200]: Request failed: <urlopen error [Errno 111] Connection refused>", "redirected": false, "status": -1, "url": "https://git.company.net/rest/api/1.0/projects/~p950ojb/repos"} PLAY RECAP ********************************************************************* localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

What am I missing?

Adding output with verbosity ‘4: Connection Debug’ (since cannot edit the original post)

`
ansible-playbook 2.9.2
config file = /etc/ansible/ansible.cfg
configured module search path = [u’/var/lib/awx/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 2.7.5 (default, Jun 11 2019, 14:33:56) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /tmp/awx_903_n07j1ejc/tmpyzzhv20e as it did not pass its verify_file() method
Set default localhost to localhost
Parsed /tmp/awx_903_n07j1ejc/tmpyzzhv20e inventory source with script plugin
Loading callback plugin awx_display of type stdout, v2.0 from /var/lib/awx/venv/awx/lib/python3.6/site-packages/ansible_runner/callbacks/awx_display.py

PLAYBOOK: list_operations_playbook.yml *****************************************
Positional arguments: list_operations_playbook.yml
diff: True
remote_user: root
become_method: sudo
inventory: (u’/tmp/awx_903_n07j1ejc/tmpyzzhv20e’,)
forks: 5
tags: (u’all’,)
extra_vars: (u’@/tmp/awx_903_n07j1ejc/env/extravars’,)
verbosity: 4
connection: smart
timeout: 30
1 plays in list_operations_playbook.yml

PLAY [List repos in a project] *************************************************

TASK [Gathering Facts] *********************************************************
task path: /tmp/awx_903_n07j1ejc/project/list_operations_playbook.yml:3
ESTABLISH LOCAL CONNECTION FOR USER: awx
EXEC /bin/sh -c ‘echo ~awx && sleep 0’
EXEC /bin/sh -c ‘( umask 77 && mkdir -p “echo /var/lib/awx/.ansible/tmp/ansible-tmp-1586417248.74-71622462422371” && echo ansible-tmp-1586417248.74-71622462422371=“echo /var/lib/awx/.ansible/tmp/ansible-tmp-1586417248.74-71622462422371” ) && sleep 0’
Attempting python interpreter discovery
EXEC /bin/sh -c ‘echo PLATFORM; uname; echo FOUND; command -v ‘"’"’/usr/bin/python’“'”‘; command -v ‘"’“‘python3.7’”’“'; command -v '”‘“‘python3.6’”’“'; command -v '”‘“‘python3.5’”’“'; command -v '”‘“‘python2.7’”’“'; command -v '”‘“‘python2.6’”’“'; command -v '”‘"’/usr/libexec/platform-python’“'”‘; command -v ‘"’"’/usr/bin/python3’“'”‘; command -v ‘"’“‘python’”’"‘; echo ENDFOUND && sleep 0’
EXEC /bin/sh -c ‘/usr/bin/python && sleep 0’
Using module file /usr/lib/python2.7/site-packages/ansible/modules/system/setup.py
PUT /var/lib/awx/.ansible/tmp/ansible-local-4904nN1BfG/tmpCC6Gr4 TO /var/lib/awx/.ansible/tmp/ansible-tmp-1586417248.74-71622462422371/AnsiballZ_setup.py
EXEC /bin/sh -c ‘chmod u+x /var/lib/awx/.ansible/tmp/ansible-tmp-1586417248.74-71622462422371/ /var/lib/awx/.ansible/tmp/ansible-tmp-1586417248.74-71622462422371/AnsiballZ_setup.py && sleep 0’
EXEC /bin/sh -c ‘/usr/bin/python /var/lib/awx/.ansible/tmp/ansible-tmp-1586417248.74-71622462422371/AnsiballZ_setup.py && sleep 0’
EXEC /bin/sh -c ‘rm -f -r /var/lib/awx/.ansible/tmp/ansible-tmp-1586417248.74-71622462422371/ > /dev/null 2>&1 && sleep 0’
ok: [localhost]
META: ran handlers

TASK [list_repos : user_private_repositories] **********************************
task path: /tmp/awx_903_n07j1ejc/project/roles/list_repos/tasks/main.yml:2
ESTABLISH LOCAL CONNECTION FOR USER: awx
EXEC /bin/sh -c ‘echo ~awx && sleep 0’
EXEC /bin/sh -c ‘( umask 77 && mkdir -p “echo /var/lib/awx/.ansible/tmp/ansible-tmp-1586417251.05-52017934597541” && echo ansible-tmp-1586417251.05-52017934597541=“echo /var/lib/awx/.ansible/tmp/ansible-tmp-1586417251.05-52017934597541” ) && sleep 0’
Using module file /usr/lib/python2.7/site-packages/ansible/modules/net_tools/basics/uri.py
PUT /var/lib/awx/.ansible/tmp/ansible-local-4904nN1BfG/tmpsEAI5j TO /var/lib/awx/.ansible/tmp/ansible-tmp-1586417251.05-52017934597541/AnsiballZ_uri.py
EXEC /bin/sh -c ‘chmod u+x /var/lib/awx/.ansible/tmp/ansible-tmp-1586417251.05-52017934597541/ /var/lib/awx/.ansible/tmp/ansible-tmp-1586417251.05-52017934597541/AnsiballZ_uri.py && sleep 0’
EXEC /bin/sh -c ‘/usr/bin/python /var/lib/awx/.ansible/tmp/ansible-tmp-1586417251.05-52017934597541/AnsiballZ_uri.py && sleep 0’
EXEC /bin/sh -c ‘rm -f -r /var/lib/awx/.ansible/tmp/ansible-tmp-1586417251.05-52017934597541/ > /dev/null 2>&1 && sleep 0’
fatal: [localhost]: FAILED! => {
“changed”: false,
“content”: “”,
“elapsed”: 0,
“invocation”: {
“module_args”: {
“attributes”: null,
“backup”: null,
“body”: null,
“body_format”: “raw”,
“client_cert”: null,
“client_key”: null,
“content”: null,
“creates”: null,
“delimiter”: null,
“dest”: null,
“directory_mode”: null,
“follow”: false,
“follow_redirects”: “safe”,
“force”: false,
“force_basic_auth”: true,
“group”: null,
“headers”: {
“Authorization”: “Bearer token-here”
},
“http_agent”: “ansible-httpget”,
“method”: “GET”,
“mode”: null,
“owner”: null,
“regexp”: null,
“remote_src”: null,
“removes”: null,
“return_content”: true,
“selevel”: null,
“serole”: null,
“setype”: null,
“seuser”: null,
“src”: null,
“status_code”: [
200
],
“timeout”: 30,
“unix_socket”: null,
“unsafe_writes”: null,
“url”: “https://git.company.net/rest/api/1.0/projects/~p950ojb/repos”,
“url_password”: null,
“url_username”: null,
“use_proxy”: true,
“validate_certs”: true
}
},
“msg”: “Status code was -1 and not [200]: Request failed: <urlopen error [Errno 111] Connection refused>”,
“redirected”: false,
“status”: -1,
“url”: “https://git.company.net/rest/api/1.0/projects/~p950ojb/repos
}

PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

`