Dick Davies wrote:

# this gets used by several classes
$activedbhost = "mysql1.mydomain.com"

host { "db.hosting.mydomain.com":
   ensure => present,
   ip          => ip_of($activedbhost)
}

'ip_of()' is what Puppet calls a 'function', right?
Does anyone have a reference on how to write them -
the reductive labs docs seem a little broken today.

Or better still, has someone already written such a thing :)

As a matter of fact, yes, I have. :-)

In my "nsc-puppet-utils" module, I have a function resolve_ipnets()
which does that.  (It does have some additional features as well.
For example, it resolves names on the form "foo.example.com/24"
to "10.20.30.17/24", and it handles lists of hostnames as well.)

Do a 'git clone http://www.nsc.liu.se/~bellman/nsc-puppet-utils.git'
to get my module.  There is documentation inside the file
plugins/puppet/parser/functions/resolve_ipnets.rb.


A little note, though.  If you use this to populate /etc/hosts from
DNS, and you do so on your Puppetmaster, you won't be able to change
the address of that name.  The next time resolve_ipnets() is called,
it will find the address in /etc/hosts, and then you're stuck.  (You
can of course remove that entry from /etc/hosts manually, and then
you'll be OK again, but that's cheating. :-)


        /Bellman

--
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.

Reply via email to