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


Chronological Thread 
  • From: Thom May < >
  • To: Chef < >
  • Cc:
  • Subject: [chef] Re: Can't seem to run command in bash resource as another user?
  • Date: Wed, 22 Jul 2015 15:26:37 +0100

Hi Jim,
I think we need more information about "still seems to be writing files with root ownership". You mean the installer is? or something else is? Can you paste the output of your chef run?
Thanks,
-Thom

On Tue, Jul 21, 2015 at 8:07 PM, o haya < " target="_blank"> > wrote:
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.

§