---------- Forwarded message ----------
From: Sans <r.santanu....@gmail.com>
Date: Thu, Aug 18, 2011 at 4:49 AM
Subject: [Puppet Users] how to create directory recursively (if parents not
present)?
To: Puppet Users <puppet-users@googlegroups.com>


Dear all,

As said in the subject line, is there a "nice" way of creating
directory tree if parent is not already there, like using "mkdir -p"?
I tried this:

class install_certs {

   $cert_dir = 'globus/cert'

   exec {
       'create_cert':
       command     => "/bin/mkdir -p /opt/$cert_dir",
       refreshonly => true,
   }

   file {
       "${hostname}-cert.pem":
       name    => "/opt/$cert_dir/${hostname}-cert.pem",
       mode    => '0444', owner => 'root', group => 'root',
       source  => "puppet:///modules/p_nodes/${hostname}-cert.pem";
   }
}

which is not working at all. Any suggestion from anyone? Cheers!!




--
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.



The following will do what you want:

file { ['/opt', '/opt/globus', '/opt/globus/cert']:
   ensure => directory,
}

Because of the implicit dependencies that exist between directories and
their parents that are managed by puppet, you do not need to specify any
ordering - puppet will set it up for you.

You can write a defined resource type to do this for you if you'd like, or
you can use the Ruby DSL to create a mkdir_p function.





-- 

Gary Larizza
Professional Services Engineer
Puppet Labs

Join us for PuppetConf <http://bit.ly/puppetconfsig>, September 22nd and
23rd in Portland, OR!

-- 
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