cwd option not working with cmd.run and runas
See original GitHub issueDescription of Issue
cwd
option from cmd.run
state is not working in combination with runas
option (on macOS at least)
I have arrived to this problem through the git.latest
and git.cloned
states.
These states are failing with the following comment:
fatal: not a git repository (or any of the parent directories): .git
(Possible related issues #43185 and #586)
Setup
SLS recipe
running as root:
cmd.run:
- name: pwd
- cwd: /Users/Carlos/Desktop
running as user:
cmd.run:
- name: pwd
- cwd: /Users/Carlos/Desktop
- runas: Carlos
powerlevel9k present:
git.latest:
- name: https://github.com/bhilburn/powerlevel9k.git
- target: /Users/Carlos/.oh-my-zsh/custom/themes/powerlevel9k
- user: Carlos
- require:
- oh-my-zsh present
Output
----------
ID: running as root
Function: cmd.run
Name: pwd
Result: True
Comment: Command "pwd" run
Started: 16:12:18.764387
Duration: 9.628 ms
Changes:
----------
pid:
73618
retcode:
0
stderr:
stdout:
/Users/Carlos/Desktop
----------
ID: running as user
Function: cmd.run
Name: pwd
Result: True
Comment: Command "pwd" run
Started: 16:12:18.774467
Duration: 55.428 ms
Changes:
----------
pid:
73619
retcode:
0
stderr:
stdout:
/Users/Carlos
----------
ID: powerlevel9k present
Function: git.latest
Name: https://github.com/bhilburn/powerlevel9k.git
Result: False
Comment: fatal: not a git repository (or any of the parent directories): .git
Started: 16:12:18.831065
Duration: 1908.322 ms
Changes:
Versions Report
(Provided by running salt --versions-report
. Please also mention any differences in master/minion versions.)
Salt Version:
Salt: 2018.3.3
Dependency Versions:
cffi: 1.11.5
cherrypy: unknown
dateutil: 2.4.2
docker-py: 1.10.6
gitdb: 2.0.5
gitpython: 2.1.11
ioflo: 1.7.5
Jinja2: 2.8
libgit2: 0.27.7
libnacl: 1.6.1
M2Crypto: 0.31.0
Mako: 1.0.7
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: 2.19
pycrypto: 3.7.2
pycryptodome: Not Installed
pygit2: 0.27.2
Python: 3.5.2 (default, Nov 12 2018, 13:43:14)
python-gnupg: 0.3.8
PyYAML: 3.11
PyZMQ: 15.2.0
RAET: 0.6.8
smmap: 2.0.5
timelib: 0.2.4
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: Ubuntu 16.04 xenial
locale: ANSI_X3.4-1968
machine: x86_64
release: 4.4.59+
system: Linux
version: Ubuntu 16.04 xenial
Update
The git.latest
task was working before upgrading my saltstack minion from 2018.3.2
to 2018.3.3
(with salt-master in 2018.3.3
)
I have installed salt in my minion workstation with @Homebrew
brew install salt
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Under what circumstance runas as administrator default to ...
On the first server, when runas administrator the batch file runs from its current directory (in this case c:\app) but on another server,...
Read more >Why does 'Run as administrator' change (sometimes) batch ...
In this new user session the current working directory is %SystemRoot%\System32 on executing now the command defined in Windows registry ...
Read more >windows - How do I set an executable's working directory via ...
I would like to run such a program from a console window and set its working directory to the current or other explicit...
Read more >salt.states.cmd - Salt Project Documentation
The command to execute, remember that the command will execute with the path and permissions of the salt-minion. cwd. The current working ......
Read more >FTP transfers via Command line
See the help topic "command line" in the Core FTP help file for a detailed list of options and examples. Common Issues: Site...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Still seeing this behavior in 2019.2 (we just attempted to upgrade from 2017.7)
Since the git execution module piggybacks on cmd.run for execution, this effectively means that the git module is completely unusable on macOS since the 2018.3.2 release. While a workaround exists for users of the cmd.run module itself, no such workaround exists for the git module.
Seems like this should be ‘High Severity’ per https://docs.saltstack.com/en/latest/topics/development/labels.html
I’m having the same problem on Windows with Salt 2018.3.3.
salt windows-minion cmd.run cd cwd='C:\'
returnsC:\
like one would expect, butsalt windows-minion cmd.run cd cwd='C:\' runas='.\local-user' password='password'
returnsc:\salt\bin
. The same goes for cmd.run states that userunas
andrunas_password
. As a workaround I’ve prefixed the commands I run withcd wherever &&
, which works in the Windows command interpreter like on Unix.