[chef] Can't seem to run command in bash resource as another user?


Chronological Thread 
  • From: o haya < >
  • To:
  • Cc:
  • Subject: [chef] Can't seem to run command in bash resource as another user?
  • Date: Tue, 21 Jul 2015 12:07:17 -0700

Hi,

I am trying to implement a recipe for installing an application, but I have 
to run the installer .bin file (in the /tmp/app) as a specific user "appuser",

I'm doing this in a bash resource, and have tried:

bash 'xxx" do
  cwd "/tmp/app"
  code <<EOH
    su - appuser
    ./app.bin.......
  EOH
end

But that doesn't seem to be work (I get an explicit error from the app in the 
bash resource saying that I have to not be root when I run the app).

I've tried some things I've found from googling, such as:

bash "installxxxx" do
  user "appuser"
  cwd "/tmp/app"
  environment ({ 'HOME' => ::Dir.home('appuser'), 'USER' => 'appuser' })
  code <<-EOH
     ./app.bin...
  EOH
end

and that if failing because it seems to still be writing some files with 
"root" ownership, rather than with "appuser" ownership.

Can someone tell me why this (the "su - appuser" isn't working and also how 
can I get it to work?

Thanks,
Jim



Archive powered by MHonArc 2.6.16.

§