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 <[email protected]> 
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 <[email protected]> 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
>> <[email protected]> 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 [email protected].
>>> To post to this group, send email to [email protected].
>>> 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 [email protected].
>> To post to this group, send email to [email protected].
>> 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 [email protected].
> To post to this group, send email to [email protected].
> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to