Add support for manually specifying a dns slave
This commit is contained in:
parent
df9d03b885
commit
d4d3298e88
|
@ -1,45 +0,0 @@
|
|||
options:
|
||||
dns-backend:
|
||||
default:
|
||||
type: string
|
||||
description: IP Address of dns backend
|
||||
nova-domain:
|
||||
default: 'www.example.com.'
|
||||
type: string
|
||||
description: Domain to add records for new instances to
|
||||
nova-domain-email:
|
||||
default: 'email@example.com'
|
||||
type: string
|
||||
description: Email address of the person responsible for the domain.
|
||||
dns-server-record:
|
||||
default: 'ns1.www.example.com.'
|
||||
type: string
|
||||
description: DNS server record
|
||||
neutron-domain:
|
||||
default: 'www.bob.com.'
|
||||
type: string
|
||||
description: Domain to add floating ip recirds to
|
||||
neutron-domain-email:
|
||||
default: 'email@example.com'
|
||||
type: string
|
||||
description: Email address of the person responsible for the domain.
|
||||
vip:
|
||||
type: string
|
||||
default:
|
||||
description: |
|
||||
Virtual IP(s) to use to front API services in HA configuration.
|
||||
|
||||
If multiple networks are being used, a VIP should be provided for each
|
||||
network, separated by spaces.
|
||||
vip_iface:
|
||||
type: string
|
||||
default: eth0
|
||||
description: |
|
||||
Default network interface to use for HA vip when it cannot be
|
||||
automatically determined.
|
||||
vip_cidr:
|
||||
type: int
|
||||
default: 24
|
||||
description: |
|
||||
Default CIDR netmask to use for HA vip when it cannot be automatically
|
||||
determined.
|
|
@ -0,0 +1,29 @@
|
|||
options:
|
||||
dns-slaves:
|
||||
default:
|
||||
type: string
|
||||
description: |
|
||||
List of DNS slaves which will accept addzone/delzone rndc commands from
|
||||
Designate. List is of the form slave_ip:rndc_port:rndc_key. This should
|
||||
only be used if DNS servers are outside of Juju control. Using the
|
||||
designate-bind charm is the prefered approach.
|
||||
nova-domain:
|
||||
default: 'www.example.com.'
|
||||
type: string
|
||||
description: Domain to add records for new instances to
|
||||
nova-domain-email:
|
||||
default: 'email@example.com'
|
||||
type: string
|
||||
description: Email address of the person responsible for the domain.
|
||||
dns-server-record:
|
||||
default: 'ns1.www.example.com.'
|
||||
type: string
|
||||
description: DNS server record
|
||||
neutron-domain:
|
||||
default: 'www.bob.com.'
|
||||
type: string
|
||||
description: Domain to add floating ip records to
|
||||
neutron-domain-email:
|
||||
default: 'email@example.com'
|
||||
type: string
|
||||
description: Email address of the person responsible for the domain.
|
|
@ -7,6 +7,7 @@ import charms_openstack.adapters as openstack_adapters
|
|||
import charms_openstack.charm as openstack_charm
|
||||
import charms_openstack.ip as os_ip
|
||||
import charmhelpers.core.hookenv as hookenv
|
||||
import charmhelpers.core.host as host
|
||||
|
||||
DESIGNATE_DIR = '/etc/designate'
|
||||
DESIGNATE_DEFAULT = '/etc/default/openstack'
|
||||
|
@ -87,6 +88,9 @@ def configure_ssl(keystone=None):
|
|||
def update_peers(cluster):
|
||||
DesignateCharm.singleton.update_peers(cluster)
|
||||
|
||||
def render_rndc_keys():
|
||||
DesignateCharm.singleton.render_rndc_keys()
|
||||
|
||||
def assess_status():
|
||||
"""Just call the BarbicanCharm.singleton.assess_status() command to update
|
||||
status on the unit.
|
||||
|
@ -121,15 +125,15 @@ class BindRNDCRelationAdapter(openstack_adapters.OpenStackRelationAdapter):
|
|||
|
||||
@property
|
||||
def pool_config(self):
|
||||
config = []
|
||||
pconfig = []
|
||||
for slave in self.slave_ips:
|
||||
unit_name = slave['unit'].replace('/', '_').replace('-', '_')
|
||||
config.append({
|
||||
pconfig.append({
|
||||
'nameserver': 'nameserver_{}'.format(unit_name),
|
||||
'pool_target': 'nameserver_{}'.format(unit_name),
|
||||
'address': slave['address'],
|
||||
})
|
||||
return config
|
||||
return pconfig
|
||||
|
||||
@property
|
||||
def nameservers(self):
|
||||
|
@ -157,6 +161,33 @@ class DesignateConfigurationAdapter(
|
|||
port_map=port_map,
|
||||
service_name='designate')
|
||||
|
||||
@property
|
||||
def pool_config(self):
|
||||
pconfig = []
|
||||
for entry in self.dns_slaves.split():
|
||||
address, port, key = entry.split(':')
|
||||
unit_name = address.replace('.', '_')
|
||||
pconfig.append({
|
||||
'nameserver': 'nameserver_{}'.format(unit_name),
|
||||
'pool_target': 'nameserver_{}'.format(unit_name),
|
||||
'address': address,
|
||||
'rndc_key_file': '/etc/designate/rndc_{}.key'.format(unit_name),
|
||||
})
|
||||
return pconfig
|
||||
|
||||
@property
|
||||
def nameservers(self):
|
||||
return ', '.join([s['nameserver'] for s in self.pool_config])
|
||||
|
||||
@property
|
||||
def pool_targets(self):
|
||||
return ', '.join([s['pool_target'] for s in self.pool_config])
|
||||
|
||||
@property
|
||||
def slave_addresses(self):
|
||||
return ', '.join(['{}:53'.format(s['address'])
|
||||
for s in self.pool_config])
|
||||
|
||||
@property
|
||||
def nova_domain_id(self):
|
||||
"""Returns the id of the domain corresponding to the user supplied
|
||||
|
@ -207,13 +238,6 @@ class DesignateConfigurationAdapter(
|
|||
"""Returns IP address slave DNS slave should use to query master
|
||||
"""
|
||||
return os_ip.resolve_address(endpoint_type=os_ip.INTERNAL)
|
||||
#class DesignateCharmFactory(openstack_charm.OpenStackCharmFactory):
|
||||
#
|
||||
# releases = {
|
||||
# 'liberty': DesignateCharm
|
||||
# }
|
||||
#
|
||||
# first_release = 'liberty'
|
||||
|
||||
class DesignateAdapters(openstack_adapters.OpenStackAPIRelationAdapters):
|
||||
"""
|
||||
|
@ -310,6 +334,33 @@ class DesignateCharm(openstack_charm.HAOpenStackCharm):
|
|||
"""
|
||||
DesignateCharm.singleton.render_with_interfaces(interfaces_list)
|
||||
|
||||
def write_key_file(self, unit_name, key):
|
||||
"""Write rndc keyfile for given unit_name
|
||||
|
||||
@param unit_name: str Name of unit using key
|
||||
@param key: str RNDC key
|
||||
@returns None
|
||||
"""
|
||||
key_file = '/etc/designate/rndc_{}.key'.format(unit_name)
|
||||
template = ('key "rndc-key" {{\n algorithm hmac-md5;\n '
|
||||
'secret "{}";\n}};')
|
||||
host.write_file(
|
||||
key_file,
|
||||
str.encode(template.format(key)),
|
||||
owner='root',
|
||||
group='designate',
|
||||
perms=0o440)
|
||||
|
||||
def render_rndc_keys(self):
|
||||
"""Render the rndc keys supplied via user config
|
||||
|
||||
@returns None
|
||||
"""
|
||||
for entry in hookenv.config('dns-slaves').split():
|
||||
address, port, key = entry.split(':')
|
||||
unit_name = address.replace('.', '_')
|
||||
self.write_key_file(unit_name, key)
|
||||
|
||||
@classmethod
|
||||
def get_domain_id(cls, domain):
|
||||
"""Return the domain ID for a given domain name
|
|
@ -79,6 +79,7 @@ def render_all_configs(*args):
|
|||
@reactive.when(*COMPLETE_INTERFACE_STATES)
|
||||
def render_all_configs_single_node(*args):
|
||||
designate.render_full_config(args)
|
||||
designate.render_rndc_keys()
|
||||
|
||||
@reactive.when('ha.connected')
|
||||
def cluster_connected(hacluster):
|
|
@ -1,4 +1,3 @@
|
|||
# {{ dns_backend.slave_ips }}
|
||||
[DEFAULT]
|
||||
# Where an option is commented out, but filled in this shows the default
|
||||
# value of that optiona aaa
|
||||
|
@ -330,28 +329,47 @@ connection = {{ shared_db.designate_pool_uri }}
|
|||
# example pool / server set up. Different backends will have different options.
|
||||
|
||||
[pool:794ccc2c-d751-44fe-b57f-8894c9f5c842]
|
||||
nameservers = {{ dns_backend.nameservers }}
|
||||
targets = {{ dns_backend.pool_targets }}
|
||||
nameservers = {{ dns_backend.nameservers }}{% if dns_backend.nameservers and options.nameservers -%}, {% endif %}{{ options.nameservers }}
|
||||
targets = {{ dns_backend.pool_targets }}{% if dns_backend.nameservers and options.nameservers -%}, {% endif %}{{ options.pool_targets }}
|
||||
|
||||
also_notifies = {{ dns_backend.slave_addresses }}
|
||||
also_notifies = {{ dns_backend.slave_addresses }}{% if dns_backend.nameservers and options.nameservers -%}, {% endif %}{{ options.slave_addresses }}
|
||||
|
||||
{% if dns_backend.pool_config -%}
|
||||
{% if dns_backend.pool_config %}
|
||||
{% for slave in dns_backend.pool_config -%}
|
||||
[pool_nameserver:{{ slave.nameserver }}]
|
||||
port = 53
|
||||
host = {{ slave.address }}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
{% endif %}
|
||||
|
||||
{% if options.pool_config %}
|
||||
{% for slave in options.pool_config -%}
|
||||
[pool_nameserver:{{ slave.nameserver }}]
|
||||
port = 53
|
||||
host = {{ slave.address }}
|
||||
{% endfor -%}
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if dns_backend.pool_config -%}
|
||||
{% if dns_backend.pool_config %}
|
||||
{% for slave in dns_backend.pool_config -%}
|
||||
[pool_target:{{ slave.pool_target }}]
|
||||
options = rndc_host: {{ slave.address }}, rndc_key_file: /etc/designate/rndc.key
|
||||
masters = {{ options.rndc_master_ip }}:5354
|
||||
type = bind9
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if options.pool_config %}
|
||||
{% for slave in options.pool_config -%}
|
||||
[pool_target:{{ slave.pool_target }}]
|
||||
options = rndc_host: {{ slave.address }}, rndc_key_file: {{ slave.rndc_key_file }}
|
||||
masters = {{ options.rndc_master_ip }}:5354
|
||||
type = bind9
|
||||
{% endfor -%}
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
##############
|
Loading…
Reference in New Issue