lib/testlab/node/bind.rb in testlab-0.0.4 vs lib/testlab/node/bind.rb in testlab-0.1.0
- old
+ new
@@ -15,18 +15,18 @@
def build_bind_records
forward_records = Hash.new
reverse_records = Hash.new
TestLab::Container.all.each do |container|
- interface = container.primary_interface
- domain = (container.domain || container.node.labfile.config[:domain])
+ interface = container.primary_interface
+ container.domain ||= container.node.labfile.config[:domain]
- forward_records[domain] ||= Array.new
- forward_records[domain] << %(#{container.id} IN A #{container.ip})
+ forward_records[container.domain] ||= Array.new
+ forward_records[container.domain] << %(#{container.id} IN A #{container.ip})
reverse_records[interface.first] ||= Array.new
- reverse_records[interface.first] << %(#{container.ptr} IN PTR #{container.id}.#{domain}.)
+ reverse_records[interface.first] << %(#{container.ptr} IN PTR #{container.id}.#{container.domain}.)
end
{ :forward => forward_records, :reverse => reverse_records }
end
# Builds the bind configuration sections for our zones
@@ -46,12 +46,11 @@
file.puts(ZTK::Template.render(bind_zone_template, context))
build_bind_db(network.arpa, reverse_records[network.id])
end
- domains = ([self.labfile.config[:domain]] + TestLab::Container.domains).flatten
- domains.each do |domain|
+ TestLab::Container.domains.each do |domain|
context = {
:zone => domain
}
file.puts
@@ -66,28 +65,31 @@
self.ssh.file(:target => "/etc/bind/db.#{zone}", :chown => "bind:bind") do |file|
file.puts(ZTK::Template.do_not_edit_notice(:message => "TestLab v#{TestLab::VERSION} BIND DB: #{zone}", :char => ';'))
file.puts(ZTK::Template.render(bind_db_template, { :zone => zone, :records => records }))
end
-
- # self.ssh.exec(%(sudo rm -fv /etc/bind/db.#{zone}.jnl))
end
# Builds the BIND configuration
def build_bind_conf
self.ssh.file(:target => File.join("/etc/bind/named.conf"), :chown => "bind:bind") do |file|
build_bind_main_partial(file)
build_bind_zone_partial(file)
end
end
- def bind_setup
- bind_setup_template = File.join(self.class.template_dir, 'bind-setup.erb')
- self.ssh.bootstrap(ZTK::Template.render(bind_setup_template))
+ def bind_install
+ self.ssh.exec(%(sudo apt-get -y install bind9))
+ end
- build_bind_conf
+ def bind_reload
+ self.ssh.exec(%(sudo rndc reload))
+ end
- self.ssh.exec(%(sudo /bin/bash -c 'service bind9 restart || service bind9 start'))
+ def bind_setup
+ bind_install
+ build_bind_conf
+ bind_reload
end
end
end