-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Functions can absolutely be used inside of manifests.

You may be running into an issue in that 'defined' works based on the
compile time order of your manifests.

Example:

class foo { ... }
class bar { ... }

# This does not work as expected

if ! defined(Class["foo"]) { ... }
include "foo"

# This does

include "foo"
if ! defined(Class["foo"]) { ... }

So, I'm guessing that whatever you're trying to do is including that
compile statement in an ordered include that you've already called.

Does that make sense?

Trevor


On 03/18/2010 02:34 PM, Douglas Garstang wrote:
> I have a situation where I am trying to manage some systems that have
> a single IP address but different ssh port numbers. For each of these
> systems I need to individually manage a logrotate.d configuration
> file, and a separate archive directory.
> 
> Of course, this won't work...
> 
> file {
>     "/data/syslog/${remote_host}/archive":
>         ensure => directory;
> 
>     "/etc/logrotate.d/syslogng-host-${remote_host}":
>         content => template("syslog-ng/etc/logrotate.d/server.erb");
> }
> 
> Puppet complains for the first entry that the file is not unique,
> since I am trying to call it multiple times with the same
> $remote_host. If the directory already exists, that's great. How can I
> make puppet skip it in that case? The puppet docs at
> http://docs.reductivelabs.com/references/stable/function.html state
> that there is an "if defined" function, but I've never gotten this to
> work, and the documentation really isn't very clear as to if functions
> are supposed to work inside a manifest.
> 
> I tried this:
> 
>     file {
>         if ! defined(File["/data/syslog/${remote_host}/archive"]) {
>             "/data/syslog/${remote_host}/archive":
>                 ensure => directory;
>         }
>     }
> 
> and this:
> 
>     if ! defined(File["/data/syslog/${remote_host}/archive"]) {
>         file {
>             "/data/syslog/${remote_host}/archive":
>                 ensure => directory;
>         }
>     }
> 
> .... both of which resulted in errors. As I said, the documentation
> really isn't clear if functions CAN be used inside a manifest. That
> has always confused me and I wish someone would clear up the docs.
> 
> For the second entry, I can simply make it unique by suffixing the
> unique ssh port number. That's not an option for the first file
> though.
> 
> Doug
> 

- -- 
Trevor Vaughan
 Vice President, Onyx Point, Inc.
 email: tvaug...@onyxpoint.com
 phone: 410-541-ONYX (6699)

- -- This account not approved for unencrypted sensitive information --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkui3ZQACgkQyWMIJmxwHpRiWACePU0uYMeWCZifmbAD0RITHGiU
jGQAoNZ77e+x7/zEbqAycwtYON3A6CcO
=2O05
-----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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to