Ansible:如果一个证书已经安装在证书存储
问题描述:
检测的最佳方式虽然等待the new certificate module,我们以下面的方式安装证书:Ansible:如果一个证书已经安装在证书存储
win_shell: Import-PfxCertificate -filepath "{{ certificatePath }}" -certStorelocation cert:\\localmachine\\My -password $(ConvertTo-SecureString -AsPlainText -Force -String "{{ organization_key }}")
这工作得很好,但我没有如果证书已经安装,找到任何好方法来跳过任务。我知道你可以运行SET-LOCATION CERT:\LOCALMACHINE
,它提供了作为文件系统访问证书存储的权限,但是可以执行类似creates=cert:\localmachine\path\to\my\cert
这样的操作吗?
这里最好的策略是什么?
答
答案是很简单: creates=Cert:\\LOCALMACHINE\\My\\{{ CertificateThumbprint }}
。
答
的Test-Path
小命令还与证书提供商:
if (Test-Path cert:\localmachine\path\to\my\cert)
{
}
请注意'\\“{{CertificateThumbrint}}”'需要转义.. – amosti