Re-opening resources at run-time


#1

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

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?


#2

On Mar 4, 2012, at 6:29 AM, Bryan Berry wrote:

run_time “tomcat[jira]” do

subscribes :restart, resources(templates => [‘jdbc configuration’, ‘jira properties’] ), :immediately

action :start

end

Can you just use notifies for those templates?

Like:

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

notifies :restart, “tomcat[jira]”, :immediately

owner jira_user

end


#3

I can’t because I have to have all of those templates in place before
starting tomcat for the first time

On Sun, Mar 4, 2012 at 6:24 PM, Brian Akins brian@akins.org wrote:

On Mar 4, 2012, at 6:29 AM, Bryan Berry wrote:

run_time “tomcat[jira]” do

subscribes :restart, resources(templates => [‘jdbc configuration’,
‘jira properties’] ), :immediately

action :start

end

Can you just use notifies for those templates?

Like:

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

notifies :restart, “tomcat[jira]”, :immediately

owner jira_user

end


#4

one option is to create a new lwrp tomcat_svc that would do something
similar

tomcat_svc “jira” do
subscribes :restart, (resources => [ template1, template2, templaten ]
action :start
end

this lwrp would require the original tomcat lwrp to keep a list of config
resources it creates. then the tomcat_svc interrogates the tomcat resource
for its config files and subscribes to them.

this blog post has thrown me for a loop and making me rethink everything
http://blog.nistu.de/2012/03/04/reusability-in-configuration-management-systems/

On Sun, Mar 4, 2012 at 6:27 PM, Bryan Berry bryan.berry@gmail.com wrote:

I can’t because I have to have all of those templates in place before
starting tomcat for the first time

On Sun, Mar 4, 2012 at 6:24 PM, Brian Akins brian@akins.org wrote:

On Mar 4, 2012, at 6:29 AM, Bryan Berry wrote:

run_time “tomcat[jira]” do

subscribes :restart, resources(templates => [‘jdbc configuration’,
‘jira properties’] ), :immediately

action :start

end

Can you just use notifies for those templates?

Like:

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

notifies :restart, “tomcat[jira]”, :immediately

owner jira_user

end


#5

r = resouces(:template, “jira”)
r.whatever(new stuff)

Adam

On Sun, Mar 4, 2012 at 11:51 AM, Bryan Berry bryan.berry@gmail.com wrote:

one option is to create a new lwrp tomcat_svc that would do something
similar

tomcat_svc “jira” do
subscribes :restart, (resources => [ template1, template2, templaten ]
action :start
end

this lwrp would require the original tomcat lwrp to keep a list of config
resources it creates. then the tomcat_svc interrogates the tomcat resource
for its config files and subscribes to them.

this blog post has thrown me for a loop and making me rethink everything
http://blog.nistu.de/2012/03/04/reusability-in-configuration-management-systems/

On Sun, Mar 4, 2012 at 6:27 PM, Bryan Berry bryan.berry@gmail.com wrote:

I can’t because I have to have all of those templates in place before
starting tomcat for the first time

On Sun, Mar 4, 2012 at 6:24 PM, Brian Akins brian@akins.org wrote:

On Mar 4, 2012, at 6:29 AM, Bryan Berry wrote:

run_time “tomcat[jira]” do

subscribes :restart, resources(templates => [‘jdbc configuration’,
‘jira properties’] ), :immediately

action :start

end

Can you just use notifies for those templates?

Like:

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

notifies :restart, “tomcat[jira]”, :immediately

owner jira_user

end


Opscode, Inc.
Adam Jacob, Chief Customer Officer
T: (206) 619-7151 E: adam@opscode.com


#6

and I have to wrap that in a ruby_block, which isn’t very readable and
confusing imho. I think we need a better wrapper, thus the

run_time resource

On Mon, Mar 5, 2012 at 8:23 PM, Adam Jacob adam@opscode.com wrote:

r = resouces(:template, “jira”)
r.whatever(new stuff)

Adam

On Sun, Mar 4, 2012 at 11:51 AM, Bryan Berry bryan.berry@gmail.com
wrote:

one option is to create a new lwrp tomcat_svc that would do something
similar

tomcat_svc “jira” do
subscribes :restart, (resources => [ template1, template2, templaten ]
action :start
end

this lwrp would require the original tomcat lwrp to keep a list of config
resources it creates. then the tomcat_svc interrogates the tomcat
resource
for its config files and subscribes to them.

this blog post has thrown me for a loop and making me rethink everything

http://blog.nistu.de/2012/03/04/reusability-in-configuration-management-systems/

On Sun, Mar 4, 2012 at 6:27 PM, Bryan Berry bryan.berry@gmail.com
wrote:

I can’t because I have to have all of those templates in place before
starting tomcat for the first time

On Sun, Mar 4, 2012 at 6:24 PM, Brian Akins brian@akins.org wrote:

On Mar 4, 2012, at 6:29 AM, Bryan Berry wrote:

run_time “tomcat[jira]” do

subscribes :restart, resources(templates => [‘jdbc configuration’,
‘jira properties’] ), :immediately

action :start

end

Can you just use notifies for those templates?

Like:

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

notifies :restart, “tomcat[jira]”, :immediately

owner jira_user

end


Opscode, Inc.
Adam Jacob, Chief Customer Officer
T: (206) 619-7151 E: adam@opscode.com


#7

You only have to wrap it in a ruby_block if you want it to happen at
run time instead of compile time.

Adam

On Mon, Mar 5, 2012 at 12:40 PM, Bryan Berry bryan.berry@gmail.com wrote:

and I have to wrap that in a ruby_block, which isn’t very readable and
confusing imho. I think we need a better wrapper, thus the

run_time resource

On Mon, Mar 5, 2012 at 8:23 PM, Adam Jacob adam@opscode.com wrote:

r = resouces(:template, “jira”)
r.whatever(new stuff)

Adam

On Sun, Mar 4, 2012 at 11:51 AM, Bryan Berry bryan.berry@gmail.com
wrote:

one option is to create a new lwrp tomcat_svc that would do something
similar

tomcat_svc “jira” do
subscribes :restart, (resources => [ template1, template2, templaten
]
action :start
end

this lwrp would require the original tomcat lwrp to keep a list of
config
resources it creates. then the tomcat_svc interrogates the tomcat
resource
for its config files and subscribes to them.

this blog post has thrown me for a loop and making me rethink everything

http://blog.nistu.de/2012/03/04/reusability-in-configuration-management-systems/

On Sun, Mar 4, 2012 at 6:27 PM, Bryan Berry bryan.berry@gmail.com
wrote:

I can’t because I have to have all of those templates in place before
starting tomcat for the first time

On Sun, Mar 4, 2012 at 6:24 PM, Brian Akins brian@akins.org wrote:

On Mar 4, 2012, at 6:29 AM, Bryan Berry wrote:

run_time “tomcat[jira]” do

subscribes :restart, resources(templates => [‘jdbc
configuration’,
‘jira properties’] ), :immediately

action :start

end

Can you just use notifies for those templates?

Like:

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

notifies :restart, “tomcat[jira]”, :immediately

owner jira_user

end


Opscode, Inc.
Adam Jacob, Chief Customer Officer
T: (206) 619-7151 E: adam@opscode.com


Opscode, Inc.
Adam Jacob, Chief Customer Officer
T: (206) 619-7151 E: adam@opscode.com


#8

You only have to wrap it in a ruby_block if you want it to happen at
run time instead of compile time.

Adam

On Mon, Mar 5, 2012 at 12:40 PM, Bryan Berry bryan.berry@gmail.com wrote:

and I have to wrap that in a ruby_block, which isn’t very readable and
confusing imho. I think we need a better wrapper, thus the

run_time resource

On Mon, Mar 5, 2012 at 8:23 PM, Adam Jacob adam@opscode.com wrote:

r = resouces(:template, “jira”)
r.whatever(new stuff)

Adam

On Sun, Mar 4, 2012 at 11:51 AM, Bryan Berry bryan.berry@gmail.com
wrote:

one option is to create a new lwrp tomcat_svc that would do something
similar

tomcat_svc “jira” do
subscribes :restart, (resources => [ template1, template2, templaten
]
action :start
end

this lwrp would require the original tomcat lwrp to keep a list of
config
resources it creates. then the tomcat_svc interrogates the tomcat
resource
for its config files and subscribes to them.

this blog post has thrown me for a loop and making me rethink everything

http://blog.nistu.de/2012/03/04/reusability-in-configuration-management-systems/

On Sun, Mar 4, 2012 at 6:27 PM, Bryan Berry bryan.berry@gmail.com
wrote:

I can’t because I have to have all of those templates in place before
starting tomcat for the first time

On Sun, Mar 4, 2012 at 6:24 PM, Brian Akins brian@akins.org wrote:

On Mar 4, 2012, at 6:29 AM, Bryan Berry wrote:

run_time “tomcat[jira]” do

subscribes :restart, resources(templates => [‘jdbc
configuration’,
‘jira properties’] ), :immediately

action :start

end

Can you just use notifies for those templates?

Like:

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

notifies :restart, “tomcat[jira]”, :immediately

owner jira_user

end


Opscode, Inc.
Adam Jacob, Chief Customer Officer
T: (206) 619-7151 E: adam@opscode.com


Opscode, Inc.
Adam Jacob, Chief Customer Officer
T: (206) 619-7151 E: adam@opscode.com