ansible - Ansible 从本地机器获取指纹哈希
问题描述
我试图从本地机器的证书存储中获取指纹,这样我就可以使用散列的变量将指纹传递给ssl_bindings
任务。到目前为止,我有这个,但它返回了很多数据。我应该过滤掉数据还是有更简单的方法从现有商店获取指纹?我已经看到使用 powershell 完成了这一点,所以如果我无法解决这个问题,我可能会走这条路。
- name: Obtain information about LocalMachines Cert Store
community.windows.win_certificate_info:
store_location: LocalMachine
register: cert
解决方案
我最终这样做了。如果有人知道如何使用本机 ansible 模块来获取哈希,那就太酷了。
- name: Run powershell one-liner to get the thumbprint hash
ansible.windows.win_powershell:
script: |
(Get-ChildItem cert:\LocalMachine\My | where-object { $_.Subject -like "*$hostname*" } | Select-Object -Last 1).Thumbprint
register: hash
- name: Add an HTTPS binding to the website using the hash
win_iis_webbinding:
name: "{{ iis_site }}"
protocol: https
port: 443
certificate_hash: "{{ hash.output[0] }}"
state: present
推荐阅读
- android - FFMPEG 命令从图像(JPEG)+ 音频(.mp3)制作视频并在 Whatsapp 中分享视频
- python - 无法在 RobotFramework 中写入现有文本文件
- postgresql - PgAdmin 4 备份用户
- python - pycharm 无法加载 django 应用程序
- laravel - 使用 dropzone js 和 laravel 与其他表单字段一起上传自定义文件
- python - 从 Github 提取更新后 Django 400 Bad request
- php - 如何在 Auth::attempt 方法中传递 OR?
- postgresql - PostgreSQL - 排序混乱的数据(递归?)
- hive - 无法在 Data Proc Hive Operator 中使用文件进行查询
- android - 在标记顶部设置 MapOverlay 自定义视图时出现 Map Premium 计划问题