Excluding hostnames from a module via parameter

56 views
Skip to first unread message

cko

unread,
Mar 3, 2014, 10:33:38 AM3/3/14
to puppet...@googlegroups.com
Hi,
here is what I'm trying to do:

I want to be able to exclude certain hostnames/ from a module by passing their hostnames in a parameter (array) within this module.

Example:

class centos-default {

  class { 'module':
    exclude => [ 'host1', 'host2' ],
  }

  class { 'module2':
    exclude => [ 'host3', 'host4' ],
  }

}

Now I assumed that the module code would have to look something like this:

class module(

  $exclude = '',

)
{

  if $::hostname != $exclude {
    include module::config
    include module::install
    ....
  }

}

But I can't seem to find the correct syntax for my "if" statement.


 

José Luis Ledesma

unread,
Mar 3, 2014, 12:28:34 PM3/3/14
to puppet...@googlegroups.com

You are comparing a string (hostname) with an array.

Instead of != you should use something like:

If ! $::hostname in $exclude

Regards,

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/6928abf7-b83b-4173-854b-e7f7efccbde7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

cko

unread,
Mar 4, 2014, 8:00:33 AM3/4/14
to puppet...@googlegroups.com
Thanks! That worked
Reply all
Reply to author
Forward
0 new messages