Ask Your Question
0

How do you pass a parameter to a class when including it in a node definition?

asked 2016-04-06 09:56:04 -0500

nvigier gravatar image

Hi,

I'm trying to do something like:

##site.pp

node /^srv-es-master-(\d+)$/ {
  $node_type = 'master'
  include es_node($node_type)
}

node /^srv-es-client-(\d+)$/ {
  $node_type = 'client'
  include es_node($node_type)
}

##es_node.pp

class es_node (String $node_type) {
...
}

But I have no idea what the syntax is and can't seem to find it in the docs.

Thanks

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2016-04-06 22:56:03 -0500

Should be

node /^srv-es-master-(\d+)$/ {
  class { 'es_node':
    node_type => 'master',
  }
}
edit flag offensive delete link more
0

answered 2016-04-07 02:03:41 -0500

nvigier gravatar image

Works great!

Thanks

edit flag offensive delete link more

Comments

If you could mark it as resolved then that would be great, thanks.

Alex Harvey gravatar imageAlex Harvey ( 2016-04-07 02:55:35 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-04-06 09:43:04 -0500

Seen: 386 times

Last updated: Apr 07 '16