Ansible win_chocolatey module – System.OutOfMemoryException error

ansiblewindows-server-2008-r2

I'm trying to use Ansible to install software on Windows server 2008 R2 via win_chocolatey module. It doesn't work as it throws error:

[ERROR] – Chocolatey had an error on WIN-2008r2 (with user Administrator): System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.Runtime.CompilerServices.RuntimeHelpers._CompileMethod(IRuntimeMethodInfo method) at System.Reflection.Emit.DynamicMethod.CreateDelegate(Type delegateType, Object target) at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda, DebugInfoGenerator debugInfoGenerator) at System.Management.Automation.Interpreter.LoopCompiler.CreateDelegate() at System.Management.Automation.Interpreter.EnterLoopInstruction.Compile(Object frameObj) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch()

Command "choco install" works when used on the server.

I tried to increase memory limit for PowerShell and for WinRM.

set-item wsman:localhost\Shell\MaxMemoryPerShellMB 2048

winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="2048"}'

What else could be the problem?