0

I need to implement openssl command pkcs12 in Ansible 2.4 The latest Ansible version provides a module called openssl_pkcs12, but how to implement this in Ansible 2.4? So far, I have tried to put this command in the action of openssl_certificate like this:

name: openssl create hostcertificate.key
openssl_certificate:
  action: pkcs12
  attributes: '"-nocerts" "-nodes"'
  src: <path-to-certificate>.p12
  path: <destination-path>.key
  mode: '400'
  state: present

But it throws "Unsupported paramaters for (openssl_certificate) module" error as this action is not supported by openssl_certificate module. How can I implement this for this version?

Moreover, I need to automate the following openssl command, so please review if there are any other mistakes I made in the above Ansible script:

openssl pkcs12 -nocerts -nodes -out <destination-path>.key -in <path-to-certificate>.p12

Thanks in advance

mythr
  • 80
  • 1
  • 10

1 Answers1

0

This can be simply resolved by using the 'shell' module. I did it by using the following ansible task:

- name: openssl create hostcertificate.key
  shell: "openssl pkcs12 -nocerts -nodes -out <destination-path>/hostcertificate.key -in <path-to-key>/hostcertificate.p12"
mythr
  • 80
  • 1
  • 10