Commit 2c89ce9d authored by Jérémie Gaidamour's avatar Jérémie Gaidamour
Browse files

[dev] bind.rb

parent bb12975f
...@@ -17,26 +17,38 @@ $output_dir = ENV['puppet_repo'] || 'output' ...@@ -17,26 +17,38 @@ $output_dir = ENV['puppet_repo'] || 'output'
# :ip=>"172.16.66", # :ip=>"172.16.66",
# :shift=>0, # :shift=>0,
# :mounted=>true} # :mounted=>true}
def print_entry(entry) def print_entry(entry)
if entry[:start] == entry[:end] if entry[:start] == entry[:end]
return "#{entry[:cluster_uid]}-#{entry[:start]}-#{entry[:net_uid]} IN A #{entry[:ip]}.#{entry[:start]+entry[:shift]}" range = ""
else hostshort = "#{entry[:cluster_uid]}-#{entry[:start]}"
range = "#{entry[:start]}-#{entry[:end]}" ip = "#{entry[:ip]}.#{entry[:start]+entry[:shift]}"
shift = (entry[:shift] > 0 ? '{+' + entry[:shift].to_s + '}' : '') else
ip = "#{entry[:ip]}.$#{shift}" range = "$GENERATE #{entry[:start]}-#{entry[:end]} " # $GENERATE 1-16
hostshort = "#{entry[:cluster_uid]}-$" # graoully-$
shift = (entry[:shift] > 0 ? '{+' + entry[:shift].to_s + '}' : '')
ip = "#{entry[:ip]}.$#{shift}" # 172.16.70.$
end
if entry[:mounted] && /^eth[0-9]$/.match(entry[:net_uid]) hostalias = nil
# primary interface if entry[:mounted] && /^eth[0-9]$/.match(entry[:net_uid])
return ["$GENERATE #{range} #{entry[:cluster_uid]}-$ IN A #{ip}", # primary interface
"$GENERATE #{range} #{entry[:cluster_uid]}-$-#{entry[:net_uid]} IN CNAME #{entry[:cluster_uid]}-$"].join("\n") hostalias = hostshort
elsif /^kavlan-[0-9]*$/.match(entry[:net_uid])
elsif /^kavlan-[0-9]*$/.match(entry[:net_uid]) # kvlan
return ["$GENERATE #{range} #{entry[:cluster_uid]}-$-eth0-#{entry[:net_uid]} IN A #{ip}", hostalias = hostshort + "-eth0-#{entry[:net_uid]}" # graoully-$-eth0-kavlan-1
"$GENERATE #{range} #{entry[:cluster_uid]}-$-#{entry[:net_uid]} IN CNAME #{entry[:cluster_uid]}-$-eth0-#{entry[:net_uid]}"].join("\n") end
else
return "$GENERATE #{range} #{entry[:cluster_uid]}-$-#{entry[:net_uid]} IN A #{ip}" hostname = hostshort + "-#{entry[:net_uid]}" # graoully-$-eth0
end
if hostalias
return ["#{range}#{hostalias} IN A #{ip}",
"#{range}#{hostname} IN CNAME #{hostalias}"].join("\n")
else
return "#{range}#{hostname} IN A #{ip}"
end end
end end
# def write_bind_file(data) # def write_bind_file(data)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment