use multiple facts into an array

asked 2017-11-13 09:05:59 -0600

Is there a way to take three facts that every host reports: "$::ipaddress,", "$::fqdn", "$::hostname" push them into an array or arrays and use them in a class that generates a config file. Still reltivly new to puppet and ruby and searched all around couldn't find anything other than this:

https://ask.puppet.com/question/14391...

but that is just one piece of the puzzle.

going into this:

class myclass  {
  file { "::${hostname}.cfg"
    path => '/tmp/test',
    ensure => 'file',
    content => template ('myclass/hosts.cfg.erb'),
  }
}

Thanks for any help

edit retag flag offensive close merge delete

Comments

Hi Allen, Can you share what you'd like your template file to look like (even without the variable...)?

stivesso gravatar imagestivesso ( 2017-11-14 05:32:51 -0600 )edit

You can unite multiple facts into an array just by specifying a literal array, so: [$ipaddress, $fqdn, $hostname]

Kai Burghardt gravatar imageKai Burghardt ( 2017-11-14 11:46:41 -0600 )edit