Marc Haber
2012-Sep-28 15:01 UTC
[Puppet Users] How to create a directory if that path does not yet exist?
Hi, I have the following resource defined: file { "/var/lib/foo": ensure => directory, owner => root, group => root, mode => 0755, } On some systems, but not on all, I have /var/lib/foo symlinked to another partition with more space. Those symlinks (/var/lib/foo => /space/foo) are replaced during the puppet run with a local directory. Neither the force nor the replace parameter to the File resource seems to stop this behavior. Is there anyway to obtain this behavior short of using an exec? Greetings Marc -- ----------------------------------------------------------------------------- Marc Haber | "I don''t trust Computers. They | Mailadresse im Header Mannheim, Germany | lose things." Winona Ryder | Fon: *49 621 31958061 Nordisch by Nature | How to make an American Quilt | Fax: *49 621 31958062 -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Thomas Linkin
2012-Oct-01 20:11 UTC
Re: [Puppet Users] How to create a directory if that path does not yet exist?
Marc, There is no way in the resource declaration for ''file'' to stop it from ensuring your symlink is made into a directory. That is because this is the state you''re asking to have ensured when you compile that resource into a catalog. What you may want to do is find a way to have the resource either ensure a symlink for those hosts or not be in your catalog. I recommend the finding a way to have it ensure a symlink. You could probably do this most easily by wrapping it in a conditional that responds to a top-level variable (either from your ENC or in your node definition). If you are using hiera, perhaps you can keep the variable there. Another option, could be to create a custom fact that detects when you''ve created a symlink. However, this method does not really capture the fact that you''ve done the symlink anywhere except on the host. Were this host to fail in an unrecoverable manner, or even just be rebuilt by someone who is not you, this detail may be missed. -- Tom Linkin Professional Services Engineer http://puppetlabs.com/ twitter: @trlinkin On Friday, September 28, 2012 at 11:01 AM, Marc Haber wrote:> Hi, > > I have the following resource defined: > > file { "/var/lib/foo": > ensure => directory, > owner => root, > group => root, > mode => 0755, > } > > On some systems, but not on all, I have /var/lib/foo symlinked to > another partition with more space. Those symlinks (/var/lib/foo => > /space/foo) are replaced during the puppet run with a local directory. > > Neither the force nor the replace parameter to the File resource seems > to stop this behavior. > > Is there anyway to obtain this behavior short of using an exec? > > Greetings > Marc > > -- > ----------------------------------------------------------------------------- > Marc Haber | "I don''t trust Computers. They | Mailadresse im Header > Mannheim, Germany | lose things." Winona Ryder | Fon: *49 621 31958061 > Nordisch by Nature | How to make an American Quilt | Fax: *49 621 31958062 > > -- > 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 (mailto:puppet-users@googlegroups.com). > To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com (mailto:puppet-users+unsubscribe@googlegroups.com). > For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en. > >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Marc Haber
2012-Oct-03 12:22 UTC
Re: [Puppet Users] How to create a directory if that path does not yet exist?
On Mon, Oct 01, 2012 at 04:11:06PM -0400, Thomas Linkin wrote:> There is no way in the resource declaration for ''file'' to stop it from > ensuring your symlink is made into a directory. That is because this > is the state you''re asking to have ensured when you compile that > resource into a catalog. What you may want to do is find a way to have > the resource either ensure a symlink for those hosts or not be in your > catalog. I recommend the finding a way to have it ensure a symlink.Thanks for the explanation. I''m going to use an exec. Ugly, but it will be easier to understand than the other options you mentioned. Greetings Marc -- ----------------------------------------------------------------------------- Marc Haber | "I don''t trust Computers. They | Mailadresse im Header Mannheim, Germany | lose things." Winona Ryder | Fon: *49 621 31958061 Nordisch by Nature | How to make an American Quilt | Fax: *49 621 31958062 -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.