Ask Your Question
0

facter array

asked 2013-11-27 06:54:18 -0500

wingZero gravatar image

updated 2013-11-27 06:54:36 -0500

Hi,

Is there anyway to get a facter array back of hostnames within a particular group.

I am looking to get the FQDN for a group within puppet to automatically populate a template.

I know you can specify the FQDN of one host in a template by doing <%= FQDN %> however is there anyway to do something similar but for all servers within a particular puppet group?

Cheers wingZero

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2013-11-27 17:20:18 -0500

Stefan gravatar image

updated 2013-11-28 06:44:11 -0500

If I get your question right you want to access a fact (in this case fqdn) of another node (or a group of other nodes) right?

This is not possible out of the box but in case you use PuppetDB, puppet will store all facts in PuppetDB and you can use puppetdbquery by Erik Dalén to access these facts inside a manifest.

inside your manifest:

class 'foo' {
  # select every node that has the apache class and get the fqdn fact.
  # The result is an array of fqdns
  $apache_nodes = query_nodes('Class[Apache]', 'fqdn')

  file { '/foo':
    ensure  => file,
    content => template('foo/bar ...
(more)
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

1 follower

Stats

Asked: 2013-11-27 06:54:18 -0500

Seen: 196 times

Last updated: Nov 28 '13