--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8581aa1e-4010-4616-b399-771acf2fa96f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thank you for the suggestion, Mike.I've tried it both ways, and neither of them works. In fact, the "YAML Syntax" doesn't seem to actually attempt to change directory - if I use that, I get an error along the lines of file not found or command not found, indicating that it isn't even going to the directory. If I put it up on the line with win_command, it seems to actually try to chdir, but fails due to the space.
I forgot to mention in the original post that I have tried all sorts of variations of double and single quotes and combinations thereof, and that hasn't made a difference - however it gets passed in to the command, it seems like PowerShell ends up interpreting it as C:\Program and just chopping it off at the space.
I am able to get a command in a directory to run using PowerShell's special escape syntax:& 'C:\Program Files\Application\mycmd.exe'
But this doesn't seem to work in the chdir argument. Unfortunately because the application that I'm running relies on the presence of certain files in the current working directory, I need to actually move to that directory.
Thanks,Nick
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/15ccacde-3e94-4347-a0f7-d5013bbb6d6f%40googlegroups.com.
chdir: 'C:\Program Files\your path\goes\here'
- name: run an executable inside a folder with a space
win_command: '"C:\Program Files\Microsoft Windows\some-exe.exe" /argument1 "/argument 2 with space" "/argument 3 with '' single quote"'
# or with chdir (note: you shouldn't have to quote the chdir arg)
- name: run an executable with custom working dir
win_command: some-exe.exe /argument1 "/argument 2 with space"
args:
chdir: C:\Program Files\Microsoft Windows
- name: run an executable with a space (powershell)
win_shell: &"C:\Program Files\Microsoft Windows\some-exe.exe" @("/argument1", "/argument 2 with space")
- name: run an executable with a space (cmd)
win_shell: '"C:\Program Files\Microsoft Windows\some-exe.exe" /argument1 "/argument 2 with space"'
args:
executable: cmd.exe
- hosts: '2016'
gather_facts: no
tasks:
- win_shell: pwd
args:
chdir: C:\Program Files
- win_shell: cd
args:
executable: cmd.exe
chdir: C:\Program Files
TASK [win_shell] ********************************************************************************************************************************************
task path: /Users/jborean/dev/module-tester/adhoc.yml:4
Using module file /Users/jborean/dev/ansible/lib/ansible/modules/windows/win_shell.ps1
<SERVER2016.domain.local> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO SERVER2016.domain.local
EXEC (via pipeline wrapper)
changed: [SERVER2016.domain.local] => {
"attempts": 1,
"changed": true,
"cmd": "pwd",
"delta": "0:00:00.640518",
"end": "2018-01-07 08:41:58.701292",
"rc": 0,
"start": "2018-01-07 08:41:58.060773",
"stderr": "",
"stderr_lines": [],
"stdout": "\r\nPath \r\n---- \r\nC:\\Program Files\r\n\r\n\r\n",
"stdout_lines": [
"",
"Path ",
"---- ",
"C:\\Program Files",
"",
""
]
}
TASK [win_shell] ********************************************************************************************************************************************
task path: /Users/jborean/dev/module-tester/adhoc.yml:8
Using module file /Users/jborean/dev/ansible/lib/ansible/modules/windows/win_shell.ps1
<SERVER2016.domain.local> ESTABLISH WINRM CONNECTION FOR USER: vagrant on PORT 5986 TO SERVER2016.domain.local
EXEC (via pipeline wrapper)
changed: [SERVER2016.domain.local] => {
"attempts": 1,
"changed": true,
"cmd": "cd",
"delta": "0:00:00.249102",
"end": "2018-01-07 08:41:59.919811",
"rc": 0,
"start": "2018-01-07 08:41:59.670709",
"stderr": "",
"stderr_lines": [],
"stdout": "C:\\Program Files\r\n",
"stdout_lines": [
"C:\\Program Files"
]
}
META: ran handlers
META: ran handlers