win_pfx
Win-PFX
Create a PFX file from SSL key and certificate(s) to install on Windows Server.
Requirements
The local (controller) host must have the openssl
command line tools installed
if creating a PFX file from existing PEM-formatted key and certificate.
Role Variables
Use the following variable to specify whether to install or remove a certificate:
pfx_state
: Specify"present"
or"absent"
; default is"present"
.
If you already have the certificate as a PFX file, use the following variable to specify the path to that file:
pfx_file
: Local path to PFX file; default is""
, which means the SSL key and certificate must be specified using the other variables below.
If you only have the SSL key and certificate in PEM format, use the following variables to provide the source data:
pfx_key
: A string with the content (not the path) of the private key associated with the certificate. Default is""
, required unlesspfx_file
is specified.pfx_crt
: A string with the content (not the path) of the certificate. Default is""
, required unlesspfx_file
is specified.pfx_ca
: A string with the content of additional CA certificates that should be bundled into the PFX file; Default is""
.pfx_output_file
: A local path to save a copy of the PFX file generated by this role; default is""
, which does not save a copy.
This role will set the following variable after installing or removing the certificate:
pfx_import_result
: Dictionary withchanged
,log
andthumbprint
keys. The value ofthumbprint
may be used by later roles or tasks to reference the certificate that was installed.
Example Playbook
The following example playbook generates a PFX file from the given key and certificate and installs to a Windows host:
- hosts: windows
vars:
pfx_key: |
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCvV7EkKx8d0qNb
vCX+DS4mDqAeGDE+ErVPkSlFWzefSM64gIDgWvP/1vIuXArvooZcpTKg0KEiNsLc
IxHkDKa3i9di9DyaH4cH2clP518USd0tZGF8MYHvtzTq3HrTpbUgtl+WC1K7yuWA
++OLSTzmbHT9gn3NsU6Pw9bUIandVNeEv1X4zmile4eEZLmZlt0fJ3rnI7tagbhT
yNISs4pWMw8MqZLXVRpp4F3d8ZbWAnElmYKxQidovaJCuzEMuQd8Tkj05mgmiFxd
4cxAdZTFT0hkFOF7z47dCHQc1J5CEhQZkyi0GxyR4YEJd6AmLv9klfroYVUiFr8w
INBMg+wPAgMBAAECggEAR4Pywhe8Z0OEUWQZ8taZXfhVIjEn1HN48+z28kzUEOl3
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R0TBAUwAwEB
/zANBgkqhkiG9w0BAQsFAAOCAQEAo/DNOdY1uwWpAcbxtVDKq7uoLV2w/h8sdsaQ
fO/yiYRJe4qjP6LuaD1g+GUpVYclzcDjtN/iSKSGIs9qisN6S2UhrduaszwNNVMH
s5ZtLPtPwS79NOQXoTZ+FzvYGMCdSxd8yUunxmOd+tjBVYMYq+TqHVxO+BSHUOdY
H7cIRc8Ti7/sOZYqxO2Lr+X6DGJmpx/t4ML/KJAuOSpItL5I1aVZQ/dy+K+UayC/
0NfCeCkka+EbNuOkPVO9IZG2vUVjXcoOy2ByY+ILUPDYVAMX/o60PcOeehv9I9vA
FzlqXiU/LHGIKLwmrpwDBNwW8Ot8pibe4TJr9ODMXQb8GJhnzA==
-----END CERTIFICATE-----
roles:
- role: cchurch.win-pfx
License
GPLv3
Author Information
Chris Church chris@ninemoreminutes.com
ansible-galaxy install cchurch/ansible-role-win-pfx