Commit 7f4f7b2e authored by anarcat's avatar anarcat Committed by anarcat

make slave servers support multi-master setups by just passing all the ips of...

make slave servers support multi-master setups by just passing all the ips of the master and explicitely requiring the master per zone
parent 6117b903
...@@ -17,7 +17,6 @@ class provisionService_dns_bind_slave extends provisionService_dns { ...@@ -17,7 +17,6 @@ class provisionService_dns_bind_slave extends provisionService_dns {
function init_server() { function init_server() {
parent::init_server(); parent::init_server();
$this->server->setProperty('dns_master_server', null);
$this->configs['server'][] = 'provisionConfig_bind_slave'; $this->configs['server'][] = 'provisionConfig_bind_slave';
} }
...@@ -25,7 +24,32 @@ class provisionService_dns_bind_slave extends provisionService_dns { ...@@ -25,7 +24,32 @@ class provisionService_dns_bind_slave extends provisionService_dns {
$this->restart(); $this->restart();
} }
function create_zone($zone = null) { /**
* Create the zonefile record on the slave server
*
* This differs from the parent implementation because it *requires* you to
* pass the master server, as it is necessary for the slave to know what its
* slave is (and it can vary according to the zone).
*
* Contrarily to the parent class implementation, this *only* creates the
* bind config (managed through the provisionConfig_bind_slave class), and no
* zonefile, because the zonefile should be managed by bind itself through
* regular zone transfers.
*
* Note that this function shouldn't be called directly through the API, but
* only from the master server's create_zone() function.
*
* @todo this needs to be pushed up in a provisionService_dns_slave common
* class
*
* @arg $master mixed a string or array of strings of IPs pointing to the
* master server for this zone
*
* @arg $zone string the zonefile name to create
*
* @see provisionService_dns::create_zone()
*/
function create_zone($master, $zone = null) {
if (is_null($zone) && ($this->context->type == 'site')) { if (is_null($zone) && ($this->context->type == 'site')) {
$host = $this->context->uri; $host = $this->context->uri;
$zone = $this->context->dns_zone; $zone = $this->context->dns_zone;
...@@ -35,8 +59,8 @@ class provisionService_dns_bind_slave extends provisionService_dns { ...@@ -35,8 +59,8 @@ class provisionService_dns_bind_slave extends provisionService_dns {
return drush_set_error('DRUSH_DNS_NO_ZONE', "Could not determine the zone to create"); return drush_set_error('DRUSH_DNS_NO_ZONE', "Could not determine the zone to create");
} }
drush_log(dt("recording zone in server configuration")); drush_log(dt("recording zone in slave configuration"));
$this->config('server')->record_set($zone, $zone)->write(); $this->config('server')->record_set($zone, $master)->write();
} }
} }
......
<?php <?php
foreach ($records as $key => $name) { foreach ($records as $zone => $master) {
printf('zone "%s" { type slave; file "%s/%s.zone"; masters { %s; }; allow-query { any; }; };' . "\n", $name, $dns_zoned_path, $name, $master_server); if (is_array($master)) {
$master = implode(";", $master);
}
printf('zone "%s" { type slave; file "%s/%s.zone"; masters { %s; }; allow-query { any; }; };' . "\n", $zone, $dns_zoned_path, $zone, $master);
} }
?> ?>
...@@ -277,7 +277,7 @@ class provisionService_dns extends provisionService { ...@@ -277,7 +277,7 @@ class provisionService_dns extends provisionService {
$this->config('server')->record_set($zone, $zone)->write(); $this->config('server')->record_set($zone, $zone)->write();
drush_log(dt("creating zone configuration on slaves")); drush_log(dt("creating zone configuration on slaves"));
$this->_each_server("create_zone", $zone); $this->_each_server("create_zone", array($this->context->ip_addresses, $zone));
} }
/** /**
......
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