Christopher McCrory
2011-Oct-26 23:45 UTC
[Puppet Users] solved Re: help with defined() and subclasses
Hello... With help from #puppet I got this to work. changeing this: include file-test::foo include file-test::foo::baz include file-test::bar include file-test::bar::baz to this: include file-test::bar include file-test::bar::baz include file-test::foo include file-test::foo::baz makes everything work. I would think the order of the includes would not matter, but it does. With the original test case it always fails. Changing the order of the include directives and it does work every time. thanks #puppet On Wed, 2011-10-26 at 13:16 -0700, Christopher McCrory wrote:> 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 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.