I''m having trouble getting puppet to work when using a conditional to check whether or not a subclass is defined. Here is what I''ve tried to do if ! defined (Class[server::cobbler]) { # do something } With the above statement I get this error: err: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at ''server::cobbler''; expected '']'' at ... So I tried quoting the class: if ! defined (Class["server::cobbler"]) { # do something } This doesn''t error out, but it doesn''t do what I''m asking which is to only run the section of code when the subclass server::cobbler is not defined. Any ideas? -- 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.
I believe there is a bug, but I can''t find it to reference it now. Try this: if ! defined("server::cobler") { # do something } On Sep 2, 5:07 pm, "Steven L. Seed" <slseed1...@gmail.com> wrote:> I''m having trouble getting puppet to work when using a conditional to > check whether or not a subclass is defined. > > Here is what I''ve tried to do > > if ! defined (Class[server::cobbler]) { > # do something > > } > > With the above statement I get this error: > > err: Could not retrieve catalog from remote server: Error 400 on SERVER: > Syntax error at ''server::cobbler''; expected '']'' at ... > > So I tried quoting the class: > if ! defined (Class["server::cobbler"]) { > # do something > > } > > This doesn''t error out, but it doesn''t do what I''m asking which is to > only run the section of code when the subclass server::cobbler is not > defined. > > Any ideas?-- 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.
Steven L. Seed
2010-Sep-03 22:07 UTC
Re: [Puppet Users] Re: Using defined(Class[]) on a subclass
This doesn''t work. It appears that puppet is looking to see if the value is defined anywhere at all in the manifest when called this way. Since I have defined a class "server::cobbler" it skips over the code even though the node I''m running it on doesn''t have the class defined for it. John Lyman wrote:> I believe there is a bug, but I can''t find it to reference it now. > Try this: > > if ! defined("server::cobler") { > # do something > } > > On Sep 2, 5:07 pm, "Steven L. Seed" <slseed1...@gmail.com> wrote: > >> I''m having trouble getting puppet to work when using a conditional to >> check whether or not a subclass is defined. >> >> Here is what I''ve tried to do >> >> if ! defined (Class[server::cobbler]) { >> # do something >> >> } >> >> With the above statement I get this error: >> >> err: Could not retrieve catalog from remote server: Error 400 on SERVER: >> Syntax error at ''server::cobbler''; expected '']'' at ... >> >> So I tried quoting the class: >> if ! defined (Class["server::cobbler"]) { >> # do something >> >> } >> >> This doesn''t error out, but it doesn''t do what I''m asking which is to >> only run the section of code when the subclass server::cobbler is not >> defined. >> >> Any ideas? >> > >-- 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.