Win_command module adds an additional slash to the windows path.

566 views
Skip to first unread message

anoop vc

unread,
Nov 6, 2017, 5:30:02 AM11/6/17
to Ansible Project
Please find my YAML below


*******************************************************
---
- hosts: all
  vars:
  tasks:
  - name: Save the result of 'whoami' in 'whoami_out'
    win_command: groovy c:\AnsibletestWorkspace\deploy_latest.groovy
    register: whoami_out

************************************************************************************************

It adds an additional slash(c:\\AnsibleMaximoWorkspace\\deploy_latest.groovy) to the windows path the tell cannot find the path specified. I tried with backslash then it's not add the double slash but still trown the error path to the file not found. 

I tried all the different combinations for specfy the path but no luck. 


J Hawkesworth

unread,
Nov 7, 2017, 4:16:16 AM11/7/17
to Ansible Project
You don't mention which ansible version you are using, but I think latest devel version and possible 2.4.1 has some improvements to argument handling for win command.

If you are using an older ansible version, I suggest trying win_shell.   Make sure groovy is on your PATH (or use the args: chdir option of win_command / win_shell so that the command itself can be found too).

There's a very useful page about how to form windows paths in yaml for ansible playbooks recently been added to the documentation here: https://docs.ansible.com/ansible/devel/windows_usage.html#path-formatting-for-windows

Hope this helps,

Jon
Reply all
Reply to author
Forward
0 new messages