Varun Shankar | 30 Oct 12:21 2014

Newbie design related doubt

I know that attributes can be configured in cookbooks (attribute files and recipes), roles, and environments. 

Suppose I have a requirement on the following lines:
- Two environments: alpha and beta
- Two web servers: web-1, web-2
- Apache should run on port 80 on web-1 in alpha
- Apache should run on port 8080 on web-2 in alpha
- Apache should run on port 8081 on web-1 and web-2 in beta

I can have two approaches:
SOLUTION 1. Write a role cookbook (using application/library pattern) and override the apache[listen_ports] attribute in the role cookbook. Again override the apache[listen_ports] attribute in my chef-repo/environments/alpha.rb and chef-repo/environments/beta.rb file. But this way the configuration for Apache is scattered in multiple places (environment files, role cookbooks and the apache community cookbook).

SOLUTION 2. Write a wrapper cookbook over the community apache cookbook. In the attribute file of my wrapper cookbook, I write logic like this:

apache[listen_ports] = 8080
if env is alpha
  if role is web1
    apache[listen_ports] = 80
  elseif role is web2
    apache[listen_ports] = 8080

This way all apache settings are consolidated in one place i.e. in the cookbook.

I have seen all the blog posts suggest the first solution. Why is the second solution a bad idea? 

Kamesh Sampath | 30 Oct 08:29 2014

Repetitive Tasks


I have a scenario where I am trying to create  cluster of servers a.k.a nodes on a box provisioned by Chef, so the structure of the servers  nodes are typically same, there will be slight modification to the server configuration files that are deployed.

I just did  server_nodes.each do |x,y| {  all my chef tasks }, i see some discrepancies when running my chef tasks,  e.g. one of my chef task will create a template for one sever node it creates correctly for other it complains the directory does not exist as when i checked the node it did not have the directory … all is well when i run as single node. Does chef has any best practice or the way to do for these kind of scenarios ?


oliver.naaris | 30 Oct 08:24 2014

Problem deploying Java app

Hi all!

I've been lurking in this mailing list for over a year and this is my first
time posting here.
Anyway, I was trying to setup a demo Java environment using this tutorial:

The problem is that when I try to bootstrap the node I get the following
I'm also curious of how other companies are deploying Java apps - are you using
the application_java cookbook or some other mechanism?

Error executing action `before_deploy` on resource

Cannot find a resource matching service[tomcat] (did you define it first?)

Cookbook Trace:
/var/chef/cache/cookbooks/application_java/providers/tomcat.rb:48:in `block (2
levels) in class_from_file'
/var/chef/cache/cookbooks/application_java/providers/tomcat.rb:46:in `block in
/var/chef/cache/cookbooks/application/providers/default.rb:110:in `block (3
levels) in before_deploy'
/var/chef/cache/cookbooks/application/providers/default.rb:109:in `each'
/var/chef/cache/cookbooks/application/providers/default.rb:109:in `block (2
levels) in before_deploy'

Resource Declaration:
# In /var/chef/cache/cookbooks/application/resources/default.rb

115:	   resource = super(resource_name.to_sym,, &block)
116:	   break

Compiled Resource:
# Declared in /var/chef/cache/cookbooks/application/resources/default.rb:115:in
`block in method_missing'

application_java_tomcat("jaxrs_tutorial") do
  action [:nothing]
  retries 0
  retry_delay 2
  cookbook_name "jaxrs_tutorial"
  recipe_name "default"
  type :tomcat
#<Proc:0x000000035134e0 <at> /var/chef/cache/cookbooks/application_java/providers/tomcat.rb:27>

Error executing action `run` on resource 'ruby_block[jaxrs_tutorial

application_java_tomcat[jaxrs_tutorial] (jaxrs_tutorial::default line 115) had
an error: Chef::Exceptions::ResourceNotFound: Cannot find a resource matching
service[tomcat] (did you define it first?)

Cookbook Trace:
/var/chef/cache/cookbooks/application_java/providers/tomcat.rb:48:in `block (2
levels) in class_from_file'
/var/chef/cache/cookbooks/application_java/providers/tomcat.rb:46:in `block in
/var/chef/cache/cookbooks/application/providers/default.rb:110:in `block (3
levels) in before_deploy'
/var/chef/cache/cookbooks/application/providers/default.rb:109:in `each'
/var/chef/cache/cookbooks/application/providers/default.rb:109:in `block (2
levels) in before_deploy'

Resource Declaration:
# In /var/chef/cache/cookbooks/application/providers/default.rb

107:   ruby_block "#{} before_deploy" do
108:	 block do
109:	   new_resource.sub_resources.each do |resource|
110:	     resource.run_action :before_deploy
111:	   end
112:	   callback(:before_deploy, new_resource.before_deploy)
113:	 end
114:   end
115: end

Compiled Resource:
# Declared in /var/chef/cache/cookbooks/application/providers/default.rb:107:in

ruby_block("jaxrs_tutorial before_deploy") do
  action "run"
  retries 0
  retry_delay 2
  block_name "jaxrs_tutorial before_deploy"
  cookbook_name "jaxrs_tutorial"
#<Proc:0x00000003466538 <at> /var/chef/cache/cookbooks/application/providers/default.rb:108>

Thanks and Regards,
Oliver Naaris

Indra k | 30 Oct 05:30 2014

reg cluster deployment

Hi all,

      How to use a cluster deployment using knife ?

        i ve seen some options like using knife cluster like that but to implement that?


   is this possible to use environment ,role like that?

Thanks & regards,
 Indra K
bjbq4d | 30 Oct 03:50 2014

Configure server to integer mapping

Hi everyone,

For a few services like zookeeper or kafka, they require a server to integer
mapping like this,

server a - 1
server b - 2

This is particularly difficult to do in Chef (outside of manually configuring
this) using things like search. Some methods I have tried or seen,

 1. Search for nodes and sort nodes by name. Use the index of each server as
their id. This can cause servers to use the same id for a moment if
provisioning servers concurrently. This can also cause problems if a new node
doesn't get appended to the end causing a number of servers to change their

 2. Convert ipaddress or some other attribute into an integer. Unfortunately
this produces an integer too large as services like zookeeper only allow ids
between 0-255.

 3. Set this id on the node during provisioning and track the current id
somewhere. Then you can use search to just get the mapping.

Does anyone have other suggestions? It seems like 3 is the best option though
not terrible easy to do. It could be easier than I think if I use something
like chef-metal and define each machine with an id.


Joe Nuspl | 29 Oct 23:21 2014

Hooking into execute resources in chefspec

I’m automating some 3rd party code.  What I have is something like:

execute ‘refresh’ do
  only_if { CONDITION }

execute ‘reconfigure' do
  only_if { ::File.exists?(GUARD) }

Sometimes refresh creates GUARD.  GUARD could also be created by an admin. reconfigure removes GUARD upon success.

I am try to write chefspec tests to cover all the cases:

1) no-existing-guard refresh-creates-gaurd
2) no-existing-guard refresh-does-not-create-guard

3) existing-guard refresh-creates-guard
4) existing-guard refresh-does-not-create-guard
5) no-existing-guard no-refresh
6) exisiting-guard no-refresh

What I want to do is to “hook” into execute[refresh] and conditionally update the ::File.exists? stub to return true.

If I update the stub before the run, I’ve collapsed #1 and #4 into one case.

Is it possible to hook into a resource?   I tried :step_into but that did not seem to do the trick.  Any guidance would be appreciated.


Justin Franks | 29 Oct 18:56 2014

knife openstack how to create/attach volume?

What is knife openstack syntax to create a volume and attach it to the server?

I want to pass it in with the knife openstack server create command

Justin Franks
Lead Operations Engineer
SaaS, Cloud, Data Centers & Infrastructure
Lithium Technologies, Inc
225 Bush St., 15th Floor
San Francisco, CA 94104
tel: +1 415 757 3100 x3219
Daniel DeLeo | 29 Oct 18:20 2014

ChefDK 0.3.2 Released

Hi Chefs, 

We just released ChefDK 0.3.2 which fixes some issues with the CA certificate bundle included in the ChefDK
omnibus package. Most notably, this fixes certificate verification errors when berkshelf fetches
cookbooks from Supermarket.

For further information, please read the release announcement: 


Daniel DeLeo

chefamirasulin | 29 Oct 14:50 2014

Newbie chef-client question

New to Chef, I may be missing the concept.
Can someone pls advise where do I set the client timeout interval
(i.e what is the time interval used by default that a client will pull
recipes/cookbook updates from the 
Chef Server)

Many thanks in advance,

pvikasroonwal | 29 Oct 13:22 2014

Is it possible to have the chef repo in svn instead of git


I am new to Chef and have been able to install the Chef server on an RHEL
machine and chef-client version 11.16.4 on a windows machine.

When running the knife cookbook site install <cookbook name> command on windows
I get an error stating that the folder e:/chef-repo/cookbooks is not a git

The setup steps for chef-repo state that it is not necessary to use git and one
can download the tar, extract it and then commit to the source control of
choice (SVN or CSV).

Is this correct? Is there a setting that needs to be changed to enable knife to
work with SVN instead of GIT?


amanscollection | 29 Oct 11:27 2014

Apply cookbooks on multiple nodes at same time

Hi All,

I have a requirement where cookbooks present on chef server need to be applied
to 5 nodes at the same time. I didn't find any suitable way in chef. Please
suggest can we achieve this through chef?

Amandeep Singh