how to debug random errors on win_msi Windows module?

I know about calling with the -vvvv option, and that displays what the error is, but I’m wondering what I need to do to get to the root of the problem.

I’ve had great success with the win_get_url. I’ve had some success with the win_msi module, but some failures as well, and they’re usually pretty serious.

I’m on the latest of the development branch, * 75bd1fa Tue Aug 26 11:49:02 2014 -0500

I’ve also recently put Trond’s changes / improvements into the win_msi module and see the same results.

So what I’d like to know is, other than the info that’s spit out when passing -vvvv, what should I be looking for on the host to help debug this? Nothing in /var/log jumped out at me.

Here is the recipe

`

Here is a subsequent success on both (ran again bc the HTTP 500 isn’t
the error I normally see)

ok: [node1.domain.com] => {“changed”: false, “exit_reason”: {“name”: “File specified in creates parameter already exists”}}
<node3.domain.com> WINRM RESULT <Response code 0, out “{ “changed”: t”, err " Process is terminat">
changed: [node3.domain.com] => {“changed”: true, “log”: “C:\Users\dummy\AppData\Local\Temp\tmp30A4.tmp”}

Hi Damon,

That’s weird,
I tried your playbook on two 2012R2 hosts just now, and it worked fine. Only thing I noticed is that you’re saving to a “non-standard” folder. Could you test it by setting the dest to dest: ‘C:\tortoise-1.7.msi’ or something in win_Get_url?

About debugging: It’s kinda hard, because Ansible cleans up the temp files. I’m gonna post an issue to see if we can get a “win_debug” setting in ansible.cfg to enable leaving the files in place so that we can run the generated script and param file through a normal PowerShell debugger. For now you have to take the params you send and store them as a json file. Then, combine the module ps1 file with the powershell.ps1 file into a single file and execute that file in powershell with the params file as the first and only argument. Its bothersome to say the least.

BTW, i have a brand spankin new win_package module coming up which will handle not only msis but all kinds of installs, and also supports auto-downloading source files from a url so that you don’t need to win_get_url first. I’m waiting for some improvements to the powershell helper scripts to be merged before i PR that module, but let me know and I’d be happy to share it with you.

-Trond

That would be awesome on the debugging, because I’d like to be able to help, but feel kinda helpless.

Yeah since switching to your changes (which I guess I forgot to link to) it’s been working better generally, because it’s seeing that the product is installed so it doesn’t try to run it again.

I’m going to try removing the bit that checks if it’s already installed and run it a few more times.

What I saw earlier was before your changes, it would usually install successfully the first time and sometimes even the second time, but eventually it’d start throwing the SOs.

Yah that’d be great. I’ll happily test it out if you like.

I’m only targeting Svr 12s, and just using it right now to set up new build agent nodes. I want to do a lot more with it but figured that would be a good place to start.

Cool, I’m writing up a short doc and putting it on a branch in my ansible fork right now. Will send you links and stuffs in a couple of minutes.

Here you go sir:
https://github.com/trondhindenes/ansible/tree/win_package

Note that I’m using the updated helper functions from the main powershell.ps1 script, so you’ll need to grab that as well. You can grab if from this PR:
https://github.com/ansible/ansible/pull/8759 (the powershell.ps1 file goes in /lib/ansible/module_utils in your ansible directory structure)

I’m still somewhat of a git noob;

I’ve cloned your repo, but I’m not sure how to get the pull request from 8759 into that clone…

I’m guessing there’s a command to merge, any pointers?

I found this…

http://stackoverflow.com/a/1426163/734790

I’m testing that out.

Me too. I would just grab the file manually and stick it in your on fork for now:
https://raw.githubusercontent.com/trondhindenes/ansible/win_setup_json_depth/lib/ansible/module_utils/powershell.ps1

My repo has a branch for each change/PR i’ve submitted, so you’re probably better off forking the original ansible code and just come up with your own way of managing the various changes you put in it. I guess I should try and rebase everything back into my devel branch, but it’s that’s not the case right now.

That’s exactly what I did to get your changes into the mainline, so I’m doing that again.

You want me to post feedback (if I have any) in this thread or on the pull request?

This thread is fine. I haven’t submitted a PR for win_package just yet.

There it is, finally!!!

This is still using the win_msi, I’ll switch to the win_package now.

I’m not sure why but I just wasn’t going to be happy until I broke it.

`
changed: [node1.domain.com]
Traceback (most recent call last):
File “/home/damon/src/ansible/lib/ansible/runner/connection_plugins/winrm.py”, line 149, in exec_command
result = self._winrm_exec(cmd_parts[0], cmd_parts[1:], from_exec=True)
File “/home/damon/src/ansible/lib/ansible/runner/connection_plugins/winrm.py”, line 118, in _winrm_exec
response = Response(self.protocol.get_command_output(self.shell_id, command_id))
File “/usr/local/lib/python2.7/dist-packages/winrm/protocol.py”, line 277, in get_command_output
self._raw_get_command_output(shell_id, command_id)
File “/usr/local/lib/python2.7/dist-packages/winrm/protocol.py”, line 293, in _raw_get_command_output
rs = self.send_message(xmltodict.unparse(rq))
File “/usr/local/lib/python2.7/dist-packages/winrm/protocol.py”, line 173, in send_message
return self.transport.send_message(message)
File “/usr/local/lib/python2.7/dist-packages/winrm/transport.py”, line 90, in send_message
raise WinRMTransportError(error_message)
WinRMTransportError: Bad HTTP response returned from server. Code 500
fatal: [node3.domain.com] => failed to exec cmd PowerShell -NoProfile -NonInteractive -EncodedCommand KABOAGUAdwAtAEkAdABlAG0AIAAtAFQAeQBwAGUAIABEAGkAcgBlAGMAdABvAHIAeQAgAC0AUABhAHQAaAAgACQAZQBuAHYAOgB0AGUAbQBwACAALQBOAGEAbQBlACAAIgBhAG4AcwBpAGIAbABlAC0AdABtAHAALQAxADQAMAA5ADAAOQAyADkAOAA2AC4ANgAtADIANwA2ADMAMAA3ADAAMAA2ADUAMgA0ADEAOAAiACkALgBGAHUAbABsAE4AYQBtAGUAIAB8ACAAVwByAGkAdABlAC0ASABvAHMAdAAgAC0AUwBlAHAAYQByAGEAdABvAHIAIAAnACcAOwA=

Nice,
So, Chris just tipped me about this ansible.cfg setting:
[defaults]
keep_remote_files = 1

Stick that in your /ansible/etc/ansible.cfg and re-run your playbook with -vvv

All those temp paths Ansible uses for powershell files will now be left on your windows system. Each folder basically has a script file (the module) and an arguments file. That should do wonders for debugging windows modules (it would still require some PowerShell proficiency tho)

Awesome I’ll give that as shot.

The biggest thing I wanted to know was how to catch the output so I can at least try to debug it or ask for help, so that’ll be huge.

I’m off for the night tonight but I’ll be testing out win_package tomorrow for sure. I’ll let you know how it goes.

OK I’m testing it out.

First, I love that you can pass arguments. I have been automating the Jenkins clients; I’m adding a specific version of SVN, and with the win_msi installer, I couldn’t figure out how to pass arguments to it so it would install the Command Line Interface.

With the win_package, that is super easy, so I was happy to see that!

But I ran into my first situation; if you give it a URL and the download file doesn’t include the extension, it will fail to install. Test out this url:

http://sourceforge.net/projects/tortoisesvn/files/1.7.15/Application/TortoiseSVN-1.7.15.25753-x64-svn-1.7.18.msi/download

Running a plain wget, wget http://sourceforge.net/projects/tortoisesvn/files/1.7.15/Application/TortoiseSVN-1.7.15.25753-x64-svn-1.7.18.msi/download will download the installer as “download” so I’m assuming the scripts are doing the same.

So, it probably needs an option to specify the output file, much like you would with wget -o or wget --output-file.

I changed it to run win_get_url to download the package so I could rename the file (using ‘dest’).

And then, I hit a nice System.OutOfMemoryException. This server isn’t that beefy and it’s wanting to run updates, so it could be that… but I’m going to try to grab the remote files anyway.

I wasn’t running -vvvv, here’s what I saw:

failed: [clone] => {“failed”: true, “parsed”: false}
invalid output was: Exception of type ‘System.OutOfMemoryException’ was thrown.
At C:\Users\dummy\AppData\Local\Temp\ansible-tmp-1409241114.17-71859971213315
\win_package.ps1:1395 char:5

  • if ($testdscresult -eq $true)
  • CategoryInfo : OperationStopped: (:slight_smile: , OutOfMemoryException
  • FullyQualifiedErrorId : System.OutOfMemoryException

FATAL: all hosts have already failed – aborting

Cool I just hit the StackOverflow again.

I used win_get_url to download, and then win_package to install. I am using the updated powershell.ps1 script from 8759, but I have seen it without that as well.

`
failed: [clone] => {“failed”: true, “parsed”: false}
invalid output was:
Process is terminated due to StackOverflowException.

FATAL: all hosts have already failed – aborting