我正在尝试将本地容器注册表的证书复制到具有 ansible 版本 2.9.6 的 Docker 主机。注册表由其他人管理,但在我们的本地网络中。
使用外壳我会这样做:
openssl s_client -showcerts -connect registry.example:443 < /dev/null 2> /dev/null | openssl x509 -outform PEM > ca.crt
到目前为止,我在community.crypto
模块上工作了 ansible ans 设法获得证书:
- name: get certificate from registry
community.crypto.get_certificate:
host: "{{ registry_url }}"
port: "{{ registry_port }}"
delegate_to: localhost
become: no
register: cert
这类似于 shell 替代方案的前半部分。我还没有弄清楚如何完成后半部分的工作,即使用从服务器接收到的内容创建证书。
我尝试使用community.crypto.x509_certificate
,但无法使其表现得像openssl_client
以下 shell 示例中的那样。
openssl x509 -outform PEM -in server_content_file -text -out ca.crt
有没有办法用community.crypto
模块或以任何其他方式使用 ansible 来做到这一点?