instance-powerdns.cfg 4.34 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
{% if slap_software_type in software_type -%}
{% set part_list =  [] %}

# Create all needed directories
[directory]
recipe = slapos.cookbook:mkdirectory

bin = $${buildout:directory}/bin/
etc = $${buildout:directory}/etc/
srv = $${buildout:directory}/srv/
var = $${buildout:directory}/var/
template = $${buildout:directory}/template/

backup = $${:srv}/backup
log = $${:var}/log
run = $${:var}/run
service = $${:etc}/service
etc-run = $${:etc}/run
promise = $${:etc}/promise

logrotate-backup = $${:backup}/logrotate
logrotate-entries = $${:etc}/logrotate.d

cron-entries = $${:etc}/cron.d
crontabs = $${:etc}/crontabs
cronstamps = $${:etc}/cronstamps
ca-dir = $${:srv}/ssl

# Instance parameters
[instance-parameter]
# Fetches parameters defined in SlapOS Master for this instance.
# Always the same.
recipe = slapos.cookbook:slapconfiguration.serialised
computer = $${slap-connection:computer-id}
partition = $${slap-connection:partition-id}
url = $${slap-connection:server-url}
key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file}


# Generic jinja section to extend
[jinja2-template-base]
recipe = slapos.recipe.template:jinja2
rendered = $${buildout:directory}/$${:filename}
extra-context =
context =
    import json_module json
    key eggs_directory buildout:eggs-directory
    key develop_eggs_directory buildout:develop-eggs-directory
    key slap_software_type instance-parameter:slap-software-type
    key slapparameter_dict instance-parameter:configuration
    section directory directory
    $${:extra-context}

####################
# PowerDNS sections
#
[pdns]
configuration = $${pdns-directory:configuration}/pdns.conf
local-ipv4 = $${instance-parameter:ipv4-random}
ipv6 = $${instance-parameter:ipv6-random}
port = 5353
socket-directory = $${pdns-directory:socket}
webserver-port = 8088

[geo]
ip-map-zonefile = ${iso-list:location}/${iso-list:filename}
geo-maps = $${pdns-directory:geo-maps}

[pdns-directory]
recipe = slapos.cookbook:mkdirectory
configuration = $${directory:etc}/pdns
geo-maps = $${:configuration}/geo-maps
socket = $${directory:run}/pdns-socket

[pdns-configuration-template]
< = jinja2-template-base
template = ${template-pdns-configuration:target}
rendered = $${pdns:configuration}
extra-context =
  section pdns pdns
  section geo geo

# Executables
[pdns-server]
recipe = slapos.cookbook:wrapper
command-line = ${powerdns:location}/sbin/pdns_server --config-dir=$${pdns-directory:configuration}
wrapper-path = $${directory:service}/pdns

[pdns-reload]
recipe = slapos.cookbook:wrapper
command-line = ${powerdns:location}/bin/pdns_control reload --config-dir=$${pdns-directory:configuration}
wrapper-path = $${directory:etc-run}/pdns-reload

# Promises
[pdns-promise-listen-port]
recipe = slapos.cookbook:check_port_listening
path = $${directory:promise}/pdns-port-listening
hostname = $${pdns:local-ipv4}
port = $${pdns:port}

102 103
[publish-connection-informations]
recipe = slapos.cookbook:publish
104 105 106
monitor-url = $${monitor-publish-parameters:monitor-url}
monitor-user = $${monitor-publish-parameters:monitor-user}
monitor-password = $${monitor-publish-parameters:monitor-password}
107

108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
#####################
# Power DNS Slave configuration
#
{% set slave_instance_list = json_module.loads(slapparameter_dict.get('extra_slave_instance_list', '')) %}

# Iter through slave list to prepare configuration
{% for slave in slave_instance_list %}
{%   if 'record' in slave and 'origin' in slave and 'default' in slave %}
{%     set slave_reference = slave.get('slave_reference') %}
{%     set slave_section_name = 'map-configuration-%s' % slave_reference  %}
{%     do part_list.append(slave_section_name) %}
[{{ slave_section_name }}]
< = jinja2-template-base
template = ${template-cdn-conf:location}/${template-cdn-conf:filename}
rendered = $${geo:geo-maps}/{{ slave_reference }}
configuration = {{ json_module.dumps(slave) }}
extra-context =
  key json_cdn :configuration
{%   endif %}
{% endfor %}

129 130 131 132 133
####################
# Monitoring
[monitor-rewrite-rule]
powerdns = http://$${pdns:local-ipv4}:$${pdns:webserver-port}/

134 135 136 137 138 139
[buildout]
parts =
  pdns-configuration-template
  pdns-server
  pdns-reload
  pdns-promise-listen-port
140
  monitor-base
141
  publish-connection-informations
142 143 144 145 146 147 148 149 150
{% for part in part_list %}
{{ '  %s' % part }}
{% endfor %}

extends = ${monitor-template:output}

eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
offline = true
151
{% endif%}