jsirex / nsupdate-cookbook

Chef Cookbook for managing DNS Entries through nsupdate
MIT License
0 stars 4 forks source link

Using programatically #2

Closed brianjmurrell closed 7 years ago

brianjmurrell commented 7 years ago

Hi,

I understand how I could create a recipe that listed all of the DNS records I wanted to update using:

nsupdate 'www.example.com' do
  value 'other.host.com'
  type :cname
  ttl 86400
  action :update
end

type stanzas, but if I instead, had my list of names and values in a different data structure, say a list of some wort, can I use this LWRP in any way to produce updates or am I going to be writing my own code around nsupdate to process that list and do the updates?

jsirex commented 7 years ago

I'm not sure what are you talking about? May be you want to use plain ruby to work with your data structure:

my_hash = { 'host1' => 'host2', 'host3' => 'host4' }
...
my_hash.each_pair do |h, v|
  nsupdate h do
    value v
    type :cname
    ttl 86400
    action :update
  end
end
brianjmurrell commented 7 years ago

Oh, duh! Of course. Even though I have done similar a zillion times, it must have just been too late for me last night when I was looking at this.

Thanks!