DaemonTool recipe and environment variables


#1

Hi,
I’m using the daemontools cookbook to run mt services on the VM, but I cannot
get the recipe to create the /etc/service/my-service/env directory.

This is what I have :-

daemontools_service “juliet-cache” do
directory "/etc/service/juliet-cache"
template "cache"
action [:enable,:start]
owner "root"
group "root"
env = {“JAVA_HOME” => “/usr/bin”, “TANGOOL_HOME” => “/u01/juliet-cache”}
log true
end

Everything works, except the env directory and the two files are not created. I
don’t see any error message either.

Have I got the syntax for this option right?

Thanks,

~JT


#2

Hello,

On Sep 4, 2011, at 6:00 PM, johnptoohey@gmail.com johnptoohey@gmail.com wrote:

env = {“JAVA_HOME” => “/usr/bin”, “TANGOOL_HOME” => “/u01/juliet-cache”}

Remove the = between env and the hash:

env {“JAVA_HOME” => “/usr/bin”, “TANGOOL_HOME” => “/u01/juliet-cache”}

Your syntax sets a local variable named env to that hash instead, not setting the parameter to the resource.


Opscode, Inc
Joshua Timberman, Director of Training and Services
IRC, Skype, Twitter, Github: jtimberman


#3

Hi all,

In one of my cookbook template .erb files I am trying to do this:

<%
appservers=search(:node, ‘roles:appserver’)
appservers.each do |appserver|
%>

server <%= appserver.automatic_attrs[“fqdn”] %>

<% end %>

This works when I use ‘shef’ on the chef-client node

But when I run chef-client, the following fatal error is being produced:

Chef::Mixin::Template::TemplateError (undefined method `search’ for #Erubis::Context:0x7f294e418830) on line #3

What am I doing wrong? Do I need to somehow import the chef DSL? Thanks


Geoff


#4

Geoff, you should be doing the search inside the recipe, not in the
template. You then pass the results of the search into the template
for your iterator. Look here (the “variables” example) -
http://wiki.opscode.com/display/chef/Resources#Resources-Template

On Wed, Sep 7, 2011 at 11:02 AM, Geoff Meakin Acid
geoffmeakin@aciddevelopments.co.uk wrote:

Hi all,

In one of my cookbook template .erb files I am trying to do this:

<%
appservers=search(:node, ‘roles:appserver’)
appservers.each do |appserver|
%>

server <%= appserver.automatic_attrs[“fqdn”] %>

<% end %>

This works when I use ‘shef’ on the chef-client node

But when I run chef-client, the following fatal error is being produced:

Chef::Mixin::Template::TemplateError (undefined method `search’ for #Erubis::Context:0x7f294e418830) on line #3

What am I doing wrong? Do I need to somehow import the chef DSL? Thanks


Geoff