Closed diraol closed 4 years ago
I would just use su -c
or su -lc
if you need a login shell.
example:
goss a command 'su someuser -c "echo \$PATH;whoami"'
or if you need a login shell:
goss a command 'su someuser -lc "echo \$PATH;whoami"'
Depending on where some of your $PATH and other things are defined, sometimes you need the -l
loginshell.
Let me know if that resolves it for you.
Yeah, that's one of the possibilities that I thought of.
Another approach I'm trying is to run goss twice, one as root with a gossfile specifying tests to be executed as root and another one with the given user passing another gossfile.yml:
su -l jenkins -c "goss ...."
But I guess I'll stick with the first option because the second approach brings the need of merging goss output reports (junit)... it is getting messy... :)
Anyway, thanks for the fast answer!
If I face problems I'll reopen the issue.
Hi, I couldn't find any reference or issue to something like this. If there is already one, please just point me to it!
What I would like to know is if there is a way to run
command
tests as a specific user other than root (or the one being used).My context is that I'm building an Image (AWS AMI) and running the tests as root. But I'd like to know if a specific command is available to a user (jenkins) and is executable by this user.
Being more specific, I want to install
awscli
andyamllint
, both are installed using pythonpip
"package manager", but by installing it in the system using root I have faced issues when trying to execute usingjenkins
user.So, what I would like to test using goss is running
yamllint --version
withjenkins
user.Any suggestion?
Thanks! :)