- From: Hedge Hog <
>
- To:
- Subject: [chef] Re: how to manage dependent resources?
- Date: Wed, 29 Feb 2012 20:05:03 +1100
- Authentication-results: mr.google.com; spf=pass (google.com: domain of
designates 10.52.21.168 as permitted sender)
; dkim=pass
On Wed, Feb 29, 2012 at 7:53 PM, Bryan Berry
<
>
wrote:
>
I have an issue where I need to provide values generated dynamically by one
>
resource to resources that follow it
>
>
My tomcat lwrp generates a base directory for each new instance that is a
>
readable attribute "base"
>
>
Following resources will use that base attribute. In this example, the ivy
>
resource should place a .jar file in the #{base}/lib directory
If you are on a system that provides upstart, then I think you'll find
upstart will scratch that itch most effectively[0].
Of course this assumes that each of the current resources can be
expressed as a task or service.
I generally use Chef to tweak a generic upstart conf template, and use
the emit/emits/start on/stop on to look after chaining and sequencing.
If you go down this path you might have to pay attention to upstart
synchronisation[1].
HTH
[0]
http://upstart.ubuntu.com/cookbook/#run-a-job-when-a-file-or-directory-is-created-deleted
[1]
http://upstart.ubuntu.com/cookbook/#synchronisation
>
>
>
include_recipe "ark"
>
>
include_recipe "tomcat::base"
>
>
include_recipe "ivy"
>
>
>
>
t = tomcat "jira" do
>
>
user node['jira']['user']
>
>
action :install
>
>
end
>
>
>
>
>
# get mysql connector
>
>
ivy "mysql-connector-java" do
>
>
groupId "mysql"
>
>
version "5.1.18"
>
>
dest "#{t.base}/lib" # evaluates to "/lib"
>
>
>
end
>
>
>
>
ruby_block "foobarbaz" do
>
>
block do
>
>
Chef::Log.debug("t.base is #{t.base}") # t.base evaluates to
>
"/usr/local/tomcat/jira"
>
>
end
>
>
end
>
>
>
I have found a solution thanks to Jorge Espada, but there really should be a
>
more straightforward way to do this.
>
>
t = tomcat "jira" do
>
>
user node['jira']['user']
>
>
action :nothing
>
>
end
>
>
t.run_action :install
--
πόλλ' οἶδ ἀλώπηξ, ἀλλ' ἐχῖνος ἓν μέγα
[The fox knows many things, but the hedgehog knows one big thing.]
Archilochus, Greek poet (c. 680 BC – c. 645 BC)
http://hedgehogshiatus.com
Archive powered by MHonArc 2.6.16.