Jira (BOLT-1430) Standardize working directory for local transport

4 views
Skip to first unread message

Cas Donoghue (JIRA)

unread,
Jun 26, 2019, 2:26:03 PM6/26/19
to puppe...@googlegroups.com
Cas Donoghue created an issue
 
Puppet Task Runner / New Feature BOLT-1430
Standardize working directory for local transport
Issue Type: New Feature New Feature
Assignee: Unassigned
Created: 2019/06/26 11:25 AM
Priority: Normal Normal
Reporter: Cas Donoghue

Currently the directory from which commands are executed are different depending on the combination of transport and bolt host.
For the local transport on windows bolt controller:
https://github.com/puppetlabs/bolt/blob/614025c960ec13af79ca13f213521c7ad53d2b96/lib/bolt/transport/local_windows.rb#L89-L99
The command is executed from a temp directory

PS C:\Users\Administrator> bolt command run "powershell.exe -noprofile -command pwd" -t localhost
Started on localhost...
Finished on localhost:
  STDOUT:
 
    Path
    ----
    C:\Users\Administrator\AppData\Local\Temp\d20190626-1844-57cb6z
 
 
Successful on 1 node: localhost
Ran on 1 node in 0.23 seconds

For the Local transport on non windows it is executed from whatever directory bolt is executed from:
https://github.com/puppetlabs/bolt/blob/614025c960ec13af79ca13f213521c7ad53d2b96/lib/bolt/transport/sudoable.rb#L25-L36

cas@cas-ThinkPad-T460p:~/working_dir/bolt$ bolt command run 'pwd' -t localhost
Started on localhost...
Finished on localhost:
  STDOUT:
    /home/cas/working_dir/bolt
Successful on 1 node: localhost
Ran on 1 node in 0.00 seconds
cas@cas-ThinkPad-T460p:~/working_dir/bolt$ bolt command run 'pwd' -t localhost --run-as root --sudo-password
Please enter your privilege escalation password: 
Started on localhost...
Finished on localhost:
  STDOUT:
    /home/cas/working_dir/bolt
Successful on 1 node: localhost
Ran on 1 node in 0.01 seconds

For the ssh transport the command is executed from the home directory of the user specified in transport config. For the winrm transport it is from the default powershell session directory https://docs.microsoft.com/en-us/windows/desktop/shell/csidl

We should decide how to standardize this. Perhaps it makes sense to make local transport on non-windows be consistent with ssh and for windows mirror the behavior of ssh.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Cas Donoghue (JIRA)

unread,
Jun 26, 2019, 2:37:03 PM6/26/19
to puppe...@googlegroups.com
Cas Donoghue commented on New Feature BOLT-1430
 
Re: Standardize working directory for local transport

Conversation from slack:
Are people running commands over the local transport? What directory do you expect commands to be run from? Currently when running commands over winrm/ssh `run command` executes from the users home directory. For the local transport on non-windows the command executes from whatever directory bolt was invoked from. For windows local transport the command is executed from a randomized temporary directory. What would make the most sense to standardize on?

nmaludy [10:11 AM]
on local i expect it to be run from wherever bolt was run from
would be nice in both cases if you could specify `cwd` for the command/script/etc

iristyle [10:17 AM]
On Windows, I would expect initial working directory to be users home directory

When you start an interactive PowerShell session, that’s where you start (unless you’ve elevated, in which case you start in `c:\windows\system32`.

When you connect over winrm, you end up in the users documents folder (at least on my machine) - let me see if there are any docs around that
```C:\Windows\system32> whoami
desktop-phtd0h8\iristyle
C:\Windows\system32> Enter-PSSession localhost
[localhost]: PS C:\Users\Iristyle\Documents>```

Yasmin Rajabi (JIRA)

unread,
Aug 19, 2019, 6:33:03 PM8/19/19
to puppe...@googlegroups.com

Cas Donoghue (JIRA)

unread,
Aug 20, 2019, 10:31:03 AM8/20/19
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages