我试图在Azure VM上运行一个ansible playbook,但我遇到了一个奇怪的问题。尝试安装任何软件(尝试git,sysinternals,nscp)都不会触发。
win_chocolatey:
name: git
state: present
甚至不会触发安装尝试。除了尝试列出软件之外,日志中没有任何内容。它只是试图列出软件,并抛出它不存在(因为没有安装所述软件)
win_chocolatey:
name: git
state: absent
手动安装git后,工作完美。我已经尝试使用win_chocolatey将使用的命令手动安装包(根据文档)并且它可以工作。使用与剧本完全相同的用户。 (拥有管理员权限)
我也尝试用become
强制管理帐户,(尽管它已经运行了管理员),但重要的不是。
-vvvv
甚至没有显示安装尝试:
TASK [Download and install chocolatey packages] **************************************************************
task path: /usr/user/clouddrive/windows-vm/create-vm-windows.yml:162
Using module file /opt/ansible/local/lib/python2.7/site-packages/ansible/modules/windows/win_chocolatey.ps1
<my.ip.address.here> ESTABLISH WINRM CONNECTION FOR USER: AzureAdministrator on PORT 5986 TO my.ip.address.here
checking if winrm_host my.ip.address.here is an IPv6 address
EXEC (via pipeline wrapper)
failed: [my.ip.address.here] (item={u'choco_name': u'git', u'choco_state': u'present'}) => {
"changed": false,
"command": "C:\\ProgramData\\chocolatey\\bin\\choco.exe list --local-only --exact --limit-output git",
"item": {
"choco_name": "git",
"choco_state": "present"
},
"msg": "Error checking installation status for the package 'git'",
"rc": 2,
"stderr": "",
"stderr_lines": [],
"stdout": "",
"stdout_lines": []
}
我错过了什么吗?文档(https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html#examples)说即使是基本的东西,如:
- name: Install git
win_chocolatey:
name: git
应该安装包(状态是否存在,我已经尝试过没有状态,任何其他,只有absent
工作)
增强的退出代码被添加到Chocolatey 0.10.12中,其被列为重大变化。
chocolatey.org/docs/release-notes
已经进行了Ansible更改以解决此问题(请参阅github.com/chocolatey/choco/issues/1758),但是现在您可以根据发行说明禁用该功能
choco feature disable --name="'useEnhancedExitCodes'"