danielt
2012-Oct-25 20:33 UTC
[Puppet Users] creating a list of files from an external define
Hi! I have a helper module called helper with a define which looks like this: define helper::files ($path='''', $requires='''', $owner=root, $group=root, $mode=644, $ensure=present) { file { "${name}": ensure => $ensure, owner => $owner, group => $group, mode => $mode, source => "${path}", require => $requires, } } I have a bunch of files I want to be copied within my Apache2 Module: $files = [ "/var/www/favicon.ico", "/var/www/error/error.html", "/var/www/error/logo.jpg", "/etc/apache2/ssl/ca.crt", "/etc/apache2/conf.d/charset", "/etc/apache2/conf.d/security", ] When I call the define from within my apache2 class with this: helper::files{$files: owner => root, group => root, mode => 644, path => "puppet:///files/apache2/", ensure => present, requires => File[$folders] } I get the following error: err: /Stage[main]/Apache2/Helper::Files[/etc/apache2/conf.d/security]/File[/etc/apache2/conf.d/security]: Could not evaluate: Could not retrieve information from source(s) puppet:///files/apache2 at /etc/puppet/env/production/modules/helper/manifests/files.pp:9 for every file in my list. I am running Puppet 3.0.1 and have the workaround from https://groups.google.com/forum/?fromgroups=#!starred/puppet-users/eQpr0-zd3dM runing. Anybody an idea how I can get my solution to work? Is it a good idea to do this so? I usually had the install define within the class. But puppet-lint didn''t like this so I thought outsourcing it to its own module would work out. Obviously it doesn''t. I am looking forward to your responses. Daniel -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/JksunZeBsGcJ. 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.
jcbollinger
2012-Oct-26 16:23 UTC
[Puppet Users] Re: creating a list of files from an external define
On Thursday, October 25, 2012 3:33:16 PM UTC-5, danielt wrote: Puppet expects to find a definition with this name:> helper::files{ >in this file: [...] modules/helper/manifests/files.pp> >> [...] I usually had the install define within the class. But puppet-lint > didn''t like this so I thought outsourcing it to its own module would work > out. >I''m not sure what you mean about putting the define in its own module, but doing so (correctly) without changing its name would have put it exactly where Puppet was looking for it. Some people try to use "module" as a synonym for "file", but Puppet "modules" are structured collections of files containing class, resource, and data definitions, and arranged according to a standard directory structure. The definition doesn''t need to be in its own module, but it should be in its own *file* within the module (which is what puppet-lint was telling you), and it should identify itself by its fully-qualified name. Anyone outside the module must reference it by that fully-qualified name. Classes and resources in the same module ought to be able to reference it by its name relative to the module, but they *should* reference it by its fully-qualified name, too. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/nDpeoYEXupkJ. 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.
danielt
2012-Oct-28 13:23 UTC
[Puppet Users] Re: creating a list of files from an external define
> > The definition doesn''t need to be in its own module, but it should be in > its own *file* within the module (which is what puppet-lint was telling > you), >I know but having a definition which just copys files in a global name space would immensely reduce the amount of code duplication. I actually do not want to have the files definition in every module, I rather want to have my helper module which does that for me. I hope you understood my intension of doing that. Dan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/8CEJGiZpEbwJ. 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.
Henrik Lindberg
2012-Oct-29 03:12 UTC
Re: [Puppet Users] creating a list of files from an external define
On 2012-25-10 22:33, danielt wrote:> When I call the define from within my apache2 class with this: > > helper::files{$files: > owner => root, > group => root, > mode => 644, > path => "puppet:///files/apache2/", > ensure => present, > requires => File[$folders] > } >Irrespective of other issues, you probably want to use the octal 0644 for mode. You currently have a decimal value 644 that corresponds to 01204 (octal) which is a quite different mode. - henrik -- 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.
jcbollinger
2012-Oct-29 14:22 UTC
[Puppet Users] Re: creating a list of files from an external define
On Sunday, October 28, 2012 8:23:30 AM UTC-5, danielt wrote:> > The definition doesn''t need to be in its own module, but it should be in >> its own *file* within the module (which is what puppet-lint was telling >> you), >> > > I know but having a definition which just copys files in a global name > space would immensely reduce the amount of code duplication. I actually do > not want to have the files definition in every module, I rather want to > have my helper module which does that for me. > > I hope you understood my intension of doing that. > >That''s not relevant to my answer. Nevertheless, inasmuch as there is nothing special about defined types relative to built-in resources when it comes to arrays as resource titles, I''m not sure I agree that there is an immense amount of code duplication to be saved. How is using an intermediary definition better than just writing this: file { ${files}: ensure => present, owner => root, group => root, mode => 0644, source => ''puppet:///files/apache2/'', require => File[$folders], } Note 1: "ensure => present" is likely not what you really want, but that''s what your definition does. Note 2: you might well not need that ''require'' parameter, as Puppet will autorequire the parent directory of any managed file if the parent is itself managed. Note 3: if it''s the owner / group / mode that you don''t want to duplicate, then you might want to consider the advantages of being explicit about what you want. If you still want to avoid expressing those explicitly (and how many places are we talking about, really?) then you could consider setting global defaults for those parameters: site.pp ----------- # ... File { owner => root, group => root, mode => 0644 } # ... John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/Z6s-TnS-UDMJ. 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.