- From: "Jason J. W. Williams" <
>
- To: "
" <
>
- Cc: "
" <
>
- Subject: [chef] Re: Setting Environment Variables
- Date: Sat, 20 Aug 2011 11:44:42 -0600
It's got to go into the init.d script you install/generate to start your program.
-J Sent via iPhone
Is your email Premiere? On Aug 20, 2011, at 11:09, Brian Jakovich <
">
> wrote: How do I go about setting environment variables in chef? I've tried several methods such as adding them to a template and then sourcing it. Adding them to attributes. I'm out of ideas...
## Problem
The JENKINS_HOME environment variable doesn't get set. It should however be set using the template "default_jenkins.erb" whenever I go into the instance and echo $JENKINS_HOME it does not return anything
## Current status
Currently it successfully takes the jenkins war from the remote location and places it into the webapps directory of Tomcat. When I go to the http://PublicDNS:8080/jenkins Jenkins is running. (It does however complain about not being able to create .jenkins directory, AKA Jenkins Home, and suggests that there is a problem with its permissions)
## default recipe
# Setting local variables
jenkinsWar = node[:jenkins][:war] webapp_dir = node["tomcat"]["webapp_dir"] tomcat_user = node["tomcat"]["user"] tomcat_group = node["tomcat"]["group"]
# Getting the Jenkins.war and putting it into the tomcat webapps directory remote_file "/#{webapp_dir}/#{jenkinsWar}" do source "#{node[:jenkins][:url]}" mode "0644" owner "root"
group "root" end
# Setting Jenkins configuration template "/etc/default/jenkins" do source "default_jenkins.erb" owner "root" group "root" mode "0644" notifies :restart, resources(:service => "tomcat")
end
## default_jenkins.erb
# Set Jenkins home variable. This will tell Jenkins where to find it's jobs/plugins/etc JENKINS_HOME=<%= node[:jenkins][:home] %>
## default attribute
default[:jenkins][:war] = "jenkins.war" default[:jenkins][:home] = "/var/lib/jenkins" default[:jenkins][:url] = "https://s3.amazonaws.com/cookbook-resources/#{node[:jenkins][:war]}"
|
Archive powered by MHonArc 2.6.16.