[chef] Re: Running package install with sudo


Chronological Thread 
  • From: Christian Requena < >
  • To:
  • Subject: [chef] Re: Running package install with sudo
  • Date: Wed, 8 Dec 2010 00:08:45 +0100
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:mime-version:content-type:subject:date:in-reply-to:to :references:message-id:x-mailer; b=CKHSankmeyYOo8ZRPPi+amJWim6aCwIkKTl3BqFZrNV4YTCqxUNyuDoeue5bFujFb6 LRMTQiUeTnUnbnqOzZ4KkOWUNjxpp7bOkejydC4KC7W1AXGHjieH4q8z5iwWe3oM1ZNu rNgNkd1sFNfFXPq5oYEOHyg32mj4v4p/QcVYQ=

Hi,

you can define your commands freely.

Example for tomcat. 

Define what do you want to do (i.e. in an attribute file):

# start the service
default[:tomcat][:start]= (platform == 'windows') ? 'C:\Applications\tomcat\bin\catalina.sh start' : \
                                                    "sudo service tomcat start"
# stop the service
default[:tomcat][:stop]= (platform == 'windows') ? 'C:\Applications\tomcat\bin\catalina.sh stop' : \
                                                   "sudo service tomcat stop"
#
# get service status. TODO: windows!?
default[:tomcat][:status]="sudo service tomcat status"

Overwrite the start,stop,... commands in your recipe:

...
service "tomcat" do
  action :nothing
  supports :start => true, :stop => true, :restart => true, :status => false 
  start_command node[:tomcat][:start]
  stop_command node[:tomcat][:stop]
  status_command node[:tomcat][:status]
  restart_command "#{node[:tomcat][:stop]} && #{node[:tomcat][:start]}"
end
...

hope that helps.


Salu2,
Christian


On 07.12.2010, at 22:37, Tristan Sloughter wrote:

I run my chef clients not as root. I want to be able to install an rpm (the RPM does not allow it to be relocated with --prefix, so it must go in /usr). 

I didn't want to but it seems I need to either run the client as root or make my user have sudo access with no password.

I decided to try the user be able to run sudo without a password to install packages. However the 'package' resource does not appear to have a way to tell it to run as a certain user. 

Is this true? Is there a way or am I stuck either running the client as root or using a bash command instead of the 'package' resource?

Thanks,
Tristan




Archive powered by MHonArc 2.6.16.

§