On Sun, Nov 8, 2009 at 1:12 AM, Douglas Garstang
<doug.garst...@gmail.com> wrote:

> I need to both make sure that the base directory exists AND the
> symlink to it exists. Other than defining a file resource that ensures
> the base directory exists and another file resource to create the
> symlink, how else could this be done?

My use case is slightly different from yours, but what I do is use
virtual resources to get around duplicate definition errors.  One of
my defines looks like this. In the class resin::files and
sites::files, I have hardcoded every possible site and environment
that could be passed in (you'll know you forgot this part if on a
puppet run you get "Failed to realize virtual resource blah").  This
is far from ideal, and I'm open to ways to do this that wouldn't
require me to do that :).

The actual use case is that for each site (which is a distinct
website), there are multiple JVM's that make various components of
that site (env_alias, which is really misnamed),  We can also
vertically scale JVM's on the same machine, in different runtime
directories (the instance variable).  For example, we can have
/apps/runtime/site_A/main/resin/host1_main_1,
/apps/runtime/site_A/main/resin/host1_main_2, and
/apps/runtime/site_A/jive/resin/host1_jive_1 all on the same host.
These are completely unrelated (to puppet) other than the fact that
they're all resin instances running on the same box.

So for each one, I need to make sure that /apps/runtime/site_A,
/apps/runtime/site_A/[main, jive], and /apps/runtime/site_A/[main,
jive]/resin all exist (/apps and /apps/runtime are taken care of in
resin::base. which as you see is included). All of that is handled via
virtual resources, defined in sites::files and resin::files like so:

class resin::files {
   @file { "/apps/runtime/gq/main/resin":
      owner => cnp,
      group => cnp-admin,
      mode => 0755,
      require => File["/apps/runtime/gq/main"],
      ensure => directory;
<much snipped.....>

And here's the complete define resin::instance.

define resin::instance(
  $site_alias,
   $env_alias,
   $instance ="1",
   $host_alias,
   $resin_ver,
   $java_ver,
   $watchdog_port = "6700"
) {
   include resin::base
   include resin::files
   include "resin::${resin_ver}"
   include sites::files
   include "java::${java_ver}"
   $instance_name="${host_alias}_${env_alias}_${instance}"
   $runtime_dir =
"/apps/runtime/$site_alias/$env_alias/resin/${host_alias}_${env_alias}_${instance}"
   file { 
"/apps/runtime/$site_alias/$env_alias/resin/${host_alias}_${env_alias}_${instance}":
      owner => cnp,
      group => cnp-admin,
      #mode => 0755,
      require => File["/apps/runtime/$site_alias/$env_alias"],
      source => "/media/CNT/common/puppet/resin3-runtime",
      recurse => true,
      ignore => ".svn",
      replace => no;
   
"/apps/runtime/$site_alias/$env_alias/resin/${host_alias}_${env_alias}_${instance}/conf":
      owner => cnp,
      group => cnp-admin,
      require =>
File["/apps/runtime/$site_alias/$env_alias/resin/${host_alias}_${env_alias}_${instance}"],
      ensure => "/media/CNT/$site_alias/apps/$site_alias/$env_alias/resin/conf";
   }
   # no class names are allowed with dots, so do a lame workaround
   case $resin_ver {
      "resin318": { $real_resin_ver = "resin-pro-3.1.8" }
      "resin316": { $real_resin_ver = "resin-pro-3.1.6" }
   }
   case $java_ver {
      "java1607": { $real_java_ver = "jdk1.6.0_07" }
   }

   file { 
"/apps/runtime/$site_alias/$env_alias/resin/${host_alias}_${env_alias}_${instance}/bin/setenv.sh":
      owner => cnp,
      group => cnp-admin,
      require =>
File["/apps/runtime/$site_alias/$env_alias/resin/${host_alias}_${env_alias}_${instance}"],
      mode => 0755,
      content => template("resin/setenv.sh.erb");
   }

   # these two are defined in sites::files
   realize File["/apps/runtime/$site_alias"]
   realize File["/apps/runtime/$site_alias/$env_alias"]
   # this is defined in resin::files above
   realize File["/apps/runtime/$site_alias/$env_alias/resin"]
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to