Ask Your Question
0

Pass facter value to class

asked 2015-04-28 14:49:20 -0500

ToothCrustLoop gravatar image
 class sensuJenkinsMasterClient {
   class { 'sensu':          
     purge_config       => true,
     rabbitmq_password  => '',
     rabbitmq_host      => 'sensu-master',
     #Need fqdn for remediator to work
     subscriptions      => ['sensu-default', 'centosJenkinsMaster', '"${::fqdn}"'], #
"${::fqdn}\" fails too
     use_embedded_ruby  => true, #set under /etc/default/sensu
  }
}

I don't know how to make this work, I need unique subscription without having to write a class for each host. Each one I tried just adds it literally. This is the sensu module, facter 2.2.0

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2015-04-28 19:16:48 -0500

JohnsonEarls gravatar image

Single-quoted strings (e.g. 'foo') do not do variable interpolation.

You said "${::fqdn}\" fails also. Did you intend to include the \ in that expression?

Just to be clear: Have you tried either of these two subscriptions lines?

    subscriptions      => ['sensu-default', 'centosJenkinsMaster', "${::fqdn}" ],
    subscriptions      => ['sensu-default', 'centosJenkinsMaster', $::fqdn ],

Depending on the version (≥3.5) and configuration (trusted_node_data=true and immutable_node_data=false) of Puppet, you can also try to use the $facts hash (see The $facts['fact_name'] Hash section of the Language: Facts and Built-in Variables reference):

    subscriptions      => ['sensu-default', 'centosJenkinsMaster', "${facts['fqdn']}" ],
    subscriptions      => ['sensu-default', 'centosJenkinsMaster', $facts['fqdn'] ],
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 2015-04-28 14:44:44 -0500

Seen: 97 times

Last updated: Apr 28 '15