windows command from ansible / returning error

I am trying to install oracle client in silent mode by runing the following task from ansible and its returning an error:

- name: Install Oracle client 12.1.0.2.1
win_command: C:\tmp\ODAC121021_x64\setup.exe -silent -responseFile C:\tmp\client.rsp
ignore_errors: yes

The error is:

fatal: [uat_cdxdb]: FAILED! => {“changed”: true, “cmd”: “C:\tmp\ODAC121021_x64\setup.exe -silent -responseFile C:\tmp\client.rsp”, “delta”: “0:00:15.234405”, “end”: “2018-10-11 07:50:06.842169”, “msg”: “non-zero return code”, “rc”: 259, “start”: “2018-10-11 07:49:51.607764”, “stderr”: “”, “stderr_lines”: , “stdout”: “\r\n Exit code of OUI process 259=”, “stdout_lines”: [“”, " Exit code of OUI process 259="]}

If I run the command directly from windows, directly through power shell its working

You would need to find out what an error code of 259 means in the context of the installer. When you run it locally are you getting the same return code, in powershell this is set to ‘$LASTEXITCODE’, in cmd.exe you can get the last rc with ‘echo %ERRORLEVEL%’.

Thanks

Jordan

when I run it locally on windows server the command is working and oracle client is installed silently

Ok so you need to fix out what error 259 means. Look to see if you can enable any logging to identify the issue, this would all be specific to that installer so start with the company that produces it and read through their docs.

Also as an FYI, normally an rc of 259 means the process is still active [1] which tells me the installer is still running in the background. I do remember seeing an issue with the Oracle installer not working in Ansible and exits straight away and there’s a special command line argument or response file value you must set for it to wait until the installer is complete. Have a look at the setup.exe documentation and see what you can find.

This may not be the case with the Oracle installer as the code could mean something else but this scenario does sound familiar.

[1] https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-getexitcodeprocess