I'm trying to copy the Certificate of a local Container registry to a Docker host with ansible version 2.9.6. The registry is managed by someone else but within our local network.
With the shell I would do it in this way:
openssl s_client -showcerts -connect registry.example:443 < /dev/null 2> /dev/null | openssl x509 -outform PEM > ca.crt
So far I worked my way around the community.crypto
module for ansible ans managed to get the certificate with:
- name: get certificate from registry
community.crypto.get_certificate:
host: "{{ registry_url }}"
port: "{{ registry_port }}"
delegate_to: localhost
become: no
register: cert
This behaves like the first half of the shell alternative. What I still haven't figured out is how to do the job of the second half, which would be creating the certificate with the content received from the server.
I tried using community.crypto.x509_certificate
but I can not make it behave like the openssl_client
would in the following shell example.
openssl x509 -outform PEM -in server_content_file -text -out ca.crt
Is there a way to do this with the community.crypto
module or in any other way using ansible?