I don't know if that would work or not, but it turns out I was over
complicating things. All I needed to do was this:

    file {
        smbshares:
            path => "/etc/samba/shares.conf",
            source => [
                "puppet:///samba/shares/$hostname.conf",
                "puppet:///samba/shares/default.conf",
            ];
    }

As Thomas Bellman pointed out the file type already supports this. If you
specify multiple file sources for a file then the first source that exists
will be used.

On Thu, Nov 20, 2008 at 3:14 AM, Henry Jenkins <[EMAIL PROTECTED]>wrote:

>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Robert,
>
> I'm only new to puppet so I'm not sure if this is what you are after but
> would the folowing work?
>
>    file {
>        smbshares:
>            path => "/etc/samba/shares.conf",
>            source => $hostname ? {
>                nodename1 => ["puppet:///samba/shares/nodename1.conf",
> "puppet:///samba/shares/default.conf"],
>                 nodename2 => ["puppet:///samba/shares/nodename2.conf",
> "puppet:///samba/shares/default.conf"],
>                 default => "puppet:///samba/shares/default.conf",
>            };
>      }
>
> This way it would check for the file called nodename1.conf then failing
> that it would look for the default.
>
> Cheers,
>
> Henry
>
>
>
> Robert Foreman wrote:
> > I was wondering if it is possible to do a conditional inside a selector
> to test for the existence of a file.
> >
> > I currently have something like this (just an excerpt):
> >
> >     file {
> >         smbshares:
> >             path => "/etc/samba/shares.conf",
> >             source => $hostname ? {
> >                 nodename1 => "puppet:///samba/shares/nodename1.conf",
> >                 nodename2 => "puppet:///samba/shares/nodename2.conf",
> >                 default => "puppet:///samba/shares/default.conf",
> >             };
> >       }
> >
> > The smb.conf does an include on /etc/samba/shares.conf so in order to
> add or create custom shares I drop a file in modules/samba/files/shares
> named after the hostname of the target machine and then place the
> corresonding line in the file block above. It works pretty well, but
> since the file is named after the hostname I was thinking it would be
> pretty slick if that part were a little more dynamic.
> >
> > Logically speaking it would look something like this:
> >
> >             source => $hostname ? {
> >                 [ -f puppet:///samba/shares/$hostname.conf ] =>
> "puppet:///samba/shares/$hostname.conf",
> >                 default => "puppet:///samba/shares/default.conf",
> >             };
> >
> > I just can't quite seem to come up with what the syntax would need to
> look. The shell syntax above is just to convey the logic I'm looking for.
> >
> > Any ideas, or is there a better way to do this?
> >
> > Thanks.
> >
> >
> >
> > >
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkklHGQACgkQ9EJQnSAhy1AEoACePEs2hSThFwEueT+tiPc/eU5I
> vI8AnAp8WfYO+XURwHfs0rQU2DvQRB/p
> =b+ea
> -----END PGP SIGNATURE-----
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to