Hi, we're trying to re-use some variables that are currently used for templating a configuration file. We found out these same hosts need to be in our /etc/hosts file as well, so we'd like to use the built-in host type to do this, but since our list of hosts is stored as an array, I'm having some issues.
Here's what we have: $my_servers = ["server1.domain|1.1.1.1","server2.domain|1.1.1.2"] Our template does this (we need both the FQDN and the short name in the config file, for software reasons): <% my_servers.each do |server| %> SERVER = <%= server.split('|')[0] %> SERVER = <%= server.split('|')[0].split('.')[0] %> So, how can we re-use the array of data we have so that we don't need to recreate things? I was looking at doing something like this: define multihosts($line) { $hostname = split($line, "[|]")[0] $ip = split($line, "[|]")[1] ... host { "$name_$hostname": name => $hostname, ... } } multihosts { foo: line => $my_servers[0] } But puppet does not seem to like indexing variables inside classes, and I can't find anywhere in the language reference where to do this currently. Also, despite the fact that the split() function is in the function reference, I am getting the following error: err: Could not retrieve catalog: Unknown function split at /var/lib/puppet/modules/... on node mynode So, what am I doing wrong, and what is the best way to proceed? -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-us...@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.