Ansible issue with Windows and Chocolatey 0.10.13

50 views
Skip to first unread message

Guillaume Belrose

unread,
Mar 25, 2019, 3:50:30 PM3/25/19
to Ansible Project
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 *****************************************************************************************************************************************
training-app.vatit.io      : ok=1    changed=0    unreachable=0    failed=1

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.

In order for me to get the playbook to work again, I've uninstalled the latest version of Chocolatey, and installed a specific version (I find that version 0.10.11 works for me) by following the instructions from https://chocolatey.org/docs/installation#installing-a-particular-version-of-chocolatey. I also tried the following role (https://galaxy.ansible.com/deekayen/chocolatey) which helps to install a specific version. 

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.





Jordan Borean

unread,
Mar 25, 2019, 4:12:17 PM3/25/19
to Ansible Project
This is a known issue and is due to a breaking change on Chocolatey's end in the 0.10.12 release. See https://github.com/ansible/ansible/issues/53860#issuecomment-473431360 for more details.

Thanks

Jordan

Guillaume Belrose

unread,
Mar 26, 2019, 12:07:06 AM3/26/19
to ansible...@googlegroups.com
Hi, 

Thanks for the link, I wonder why I did not find it the 1st time around. 

I was initially using Ansible 2.4.x and the error message was very obscure, so the issue became more obvious when I tried Ansible 2.7.x.

Thanks for your help.

Guillaume. 

Sent from my iPhone
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/6_iHgmMyFnQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/678c9f88-14f6-4e39-a9a6-e9c32e89f95b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

cirrus.jas...@gmail.com

unread,
Apr 8, 2019, 10:16:33 AM4/8/19
to Ansible Project
Jordan,

Is it possible in a configuration file to specify the version of chocolatey to install?

Thanks

Jason

Jordan Borean

unread,
Apr 8, 2019, 7:42:51 PM4/8/19
to Ansible Project
Not something I've tested but if you are installing it from the public repo and not some internal repository you might be able to set the 'chocolateyVersion' environment variable as documented by https://chocolatey.org/install#installing-a-particular-version-of-chocolatey. This can be done with;

- win_chocolatey:
    name
: chocolatey
    state
: present
  environment
:
    chocolateyVersion
: '0.10.11'

This isn't something I've tested to prove it works so you would just have to try it and see how it goes. The alternative option is to use an internal repo and don't add the latest Chocolatey version nupkg and source it from there.

Thanks

Jordan

Guillaume Belrose

unread,
Apr 11, 2019, 5:10:26 AM4/11/19
to ansible...@googlegroups.com
Hi Jordan, 

I’ve just tried the approach that you suggested and it worked for me. 

Thanks for the tip. 

Guillaume.

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/6_iHgmMyFnQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages