What:
Puppet
Problem:
You need to resolve dns name inside puppet to avoid hard coding ip address.
Solution:
The simplest way of doing dns lookup inside a puppet manifest is to use inline template.
You can assign IP to a variable:
$ip_address = inline_template("<% _erbout.concat(Resolv::DNS.open.getaddress('example.com').to_s) %>")The other way of doing it is for example using one of the puppet's resource type:
host { 'dynamic-ip':
ensure => present,
ip => inline_template("<% _erbout.concat(Resolv::DNS.open.getaddress('example.com').to_s) %>"),
name => example.com,
target => '/etc/hosts',
}
Source: 1
No comments:
Post a Comment