Ansible:检测证书是否已安装在证书存储中的最佳方法
Ansible: Best way to detect if a certificate is already installed in the Certificate Store
在等待 the new certificate module 期间,我们正在通过以下方式安装证书:
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
?
的操作
最好的策略是什么?
Test-Path
cmdlet 也适用于证书提供商:
if (Test-Path cert:\localmachine\path\to\my\cert)
{
}
答案很简单:
creates=Cert:\LOCALMACHINE\My\{{ CertificateThumbprint }}
。
在等待 the new certificate module 期间,我们正在通过以下方式安装证书:
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
?
最好的策略是什么?
Test-Path
cmdlet 也适用于证书提供商:
if (Test-Path cert:\localmachine\path\to\my\cert)
{
}
答案很简单:
creates=Cert:\LOCALMACHINE\My\{{ CertificateThumbprint }}
。