Run Chef in another user

hello,

I’m trying to deploy a software tha has to be install in a expecific user

when I try this, the user doesn’t change(stays root).

execute ‘install_scos’ do
cwd '/home/S2K’
command "/opt/platform3pp/MICONYS/SCOS/S2K-5-5-1-issue-1/installMission.PARC
-c=Single -p=Standalone_single -z=Multi
/opt/platform3pp/MICONYS/SCOS/S2K-5-5-1-issue-1/SDCF_MCNYS61.xml"
user 'S2K’
group 'users’
action :run

Is there a way that i can why chef login in another user., and run commands in
there?
this has to be done in that user because it uses a diferente shell (tcsh).

Hey Ana,

execute uses mixlib-shellout https://github.com/opscode/mixlib-shellout
under the hood, which in turn (on Unix-y platforms) forks and sets the uid
https://github.com/opscode/mixlib-shellout/blob/master/lib/mixlib/shellout/unix.rb#L122-L127
of the child process. So, it does run the command “as” the specified user,
but it doesn’t “log in” as that user. If what you need is for your command
to run under tcsh as that user, you could use the script resource
http://docs.getchef.com/resource_script.html and specify an interpreter,
I think.

I notice that Chef actually has a “csh” resource
http://docs.getchef.com/resource_csh.html which might do the trick (since
tcsh is csh-compatible).

Matt Moretti

On Wed, Aug 13, 2014 at 9:30 AM, anasofia1072@gmail.com wrote:

hello,

I'm trying to deploy a software tha has to be install in a expecific user

when I try this, the user doesn't change(stays root).

execute 'install_scos' do
cwd '/home/S2K'
command
"/opt/platform3pp/MICONYS/SCOS/S2K-5-5-1-issue-1/installMission.PARC
-c=Single -p=Standalone_single -z=Multi
/opt/platform3pp/MICONYS/SCOS/S2K-5-5-1-issue-1/SDCF_MCNYS61.xml"
user 'S2K'
group 'users'
action :run

Is there a way that i can why chef login in another user., and run
commands in
there?
this has to be done in that user because it uses a diferente shell (tcsh).

Hello Matt

thank for you reply.
i finded very helpfull!
I could already find the sulotion for my problem.

ty

On Wed, Aug 13, 2014 at 2:54 PM, Matthew Moretti werebus@gmail.com wrote:

Hey Ana,

execute uses mixlib-shellout https://github.com/opscode/mixlib-shellout
under the hood, which in turn (on Unix-y platforms) forks and sets the uid
https://github.com/opscode/mixlib-shellout/blob/master/lib/mixlib/shellout/unix.rb#L122-L127
of the child process. So, it does run the command “as” the specified user,
but it doesn’t “log in” as that user. If what you need is for your command
to run under tcsh as that user, you could use the script resource
http://docs.getchef.com/resource_script.html and specify an
interpreter, I think.

I notice that Chef actually has a “csh” resource
http://docs.getchef.com/resource_csh.html which might do the trick
(since tcsh is csh-compatible).

Matt Moretti

On Wed, Aug 13, 2014 at 9:30 AM, anasofia1072@gmail.com wrote:

hello,

I'm trying to deploy a software tha has to be install in a expecific user

when I try this, the user doesn't change(stays root).

execute 'install_scos' do
cwd '/home/S2K'
command
"/opt/platform3pp/MICONYS/SCOS/S2K-5-5-1-issue-1/installMission.PARC
-c=Single -p=Standalone_single -z=Multi
/opt/platform3pp/MICONYS/SCOS/S2K-5-5-1-issue-1/SDCF_MCNYS61.xml"
user 'S2K'
group 'users'
action :run

Is there a way that i can why chef login in another user., and run
commands in
there?
this has to be done in that user because it uses a diferente shell (tcsh).