Cookbook ignored in run-list


#1

Ohai Chefs:

I’m setting up a node that will have Nginx, Tomcat, and a Tomcat application running JDK7.

I’ve written a wrapper cookbook around the community tomcat cookbook, mostly to add an application LWRP to grab the artifact from our Artifactory repository and deploy it. Testing this cookbook, called ome_tomcat via Vagrant works perfectly. Here’s the run-list from the ome_tomcat Vagrantfile:

config.vm.provision :chef_solo do |chef|
chef.json = {
:tomcat => {
:base_version => ‘7’,
:java_options => “-server -Xms768M -Xmx768M -XX:MaxPermSize=256M -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -Dreusestatement.debug.sql=true -Ddevel -DdebugOn=true -DextendedLoggingOn -Dlog4j.configuratorClass=ksutelc.common.log.TelcConfigurator -DdisableProcessingUnhandledExceptions”
}
}

chef.run_list = [
    "recipe[est-apt]",
    "recipe[ome_java::jdk7]",
    "recipe[ome_tomcat::default]"
]

end
end

Another wrapper cookbook I have is ome_nginx, which like the Tomcat wrapper, adds a LWRP we use.

I also have a cookbook for the application getting installed. It’s called ome_telecom_creditcard. Here is the run list from the Vagrantfile for the application deployment cookbook:

config.vm.provision :chef_solo do |chef|
chef.log_level = :debug
chef.json = {
:tomcat => {
:base_version => ‘7’,
:java_options => “-server -Xms768M -Xmx768M -XX:MaxPermSize=256M -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -Dreusestatement.debug.sql=true -Ddevel -DdebugOn=true -DextendedLoggingOn -Dlog4j.configuratorClass=ksutelc.common.log.TelcConfigurator -DdisableProcessingUnhandledExceptions”
},
:ome_tomcat => {
:artifact_url => “https://tools.ome.ksu.edu/artifactory/ome-telecom-release/telecom/credit-card-webapp/2.1.1/credit-card-webapp-2.1.1.war”,
:version => “2.1.1”,
:artifact_checksum => ‘522726822fcc79e52f4fe0c5240eca9b’
}
}

chef.run_list = [
    "recipe[est-apt]",
    "recipe[ome_java::jdk7]",
    "recipe[ome_tomcat::default]",
    "recipe[ome_nginx::default]",
    "recipe[ome_telecom_creditcard::default]"
]

end
end

When I run vagrant up against the ome_telecom_creditcard Vagrantfile, the ome_tomcat cookbook appears to be ignored. Where it includes tomcat never happens.

If I comment out the last recipe in the run_list, like so:


chef.run_list = [
“recipe[est-apt]”,
“recipe[ome_java::jdk7]”,
“recipe[ome_tomcat::default]”,
“recipe[ome_nginx::default]”,
# "recipe[ome_telecom_creditcard::default]”

Everything works. Obviously the issue is with the default recipe for ome_telecom_creditcard. However for the life of me I can’t see what I’m doing in this recipe that would cause the tomcat process to not even happen.

I’ve turned the log level to :debug and traced through all the loading of attributes and recipes and can see where it load both the tomcat::default and ome_tomcat::default recipes, but neither executes.

I am stumped as to what I’ve screwed up.

The default recipe for ome_telecom_creditcard uses the LWRP created by ome_tomcat and ome_nginx to deploy the artifact if and when it’s version number changes.

Here is that recipe:

Remove the previous credit-card app

ome_tomcat_application “credit-card.war” do
action :remove

version “2.1.1”

notifies :restart, "service[tomcat7]"
end

Deploy the Telecom credit-card app

ome_tomcat_application “credit-card.war” do

artifact_url “https://tools.ome.ksu.edu/artifactory/ome-telecom-release/telecom/credit-card-webapp/2.1.1/credit-card-webapp-2.1.1.war

version “2.1.1”

artifact_checksum = ‘522726822fcc79e52f4fe0c5240eca9b’

action :deploy
end

Include the OME Nginx wrapper cookbook and override the default_root

attribute

node.default[‘nginx’][‘default_root’] = '/usr/share/nginx/www’
include_recipe ‘ome_nginx::default’

Populate Nginx SSL directory with key and certificate

cookbook_file “www-secure.telecom.cer” do
path "#{node[‘ome_nginx’][‘ssl_directory_path’]}/www-secure.telecom.cer"
owner "www-data"
group "root"
mode "0644"
end

cookbook_file “www-secure.telecom.key” do
path "#{node[‘ome_nginx’][‘ssl_directory_path’]}/www-secure.telecom.key"
owner "www-data"
group "root"
mode "0600"
end

Setup the site configurations with Nginx

ome_nginx_configuration “credit-card.conf” do
action :create
end

ome_nginx_configuration “credit-card-ssl.conf” do
action :create
notifies :restart, 'service[nginx]'
end

Open up the ports required by the application

include_recipe “firewall”

firewall_rule “https” do
port 443
protocol :tcp
action :allow
end

firewall_rule “http” do
port 8080
protocol :tcp
action :allow
end

firewall_rule “http” do
port 80
protocol :tcp
action :allow
end

Any help or ideas will be greatly appreciated.

Thanks
Mark


#2

All -

It appears that referencing the LWRP in ome_tomcat was causing the problem. By refactoring that resource to a definition the run list behaves as I expect. Very odd.

— Mark

On Aug 7, 2014, at 1:56 PM, Mark Nichols chef@zanshin.net wrote:

Ohai Chefs:

I’m setting up a node that will have Nginx, Tomcat, and a Tomcat application running JDK7.

I’ve written a wrapper cookbook around the community tomcat cookbook, mostly to add an application LWRP to grab the artifact from our Artifactory repository and deploy it. Testing this cookbook, called ome_tomcat via Vagrant works perfectly. Here’s the run-list from the ome_tomcat Vagrantfile:

config.vm.provision :chef_solo do |chef|
chef.json = {
:tomcat => {
:base_version => ‘7’,
:java_options => “-server -Xms768M -Xmx768M -XX:MaxPermSize=256M -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -Dreusestatement.debug.sql=true -Ddevel -DdebugOn=true -DextendedLoggingOn -Dlog4j.configuratorClass=ksutelc.common.log.TelcConfigurator -DdisableProcessingUnhandledExceptions”
}
}

chef.run_list = [
    "recipe[est-apt]",
    "recipe[ome_java::jdk7]",
    "recipe[ome_tomcat::default]"
]

end
end

Another wrapper cookbook I have is ome_nginx, which like the Tomcat wrapper, adds a LWRP we use.

I also have a cookbook for the application getting installed. It’s called ome_telecom_creditcard. Here is the run list from the Vagrantfile for the application deployment cookbook:

config.vm.provision :chef_solo do |chef|
chef.log_level = :debug
chef.json = {
:tomcat => {
:base_version => ‘7’,
:java_options => “-server -Xms768M -Xmx768M -XX:MaxPermSize=256M -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -Dreusestatement.debug.sql=true -Ddevel -DdebugOn=true -DextendedLoggingOn -Dlog4j.configuratorClass=ksutelc.common.log.TelcConfigurator -DdisableProcessingUnhandledExceptions”
},
:ome_tomcat => {
:artifact_url => “https://tools.ome.ksu.edu/artifactory/ome-telecom-release/telecom/credit-card-webapp/2.1.1/credit-card-webapp-2.1.1.war”,
:version => “2.1.1”,
:artifact_checksum => ‘522726822fcc79e52f4fe0c5240eca9b’
}
}

chef.run_list = [
    "recipe[est-apt]",
    "recipe[ome_java::jdk7]",
    "recipe[ome_tomcat::default]",
    "recipe[ome_nginx::default]",
    "recipe[ome_telecom_creditcard::default]"
]

end
end

When I run vagrant up against the ome_telecom_creditcard Vagrantfile, the ome_tomcat cookbook appears to be ignored. Where it includes tomcat never happens.

If I comment out the last recipe in the run_list, like so:


chef.run_list = [
“recipe[est-apt]”,
“recipe[ome_java::jdk7]”,
“recipe[ome_tomcat::default]”,
“recipe[ome_nginx::default]”,
# "recipe[ome_telecom_creditcard::default]”

Everything works. Obviously the issue is with the default recipe for ome_telecom_creditcard. However for the life of me I can’t see what I’m doing in this recipe that would cause the tomcat process to not even happen.

I’ve turned the log level to :debug and traced through all the loading of attributes and recipes and can see where it load both the tomcat::default and ome_tomcat::default recipes, but neither executes.

I am stumped as to what I’ve screwed up.

The default recipe for ome_telecom_creditcard uses the LWRP created by ome_tomcat and ome_nginx to deploy the artifact if and when it’s version number changes.

Here is that recipe:

Remove the previous credit-card app

ome_tomcat_application “credit-card.war” do
action :remove

version “2.1.1”

notifies :restart, "service[tomcat7]"
end

Deploy the Telecom credit-card app

ome_tomcat_application “credit-card.war” do

artifact_url “https://tools.ome.ksu.edu/artifactory/ome-telecom-release/telecom/credit-card-webapp/2.1.1/credit-card-webapp-2.1.1.war

version “2.1.1”

artifact_checksum = ‘522726822fcc79e52f4fe0c5240eca9b’

action :deploy
end

Include the OME Nginx wrapper cookbook and override the default_root

attribute

node.default[‘nginx’][‘default_root’] = '/usr/share/nginx/www’
include_recipe ‘ome_nginx::default’

Populate Nginx SSL directory with key and certificate

cookbook_file “www-secure.telecom.cer” do
path "#{node[‘ome_nginx’][‘ssl_directory_path’]}/www-secure.telecom.cer"
owner "www-data"
group "root"
mode "0644"
end

cookbook_file “www-secure.telecom.key” do
path "#{node[‘ome_nginx’][‘ssl_directory_path’]}/www-secure.telecom.key"
owner "www-data"
group "root"
mode "0600"
end

Setup the site configurations with Nginx

ome_nginx_configuration “credit-card.conf” do
action :create
end

ome_nginx_configuration “credit-card-ssl.conf” do
action :create
notifies :restart, 'service[nginx]'
end

Open up the ports required by the application

include_recipe “firewall”

firewall_rule “https” do
port 443
protocol :tcp
action :allow
end

firewall_rule “http” do
port 8080
protocol :tcp
action :allow
end

firewall_rule “http” do
port 80
protocol :tcp
action :allow
end

Any help or ideas will be greatly appreciated.

Thanks
Mark