Hi Garrett,

 That's great. And that explanation makes perfect sense! I understand this
a little better now. And using the example you provided works.

Thanks,
Tim

On Wed, Dec 23, 2015 at 5:52 PM, Garrett Honeycutt <g...@garretthoneycutt.com>
wrote:

> On 12/23/15 4:14 PM, Tim Dunphy wrote:
> > Hello,
> >
> >  How can I require two different types in my manifests? For instance I
> > have this setup in one of my modules:
> >
> > file { "/etc/pki/tls/private/${::hostname}.example.com.key":
> >       owner => "bacula",
> >       group => "bacula",
> >       mode => 0400,
> >       require => Package["bacula-client","bacula-common"],
> >       require => File["/etc/pki/tls/private","/etc/pki/tls/certs"],
> >       source =>
> > "puppet:///modules/bacula/${::hostname}/${::hostname}.example.com.key",
> >       notify  => Service["bacula-fd"]
> >      }
> >
> > And I want to require both Packages and directories provided by File.
> > But when I try that I get this:
> >
> > Error: Could not retrieve catalog from remote server: Error 400 on
> > SERVER: Duplicate parameter 'require' for on
> > File[/etc/pki/tls/private/ldap1.example.com.key] at
> >
> /etc/puppet/environments/production/modules/bacula/manifests/config.pp:43 on
> > node ldap1.example.com <http://ldap1.example.com>
> > Warning: Not using cache on failed catalog
> > Error: Could not retrieve catalog; skipping run
> >
> > How do I require both Files and Packages in such a way as to be
> > acceptable to puppet?
> >
> > Thanks,
> > Tim
> >
>
> Hi Tim,
>
> The key is to use an array.
>
> Such as
>
> file { "/etc/pki/tls/private/${::hostname}.example.com.key":
>   source  =>
> "puppet:///modules/bacula/${::hostname}/${::hostname}.example.com.key",
>   owner   => 'bacula',
>   group   => 'bacula',
>   mode    => '0400',
>   require => [
>     Package['bacula-client','bacula-common'],
>     File['/etc/pki/tls/private'],
>     File['/etc/pki/tls/certs'],
>   ],
>   notify  => Service['bacula-fd'],
> }
>
> Since the filesystem is hierarchical in nature, file resources are
> implicitly ordered. So if you have a file resource for
> '/etc/pki/tls/private' it is automatically done before this file
> resource and should not be explicitly required.
>
> Note that this is not same functionality as `mkdir -p`. So if
> '/etc/pki/tls' did not exist, the resource for '/etc/pki/tls/private'
> would fail and so would this file resource for the key.
>
> You would correctly write your resource as follows.
>
> file { "/etc/pki/tls/private/${::hostname}.example.com.key":
>   source  =>
> "puppet:///modules/bacula/${::hostname}/${::hostname}.example.com.key",
>   owner   => 'bacula',
>   group   => 'bacula',
>   mode    => '0400',
>   require => [
>     Package['bacula-client','bacula-common'],
>     File['/etc/pki/tls/certs'],
>   ],
>   notify  => Service['bacula-fd'],
> }
>
> Even when requiring multiple resources of the same type, the above
> format is the way to go.
>
> Here's a link to make viewing the code a bit nicer.
>
> http://pastebin.com/NpbJT86J
>
> Best regards,
> -g
>
> --
> Garrett Honeycutt
> @learnpuppet
> Puppet Training with LearnPuppet.com
> Mobile: +1.206.414.8658
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/567B25A8.4020806%40garretthoneycutt.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAOZy0enoGeWL5UZ2GoxnmAWjf6qbNMLT2WL4XBfxtu8TYWuhXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to