I'm trying to run this command using Ansible's shell module:
openssl s_client -connect router1.lab.net:50051
My Ansible play looks like this:
---
- hosts: lab
connection: local
tasks:
- name: Check cert with OpenSSL
shell: |
openssl s_client -connect {{ ansible_host }}:50051
register: cert
ignore_errors: yes
- name: Print cert data
debug:
msg: "{{ cert }}"
when: cert is succeeded
When I run the playbook with -vvv I get the following error:
"stderr": "139631224861120:error:0200206F:system library:connect:Connection refused:../crypto/bio/b_sock2.c:110:\n139631224861120:error:2008A067:BIO routines:BIO_connect:connect error:../crypto/bio/b_sock2.c:111:\nconnect:errno=111",
"stderr_lines": [
"139631224861120:error:0200206F:system library:connect:Connection refused:../crypto/bio/b_sock2.c:110:",
"139631224861120:error:2008A067:BIO routines:BIO_connect:connect error:../crypto/bio/b_sock2.c:111:",
"connect:errno=111"
]
The same openssl command works when I run it from Linux command line and gives the proper output.
I tried installing ansible-galaxy collection install community.crypto (https://ansible.fontein.de/collections/community/crypto/x509_certificate_pipe_module.html) but that didn't help.