Amos Shapira
unread,Apr 26, 2012, 3:55:59 AM4/26/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet...@googlegroups.com
Hello,
Like many others, I once again had to deal with creation of deep directory trees with puppet. I did the usual:
file { [ "/a", "/a/b/", "/a/b/c"...]:
ensure => directory
}
And again got sick of it. I still didn't find a good answer for it on the web so here is what I came up with in a moment of despair:
define core::mkdirp($owner = undef, $group = undef) {
exec { "mkdir -p ${name}":
creates => $name,
}
file { $name:
ensure => 'directory',
require => Exec["mkdir -p ${name}"],
owner => $owner,
group => $group,
}
}
Usage:
core::mkdirp { "/a/b/c/d":
owner => $user,
group => $group,
}
file { "/a/b/c/d/file.txt":
require => Core::Mkdirp["/a/b/c/d"],
...
}
So far it works beautifully for me but I want to hear what the community thinks of it and whether there is a nicer solution I'm missing.
Thanks.
--Amos