代码之家  ›  专栏  ›  技术社区  ›  Rudy van Sloten

Ansible巧克力神秘地失败了?

  •  0
  • Rudy van Sloten  · 技术社区  · 7 年前

    我试图在Azure VM上运行ansible playbook,但遇到了一个奇怪的问题。试图安装任何软件(试图安装的git、sysinternals、nscp)都无法启动。

    win_chocolatey:
            name: git
            state: present  
    

    甚至不会触发安装尝试。除了尝试列出软件,日志中没有其他内容。它只是试图列出软件,并抛出它不存在(因为所述软件未安装)

    win_chocolatey:
            name: git
            state: absent  
    

    在手动安装git之后,它工作得非常好。我已经尝试过使用win_Chocolate将使用的命令手动安装软件包(根据文档),而且效果很好。使用与剧本完全相同的用户。(拥有管理员权限)

    我还试图用 become ,(尽管它已经运行admin),但这并不重要。

    -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 (工程)

    0 回复  |  直到 7 年前
        1
  •  1
  •   Madison    7 年前

    巧克力0.10.12中增加了增强的退出代码,这被列为突破性的改变。

    chocolatey.org/docs/release-notes

    为了解决这个问题,已经进行了一些简单的更改(请参见 github.com/chocolatey/choco/issues/1758 ),但现在您可以根据发行说明禁用该功能

    choco feature disable --name="'useEnhancedExitCodes'"