Here's a snippet from my user management define that shows how I deal with
making a directory that might be many levels deep :
# create the homedir-dir
exec { "mkdir-${username}":
command => "/bin/mkdir -p ${homedirdir} ; /bin/chgrp ${gname}
${homedirdir}",
unless => "/usr/bin/test -d ${homedirdir}",
require => Group[$gname],
}
# create the homedir
file { $userhome :
ensure => directory,
require => [
User[$username],
Exec["mkdir-${username}"],
]
}
Note the "chgrp" command stacked in the command line. It did not want to work gracefully
in the "file" resource.
“Sometimes I think the surest sign that intelligent life exists elsewhere in the
universe is that none of it has tried to contact us.” (Bill Waterson: Calvin &
Hobbes)
On Oct 13, 2015, at 01:20 PM, Ugo Bellavance <[email protected]> wrote:
Hi,
I'd need to create a number of directories in a fasion similar to that:
/var/extlogs/$stage/$client-$application
For example, if stages are integration, staging, production and clients are
client1 and client2 (there are many morem in reality), I'd like to have puppet
create
/var/extlogs/integration/client1-application1
/var/extlogs/integration/client1-application2
/var/extlogs/integration/client2-application1
/var/extlogs/integration/client2-application2
/var/extlogs/staging/client1-application1
/var/extlogs/staging/client1-application2
/var/extlogs/staging/client2-application1
/var/extlogs/staging/client2-application2
/var/extlogs/production/client1-application1
/var/extlogs/production/client1-application2
/var/extlogs/production/client2-application1
/var/extlogs/production/client2-application1
I've created a class that eases the job:
define lsyncd::createdestdirs (
$application = '',
$client = '',
$envstage = '',
) {
file {
'/var/extlogs':
ensure => directory,
owner => "root",
group => "root",
mode => 0755,
}
file {
"/var/extlogs/${envstage}":
ensure => directory,
owner => "root",
group => "root",
mode => 0755,
require => File['/var/extlogs'],
}
file {
"/var/extlogs/${envstage}/${client}-${application}":
ensure => directory,
owner => "root",
group => "root",
mode => 0755,
require => File["/var/www/extlogs/${envstage}"],
}
}
I can simply call something like
lsyncd::createdestdirs { 'client1-application1':
application => 'application1',
client => 'client1',
envstage => 'production',
}
to create one directory, but would there be a way to have all the directories
created in one directive, by setting $application, $client, and $stage in an
array?
I'm currently using puppet 2.7.25 and I'm not using hiera or puppetdb.
Thanks,
Ugo
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/c9182f72-ae82-4a89-95e1-e297dc74aa5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/fdb819b9-979c-49a4-bd62-4544a1a858ae%40me.com.
For more options, visit https://groups.google.com/d/optout.