3.2.
The hiera JSON file generated looks like this:
{
"instances": {
"prod-api-01": {
"private_ip": "10.1.1.1",
"public_ip": "23.1.1.1",
},
"prod-api-02": {
"private_ip": "10.2.2.2",
"public_ip": "23.2.2.2",
},
"prod-api-03": {
"private_ip": "10.3.3.3",
"public_ip": "23.3.3.3",
}
}
}
My manifest has the following declarations:
$instances = hiera_hash('instances')
$instance_names = keys($instances)
In my hosts.cfg.erb template, I attempted the following, but neither works
(entries for alias and address are blank).
<%- @instances.each_pair do |instance_name, attributes| -%>
define host {
host_name <%= @instance_name %>
use host-platform-prod-group
alias <%= attributes['public_ip'] %>
address <%= attributes['private_ip'] %>
}
<%- end -%>
AND
<%- @instance_names.each do | instance_name | -%>
define host {
host_name <%= @instance_name %>
alias <%= @instances[@instance_name]['public_ip'] %>
address <%= @instances[@instance_name]['private_ip'] %>
}
<%- end -%>
I know I can access @instances and @instance_names within the template, but
the template does not appear to find values for the loop variable
@instance_name. Why is this?
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.