[chef] re-opening resources at run-time


Chronological Thread 
  • From: Bryan Berry < >
  • To:
  • Subject: [chef] re-opening resources at run-time
  • Date: Sun, 4 Mar 2012 12:29:50 +0100
  • Authentication-results: mr.google.com; spf=pass (google.com: domain of designates 10.52.88.235 as permitted sender) ; dkim=pass

Working on my new jira cookbook I have encountered the need to re-open a resource during run-time

https://github.com/bryanwb/cookbooks/blob/master/jira/recipes/default.rb

Here is what i want to do

# define a tomcat instance using my lwrp

tomcat "jira" do
  user jira_user
  action :install
  jvm_opts node['jira']['jvm_opts']
end

# define key template files

file "jira properties" do  path "#{t.base}/webapps/jira/WEB-INF/classes/jira-application.properties"  content <<-EOS
# generated by Chef, don't touch!
jira.home = /home/jira
EOS
  owner jira_user
end

template "jdbc configuration" do
  path "/home/jira/dbconfig.xml"
  source "dbconfig.xml.erb"
  owner jira_user
end

# then reopen the tomcat resource at run_time to subscribe to the template files and start it
# here is my wacky idea on how to do it w/ the fictitious run_time resource
run_time "tomcat[jira]" do
subscribes :restart, resources(templates => ['jdbc configuration', 'jira properties'] ), :immediately
action :start
end

I believe that I could accomplish most of the above w/ a ruby_block but frankly that's pretty ugly. There must be a better way. I would really love to use something like a run_time resource that allows me to re-open a resource much like on can extend a ruby object, however I want it to happen at run_time and not compile-time. thoughts?



Archive powered by MHonArc 2.6.16.

§