Hi all,
I use Ansible to deploy Chocolatey packages on Windows Server 2016 machines (hosted on Amazon EC2). Yesterday, I re-created a brand new cluster for training purposes and I attempted to re-deploy my applications on it from scratch.
I've done this process countless times but yesterday it started to fail even though the playbooks had not changed in a while. After a fair amount of debugging, I found out that the error is caused by Chocolatey version 0.10.13.
Because the EC2 instances were created yesterday (24/03/2019), version 0.10.13 is the version that Ansible installed when it invoked the win_chocolatey command the 1st time around.
A playbook as simple as: ---
- hosts: app_servers
tasks:
- name: ensure Google Chrome is installed
win_chocolatey:
name: googlechrome
would then fail with the following error:
PLAY [app_servers] *********************************************************************************************************************************
TASK [Gathering Facts] *****************************************************************************************************************************
TASK [ensure Google Chrome is installed] ***********************************************************************************************************
fatal: [
training-app.vatit.io]: FAILED! => {"changed": false, "command": "C:\\ProgramData\\chocolatey\\bin\\choco.exe list --local-only --exact --limit-output googlechrome", "msg": "Error checking installation status for the package 'googlechrome'", "rc": 2, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
to retry, use: --limit @/ansible/app_server.retry
PLAY RECAP *****************************************************************************************************************************************
It turns out when you run the command directly on the Windows server
C:\ProgramData\chocolatey\bin\choco.exe list --local-only --exact --limit-output googlechrome
then it fails with an error code. But it does not with earlier versions of chocolatey.
I don't know if this is an Ansible bug, a Chocolatey bug or something in between. In my mind, Chocolatey should not return an error when checking if a package is already installed.
I did spend a fair amount of time debugging this issue, so I hope it is useful to someone in the same situation as me.
Cheers,
Guillaume.