Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
help with defined() and subclasses
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Christopher McCrory  
View profile  
 More options Oct 26 2011, 4:16 pm
From: Christopher McCrory <chris...@gmail.com>
Date: Wed, 26 Oct 2011 13:16:07 -0700
Local: Wed, Oct 26 2011 4:16 pm
Subject: help with defined() and subclasses
Hello...

Can someone hit me with a clue stick?  I cannot understand why
  if defined(File['/tmp/file-bar']) {
    notify {"DEBUG if defined class $title THIS NEVER WORKS":}
  }
from below does not work.  I'm using 2.6.11 from tmz's repo

$ cat file-test.pp
# vim: set syntax=puppet
#

class create-file {
  file {"/tmp/file-main":
    ensure => exists
  }

}

class file-test {
  #notify {"class $title":}
  include file-test::foo
  include file-test::foo::baz
  include file-test::bar
  include file-test::bar::baz
  #if defined(File['/tmp/file-main']) {
    #notify {"DEBUG if defined class $title":}
  #}

}

class file-test::foo {
  #notify {"class $title":}
  if defined(File['/tmp/file-main']) {
    #notify {"DEBUG if defined class $title":}
  }

}

class file-test::foo::baz inherits file-test::foo {
  notify {"class $title":}
  if defined(File['/tmp/file-bar']) {
    notify {"DEBUG if defined class $title THIS NEVER WORKS":}
  }

}

class file-test::bar {
  notify {"class $title":}
  file {"/tmp/file-bar":
    ensure => exists
  }

}

class file-test::bar::baz inherits file-test::bar {
  notify {"class $title":}
  if defined(File['/tmp/file-main']) {
    notify {"DEBUG if defined class $title THIS DOES WORK":}
  }

}

node default {
 include create-file
 include file-test

}

run results:

$ /bin/rm /tmp/file-bar /tmp/file-main ; puppet  file-test.pp | cat -
warning: Could not retrieve fact fqdn
warning: Host is missing hostname and/or domain: wednesday
notice: DEBUG if defined class file-test::bar::baz THIS DOES WORK
notice: /Stage[main]/File-test::Bar::Baz/Notify[DEBUG if defined class
file-test::bar::baz THIS DOES WORK]/message: defined 'message' as 'DEBUG
if defined class file-test::bar::baz THIS DOES WORK'
notice: class file-test::foo::baz
notice: /Stage[main]/File-test::Foo::Baz/Notify[class
file-test::foo::baz]/message: defined 'message' as 'class
file-test::foo::baz'
notice: /Stage[main]/Create-file/File[/tmp/file-main]/ensure: created
notice: class file-test::bar::baz
notice: /Stage[main]/File-test::Bar::Baz/Notify[class
file-test::bar::baz]/message: defined 'message' as 'class
file-test::bar::baz'
notice: /Stage[main]/File-test::Bar/File[/tmp/file-bar]/ensure: created
notice: class file-test::bar
notice: /Stage[main]/File-test::Bar/Notify[class
file-test::bar]/message: defined 'message' as 'class file-test::bar'
notice: Finished catalog run in 0.06 seconds

--
Christopher McCrory
To the optimist, the glass is half full.
To the pessimist, the glass is half empty.
To the engineer, the glass is twice as big as it needs to be.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »