Hi! I''m using the following way to define the order and assign classes to nodes: node nodename1, nodename2, nodename3, nodename4 { class { "class1": } -> class { "class2": } -> class { "class3": } -> class { "class4": } } I''m fully delighted with it. But at the moment I need class2 to be executed only on nodename2. The following construction doesn''t work node nodename1, nodename2, nodename3, nodename4 { class { "class1": } -> if $fqdn == "nodename2" { class { "class2": } -> } class { "class3": } -> class { "class4": } } And this construction breaks the order: node nodename1, nodename2, nodename3, nodename4 { class { "class1": } if $fqdn == "nodename2" { Class["class1"] -> class { "class2": } } class { "class3": } -> class { "class4": } } What do I do in a situation like this? Thanks in advance. Sergey. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Here''s one way: node nodename1, nodename3, nodename4 { class { "class1": } -> class { "class3": } -> class { "class4": } } node nodename2 { class { "class1": } -> class { "class2": } -> class { "class3": } -> class { "class4": } } “Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” Bill Waterson (Calvin & Hobbes) ----- Original Message ----- From: "Sergey Arlashin" <sergeyarl.maillist@gmail.com> To: puppet-users@googlegroups.com Sent: Thursday, August 15, 2013 1:17:46 PM Subject: [Puppet Users] Puppet: chaining and conditionals Hi! I''m using the following way to define the order and assign classes to nodes: node nodename1, nodename2, nodename3, nodename4 { class { "class1": } -> class { "class2": } -> class { "class3": } -> class { "class4": } } I''m fully delighted with it. But at the moment I need class2 to be executed only on nodename2. The following construction doesn''t work node nodename1, nodename2, nodename3, nodename4 { class { "class1": } -> if $fqdn == "nodename2" { class { "class2": } -> } class { "class3": } -> class { "class4": } } And this construction breaks the order: node nodename1, nodename2, nodename3, nodename4 { class { "class1": } if $fqdn == "nodename2" { Class["class1"] -> class { "class2": } } class { "class3": } -> class { "class4": } } What do I do in a situation like this? Thanks in advance. Sergey. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Have you tried putting all the classes in the conditional? node nodename1, nodename2, nodename3, nodename4 { if $fqdn == "nodename2" { class { "class1": } -> class { "class2": } -> class { "class3": } -> class { "class4": } } else { class { "class1": } -> class { "class3": } -> class { "class4": } } } -- Arthur Furlan On Thu, Aug 15, 2013 at 2:17 PM, Sergey Arlashin <sergeyarl.maillist@gmail.com> wrote:> Hi! > > I''m using the following way to define the order and assign classes to nodes: > > node nodename1, nodename2, nodename3, nodename4 { > class { "class1": } -> > class { "class2": } -> > class { "class3": } -> > class { "class4": } > } > > I''m fully delighted with it. > > But at the moment I need class2 to be executed only on nodename2. The following construction doesn''t work > > node nodename1, nodename2, nodename3, nodename4 { > class { "class1": } -> > if $fqdn == "nodename2" { > class { "class2": } -> > } > class { "class3": } -> > class { "class4": } > } > > And this construction breaks the order: > > node nodename1, nodename2, nodename3, nodename4 { > class { "class1": } > if $fqdn == "nodename2" { > Class["class1"] -> class { "class2": } > } > class { "class3": } -> > class { "class4": } > } > > What do I do in a situation like this? > > > Thanks in advance. > > Sergey. > > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users. > For more options, visit https://groups.google.com/groups/opt_out.-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Sergey Arlashin
2013-Aug-15 17:33 UTC
Re: [Puppet Users] Puppet: chaining and conditionals
Thank you for your reply. This looks nice only if I have 4 classes. That was just an example. In reality I have a huge number of classes assigned to this group of nodes. So I want to avoid (if it is possible of course) declaring classes twice. On Aug 15, 2013, at 9:27 PM, Arthur Furlan <afurlan@afurlan.org> wrote:> Have you tried putting all the classes in the conditional? > > node nodename1, nodename2, nodename3, nodename4 { > if $fqdn == "nodename2" { > class { "class1": } -> > class { "class2": } -> > class { "class3": } -> > class { "class4": } > } else { > class { "class1": } -> > class { "class3": } -> > class { "class4": } > } > } > > > -- Arthur Furlan > > > On Thu, Aug 15, 2013 at 2:17 PM, Sergey Arlashin > <sergeyarl.maillist@gmail.com> wrote: >> Hi! >> >> I''m using the following way to define the order and assign classes to nodes: >> >> node nodename1, nodename2, nodename3, nodename4 { >> class { "class1": } -> >> class { "class2": } -> >> class { "class3": } -> >> class { "class4": } >> } >> >> I''m fully delighted with it. >> >> But at the moment I need class2 to be executed only on nodename2. The following construction doesn''t work >> >> node nodename1, nodename2, nodename3, nodename4 { >> class { "class1": } -> >> if $fqdn == "nodename2" { >> class { "class2": } -> >> } >> class { "class3": } -> >> class { "class4": } >> } >> >> And this construction breaks the order: >> >> node nodename1, nodename2, nodename3, nodename4 { >> class { "class1": } >> if $fqdn == "nodename2" { >> Class["class1"] -> class { "class2": } >> } >> class { "class3": } -> >> class { "class4": } >> } >> >> What do I do in a situation like this? >> >> >> Thanks in advance. >> >> Sergey. >> >> >> -- >> You received this message because you are subscribed to the Google Groups "Puppet Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. >> To post to this group, send email to puppet-users@googlegroups.com. >> Visit this group at http://groups.google.com/group/puppet-users. >> For more options, visit https://groups.google.com/groups/opt_out. > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users. > For more options, visit https://groups.google.com/groups/opt_out.-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Peter Bukowinski
2013-Aug-15 17:54 UTC
Re: [Puppet Users] Puppet: chaining and conditionals
If you don''t mind a hacky workaround, you can accomplish this with the help of an empty class: node nodename1, nodename2, nodename3, nodename4 { if $fqdn == "nodename2" { $class2 = "class2" } else { $class2 = "null_class" } class { "class1": } -> class { "$class2": } -> class { "class3": } -> class { "class4": } } class null_class { } -- Peter Bukowinski On Aug 15, 2013, at 1:33 PM, Sergey Arlashin <sergeyarl.maillist@gmail.com> wrote:> Thank you for your reply. > This looks nice only if I have 4 classes. That was just an example. In reality I have a huge number of classes assigned to this group of nodes. So I want to avoid (if it is possible of course) declaring classes twice. > > > > > > On Aug 15, 2013, at 9:27 PM, Arthur Furlan <afurlan@afurlan.org> wrote: > >> Have you tried putting all the classes in the conditional? >> >> node nodename1, nodename2, nodename3, nodename4 { >> if $fqdn == "nodename2" { >> class { "class1": } -> >> class { "class2": } -> >> class { "class3": } -> >> class { "class4": } >> } else { >> class { "class1": } -> >> class { "class3": } -> >> class { "class4": } >> } >> } >> >> >> -- Arthur Furlan >> >> >> On Thu, Aug 15, 2013 at 2:17 PM, Sergey Arlashin >> <sergeyarl.maillist@gmail.com> wrote: >>> Hi! >>> >>> I''m using the following way to define the order and assign classes to nodes: >>> >>> node nodename1, nodename2, nodename3, nodename4 { >>> class { "class1": } -> >>> class { "class2": } -> >>> class { "class3": } -> >>> class { "class4": } >>> } >>> >>> I''m fully delighted with it. >>> >>> But at the moment I need class2 to be executed only on nodename2. The following construction doesn''t work >>> >>> node nodename1, nodename2, nodename3, nodename4 { >>> class { "class1": } -> >>> if $fqdn == "nodename2" { >>> class { "class2": } -> >>> } >>> class { "class3": } -> >>> class { "class4": } >>> } >>> >>> And this construction breaks the order: >>> >>> node nodename1, nodename2, nodename3, nodename4 { >>> class { "class1": } >>> if $fqdn == "nodename2" { >>> Class["class1"] -> class { "class2": } >>> } >>> class { "class3": } -> >>> class { "class4": } >>> } >>> >>> What do I do in a situation like this? >>> >>> >>> Thanks in advance. >>> >>> Sergey. >>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups "Puppet Users" group. >>> To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. >>> To post to this group, send email to puppet-users@googlegroups.com. >>> Visit this group at http://groups.google.com/group/puppet-users. >>> For more options, visit https://groups.google.com/groups/opt_out. >> >> -- >> You received this message because you are subscribed to the Google Groups "Puppet Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. >> To post to this group, send email to puppet-users@googlegroups.com. >> Visit this group at http://groups.google.com/group/puppet-users. >> For more options, visit https://groups.google.com/groups/opt_out. > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users. > For more options, visit https://groups.google.com/groups/opt_out.-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
perhaps something like this? node nodename1, nodename2, nodename3, nodename4 { class { "class1": } if $fqdn == "nodename2" { Class["class1"] -> class { "class2": } -> class{ "class3" } } else { Class["class1"] -> class { "class3": } } Class["class3"] -> class { "class4": } } On Thursday, August 15, 2013 10:17:46 AM UTC-7, Sergey Arlashin wrote:> > Hi! > > I''m using the following way to define the order and assign classes to > nodes: > > node nodename1, nodename2, nodename3, nodename4 { > class { "class1": } -> > class { "class2": } -> > class { "class3": } -> > class { "class4": } > } > > I''m fully delighted with it. > > But at the moment I need class2 to be executed only on nodename2. The > following construction doesn''t work > > node nodename1, nodename2, nodename3, nodename4 { > class { "class1": } -> > if $fqdn == "nodename2" { > class { "class2": } -> > } > class { "class3": } -> > class { "class4": } > } > > And this construction breaks the order: > > node nodename1, nodename2, nodename3, nodename4 { > class { "class1": } > if $fqdn == "nodename2" { > Class["class1"] -> class { "class2": } > } > class { "class3": } -> > class { "class4": } > } > > What do I do in a situation like this? > > > Thanks in advance. > > Sergey. > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Sergey Arlashin
2013-Aug-17 21:54 UTC
Re: [Puppet Users] Puppet: chaining and conditionals
Thank you all for your answers! Finally I decided to modify a couple of my classes to look like: class { "class1": } -> class { "class2": class_enabled => $fqdn ? { "nodename2" => "yes", default => "no" } } -> class { "class3": } -- best regards, Sergey On Aug 16, 2013, at 12:25 AM, Ellison Marks <gtyaoi@gmail.com> wrote:> perhaps something like this? > > node nodename1, nodename2, nodename3, nodename4 { > class { "class1": } > if $fqdn == "nodename2" { > Class["class1"] -> class { "class2": } -> class{ "class3" } > } > else { > Class["class1"] -> class { "class3": } > } > Class["class3"] -> > class { "class4": } > } > > On Thursday, August 15, 2013 10:17:46 AM UTC-7, Sergey Arlashin wrote: > Hi! > > I''m using the following way to define the order and assign classes to nodes: > > node nodename1, nodename2, nodename3, nodename4 { > class { "class1": } -> > class { "class2": } -> > class { "class3": } -> > class { "class4": } > } > > I''m fully delighted with it. > > But at the moment I need class2 to be executed only on nodename2. The following construction doesn''t work > > node nodename1, nodename2, nodename3, nodename4 { > class { "class1": } -> > if $fqdn == "nodename2" { > class { "class2": } -> > } > class { "class3": } -> > class { "class4": } > } > > And this construction breaks the order: > > node nodename1, nodename2, nodename3, nodename4 { > class { "class1": } > if $fqdn == "nodename2" { > Class["class1"] -> class { "class2": } > } > class { "class3": } -> > class { "class4": } > } > > What do I do in a situation like this? > > > Thanks in advance. > > Sergey. > > > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users. > For more options, visit https://groups.google.com/groups/opt_out.-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.