HI folks,I have copied a batch file from ansible to windows and want to run it.If i go to the windows machine and run it it works fine, but when I run it from playbook it fails.Here is the playbook:
---
- name: test script module
hosts: builders
tasks:
- name: run simple script
win_command: C:\Users\pkmbuilder\Desktop\configure_builder.bat
And here is the batch:
::Install cygwin
setup-x86_64.exe --root C:\cygwin64 --quiet-mode --site http://cygwin.mirror.constant.com --packages "openssh,rsync,zip,vim,wget" || exit /b 1
When running via cli I get
root@Raspi_Ctrl:/ansible/playbook# ansible-playbook /ansible/playbook/batch.yml -i /ansible/hosts
PLAY [test script module] ******************************************************
TASK [Gathering Facts] *********************************************************
ok: [100.]
TASK [run simple script] *******************************************************
fatal: [100.6]: FAILED! => {"changed": true, "cmd": "C:\\Users\\pkmbuilder\\Desktop\\configure_builder.bat", "delta": "0:00:00.304048", "end": "2017-11-09 02:22:46.953264", "msg": "non-zero return code", "rc": 1, "start": "2017-11-09 02:22:46.649216", "stderr": "'setup-x86_64.exe' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n", "stderr_lines": ["'setup-x86_64.exe' is not recognized as an internal or external command,", "operable program or batch file."], "stdout": "\r\nC:\\Users\\pkmbuilder>setup-x86_64.exe --root C:\\cygwin64 --quiet-mode --site http://cygwin.mirror.constant.com --packages \"openssh,rsync,zip,vim,wget\" || exit /b 1 \r\n", "stdout_lines": ["", "C:\\Users\\pkmbuilder>setup-x86_64.exe --root C:\\cygwin64 --quiet-mode --site http://cygwin.mirror.constant.com --packages \"openssh,rsync,zip,vim,wget\" || exit /b 1 "]}
to retry, use: --limit @/ansible/playbook/batch.retry
PLAY RECAP *********************************************************************
100. : ok=1 changed=0 unreachable=0 failed=1
What variables need I set to get this running?
Thanks!
- win_command: cmd.exe /c dir
args:
chdir: C:\temp
Not sure if either of these are the answer but a couple of things you can try..
Try using win_shell instead of win_command. I think it may handle args differently (because it is running inside a shell).
Another thing you could try is using with_items to pass each of the packages you are installing separately, thereby avoiding the comma in your command line. Probably a bit slower but if it works it might be good enough for you to move on to the next thing.
Hope this helps,
Jon
Thanks
Jordan