我正在尝试通过 Ansible 安装 PowerShell7-MSI 包。在执行过程中,Ansible 似乎卡住了(至少大约 45 分钟......)。对于安装,我使用 win_package
模块。我还发现了这个 SO question 不幸的是没有答案。
我尝试安装的主机是:
OS Name: Microsoft Windows 10 Enterprise
OS Version: 10.0.19042 N/A Build 19042
Ansible 版本:
ansible 2.9.16
config file = /etc/ansible/ansible.cfg
executable location = /usr/bin/ansible
python version = 3.6.8 (default, Aug 24 2020, 17:57:11) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
剧本:
---
# tasks file for common
- name: Create temp directory
win_file:
path: "{{ ansibleRemoteTemp }}"
state: directory
- name: Copy Powershell package
win_copy:
src: ../files/PowerShell-7.1.0-win-x64.msi
dest: "{{ ansibleRemoteTemp }}/PowerShell-7.1.0-win-x64.msi"
- name: Install PowerShell 7
win_package:
product_id: '{8B34F593-C5DF-47D9-AD0E-23D579F6D83E}'
path: "{{ ansibleRemoteTemp }}/PowerShell-7.1.0-win-x64.msi"
state: present
arguments: ' /package PowerShell-7.1.0-win-x64.msi /quiet ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 ENABLE_PSREMOTING=1 REGISTER_MANIFEST=1'
arguments
基于此 docs.microsoft.com 链接。
这是我的 Ansible 输出:
...
TASK [common : Copy Powershell package] *************************************************************************************************************************************************************************
ok: [server_14] => {
"changed": false,
"checksum": "517a93072f1f3d2d82b4634a506a84a808f63de2",
"dest": "C:/Users/ansibletestuser/AppData/Local/Temp/playbookPackages/PowerShell-7.1.0-win-x64.msi",
"operation": "file_copy",
"original_basename": "PowerShell-7.1.0-win-x64.msi",
"size": 99663872,
"src": "../files/PowerShell-7.1.0-win-x64.msi"
}
TASK [common : Install PowerShell 7] ****************************************************************************************************************************************************************************
HERE WE ARE STUCK