$dir = inline_template('<%=ENV["HOME"]%>')
define customizable_file($source=undef,$template=undef,$replacemd5='') {
$tmplname = $template ? {
undef => "$name.common",
default => "$template",
}
file { "$tmplname":
source => $source,
}
exec { "cp $tmplname $name":
onlyif => "test ! -e $name -o \"$(md5sum $name|cut -d' ' -f1)\" = \"$replacemd5\"",
path => ['/bin', '/usr/bin'],
require => File["$tmplname"],
}
}
customizable_file { "$dir/foo-$::hostname":
source => 'file:///etc/motd',
template => "$dir/foo-common",
replacemd5 => 'e43e23c6d9a376bedd1ae405be4fdf97',
}
Idk if i did understand correctly, but there is the replace parameter in the file resource that may help here.
Regards
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/a5a6e496-5853-4a47-a7fb-14ab5f6c1f4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On 24 Apr 2014 18:21, "Matthias Saou" <matt...@saou.eu> wrote:
>
> On Thu, 24 Apr 2014 18:41:05 +0200
> José Luis Ledesma <joseluis...@gmail.com> wrote:
>
> > Idk if i did understand correctly, but there is the replace parameter
> > in the file resource that may help here.
>
> I think you've missed the important bit, like I did initially : The
> "replace" parameter set to false will have puppet *never* touch the
> file once it's created. What the OP wants it to have puppet keep
> updating the file *until it's modified locally*, at which point it
> should stop.
>
> Tricky. I can't think of any simple and clean solution from the top of
> my head, though I do understand why one would want to do that... I
> could actually use that behaviour for the initial ~/.gitconfig files I
> create for system users, for example.
For files in user's home directories I would manage the skeleton files using puppet and then when the user account is created they'll be copied into their home directory. That obviously only works for new users though. It won't account for existing users or for updating the file if it hasn't been touched by the user yet.
It's perhaps a little painful but could you put a comment marker in each file you manage and then have a custom fact that checks for that marker? That is then used to determine whether the File resource is managed or not. Users would have to be told (probably in that same comment marker) that any changes to the file will be undone unless they remove the comment.
Matt
Indeed i missed it. Perhaps you can have some custom fact that returns the md5 of the files, so you can detect if it matches the replacemd5. Probably will make the manifest simpler.
Regards,
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/20140424192135.33eb26e7%40r2d2.marmotte.net.
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/a5a6e496-5853-4a47-a7fb-14ab5f6c1f4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
For files in user's home directories I would manage the skeleton files using puppet and then when the user account is created they'll be copied into their home directory. That obviously only works for new users though. It won't account for existing users or for updating the file if it hasn't been touched by the user yet.
$dir = inline_template('<%=ENV["HOME"]%>') # again, just to make testing using puppet apply easier
file { "$dir/foo":
source => ["file://$dir/foo.local", 'file:///etc/motd'] # the latter would typically be a puppet:/// URL
}
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/208cbf21-c3e8-45fe-99ee-5b4ab7e598fe%40googlegroups.com.