summaryrefslogtreecommitdiff
path: root/devstack
diff options
context:
space:
mode:
authorGraham Hayes <graham.hayes@hpe.com>2016-09-15 14:24:42 +0100
committerGraham Hayes <graham.hayes@hpe.com>2016-09-16 17:33:13 +0100
commitaa23d868357e570ba8d7990c66e4bb5b1bddbee5 (patch)
treeef62410a90e75935921a5ed3c9a8caec055c6de0 /devstack
parented04418957d0f7c9642d31cd3dd59e29223cf161 (diff)
Add PowerDNS 4 driver
Notes
Notes (review): Code-Review+1: Erik Olof Gunnar Andersson <eandersson@blizzard.com> Code-Review+2: Kiall Mac Innes <kiall@macinnes.ie> Code-Review+2: Eric Larson <eric.larson@rackspace.com> Workflow+1: Eric Larson <eric.larson@rackspace.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Mon, 19 Sep 2016 15:15:06 +0000 Reviewed-on: https://review.openstack.org/371054 Project: openstack/designate Branch: refs/heads/master
Diffstat (limited to 'devstack')
-rw-r--r--devstack/designate_plugins/backend-pdns4181
-rw-r--r--devstack/designate_plugins/backend-pdns4-mysql-db.sql92
2 files changed, 273 insertions, 0 deletions
diff --git a/devstack/designate_plugins/backend-pdns4 b/devstack/designate_plugins/backend-pdns4
new file mode 100644
index 0000000..37247b8
--- /dev/null
+++ b/devstack/designate_plugins/backend-pdns4
@@ -0,0 +1,181 @@
1# Configure the powerdns backend
2
3# Enable with:
4# DESIGNATE_BACKEND_DRIVER=powerdns
5
6# Dependencies:
7# ``functions`` file
8# ``designate`` configuration
9
10# install_designate_backend - install any external requirements
11# configure_designate_backend - make configuration changes, including those to other services
12# init_designate_backend - initialize databases, etc.
13# start_designate_backend - start any external services
14# stop_designate_backend - stop any external services
15# cleanup_designate_backend - remove transient data and cache
16
17# Save trace setting
18DP_PDNS_XTRACE=$(set +o | grep xtrace)
19set +o xtrace
20
21# Defaults
22# --------
23if is_fedora; then
24 POWERDNS_CFG_DIR=/etc/pdns
25else
26 POWERDNS_CFG_DIR=/etc/powerdns
27fi
28
29# Entry Points
30# ------------
31
32# install_designate_backend - install any external requirements
33function install_designate_backend {
34 if is_ubuntu; then
35 GetOSVersion
36 if [ "$os_CODENAME" = "trusty" ]; then
37 sudo tee /etc/apt/sources.list.d/pdns.list > /dev/null <<EOF
38deb [arch=amd64] http://repo.powerdns.com/ubuntu trusty-auth-40 main
39EOF
40 sudo tee /etc/apt/preferences.d/pdns > /dev/null <<EOF
41Package: pdns-*
42Pin: origin repo.powerdns.com
43Pin-Priority: 600
44EOF
45 curl https://repo.powerdns.com/FD380FBB-pub.asc | sudo apt-key add - &&
46 sudo apt-get update
47 elif [ "$os_CODENAME" = "xenial" ]; then
48 echo "Use PDNS4 from apt repo"
49 else
50 die $LINENO "PDNS4 backend only supports trusty or xenial"
51 fi
52 PDNS=pdns-server
53 else
54 die $LINENO "PDNS4 Backend plugin backend only supports Ubuntu"
55 fi
56
57 if is_service_enabled mysql; then
58 PDNS+=" pdns-backend-mysql"
59 else
60 die $LINENO "PDNS4 backend only supports MySQL"
61 fi
62
63 install_package $PDNS
64 sudo rm -rf $POWERDNS_CFG_DIR/pdns.d
65}
66
67# configure_designate_backend - make configuration changes, including those to other services
68function configure_designate_backend {
69 # Generate Designate pool.yaml file
70 sudo tee $DESIGNATE_CONF_DIR/pools.yaml > /dev/null <<EOF
71---
72- name: default
73 description: DevStack PowerDNS Pool
74 attributes: {}
75
76 ns_records:
77 - hostname: $DESIGNATE_DEFAULT_NS_RECORD
78 priority: 1
79
80 nameservers:
81 - host: $DESIGNATE_SERVICE_HOST
82 port: $DESIGNATE_SERVICE_PORT_DNS
83
84 targets:
85 - type: pdns4
86 description: PowerDNS Database Cluster
87
88 masters:
89 - host: $DESIGNATE_SERVICE_HOST
90 port: $DESIGNATE_SERVICE_PORT_MDNS
91
92 options:
93 host: $DESIGNATE_SERVICE_HOST
94 port: $DESIGNATE_SERVICE_PORT_DNS
95 api_endpoint: http://$DESIGNATE_SERVICE_HOST:8081
96 api_token: changeme
97EOF
98
99 # Generate PowerDNS pdns.conf file
100 sudo tee $POWERDNS_CFG_DIR/pdns.conf > /dev/null <<EOF
101# General Config
102setgid=pdns
103setuid=pdns
104config-dir=$POWERDNS_CFG_DIR
105socket-dir=/var/run
106guardian=yes
107daemon=yes
108disable-axfr=no
109local-address=$DESIGNATE_SERVICE_HOST
110local-port=$DESIGNATE_SERVICE_PORT_DNS
111master=no
112slave=yes
113cache-ttl=0
114query-cache-ttl=0
115negquery-cache-ttl=0
116out-of-zone-additional-processing=no
117webserver=yes
118webserver-address=$DESIGNATE_SERVICE_HOST
119api=yes
120api-key=changeme
121EOF
122
123 if is_service_enabled mysql; then
124 sudo tee -a $POWERDNS_CFG_DIR/pdns.conf > /dev/null <<EOF
125# Launch gmysql backend
126launch=gmysql
127
128# gmysql parameters
129gmysql-host=$DATABASE_HOST
130gmysql-user=$DATABASE_USER
131gmysql-password=$DATABASE_PASSWORD
132gmysql-dbname=designate_pdns
133gmysql-dnssec=yes
134EOF
135 else
136 die $LINENO "PDNS4 backend only supports MySQL"
137 fi
138 restart_service pdns
139}
140
141# init_designate_backend - initialize databases, etc.
142function init_designate_backend {
143 # Stop pdns so that the migration succeeds, if not you get a error
144 # that the schema is still in use.
145 if is_service_enabled postgresql; then
146 stop_designate_backend
147 fi
148
149 # (Re)create designate_pdns database
150 recreate_database designate_pdns utf8
151 if is_service_enabled mysql; then
152 sudo mysql -u root designate_pdns < $DESIGNATE_PLUGINS/backend-pdns4-mysql-db.sql
153 else
154 die $LINENO "PDNS4 backend only supports MySQL"
155 fi
156}
157
158# create_designate_pool_configuration_backend - Perform post-pool config tasks
159function create_designate_pool_configuration_backend {
160 # Init and migrate designate_pdns database
161 :
162}
163
164# start_designate_backend - start any external services
165function start_designate_backend {
166 start_service pdns
167}
168
169
170# stop_designate_backend - stop any external services
171function stop_designate_backend {
172 stop_service pdns
173}
174
175# cleanup_designate_backend - remove transient data and cache
176function cleanup_designate_backend {
177 :
178}
179
180# Restore xtrace
181$DP_PDNS_XTRACE
diff --git a/devstack/designate_plugins/backend-pdns4-mysql-db.sql b/devstack/designate_plugins/backend-pdns4-mysql-db.sql
new file mode 100644
index 0000000..6fc8647
--- /dev/null
+++ b/devstack/designate_plugins/backend-pdns4-mysql-db.sql
@@ -0,0 +1,92 @@
1CREATE TABLE domains (
2 id INT AUTO_INCREMENT,
3 name VARCHAR(255) NOT NULL,
4 master VARCHAR(128) DEFAULT NULL,
5 last_check INT DEFAULT NULL,
6 type VARCHAR(6) NOT NULL,
7 notified_serial INT DEFAULT NULL,
8 account VARCHAR(40) DEFAULT NULL,
9 PRIMARY KEY (id)
10) Engine=InnoDB;
11
12CREATE UNIQUE INDEX name_index ON domains(name);
13
14
15CREATE TABLE records (
16 id INT AUTO_INCREMENT,
17 domain_id INT DEFAULT NULL,
18 name VARCHAR(255) DEFAULT NULL,
19 type VARCHAR(10) DEFAULT NULL,
20 -- Changed to "TEXT", as VARCHAR(65000) is too big for most MySQL installs
21 content TEXT DEFAULT NULL,
22 ttl INT DEFAULT NULL,
23 prio INT DEFAULT NULL,
24 change_date INT DEFAULT NULL,
25 disabled TINYINT(1) DEFAULT 0,
26 ordername VARCHAR(255) BINARY DEFAULT NULL,
27 auth TINYINT(1) DEFAULT 1,
28 PRIMARY KEY (id)
29) Engine=InnoDB;
30
31CREATE INDEX nametype_index ON records(name,type);
32CREATE INDEX domain_id ON records(domain_id);
33CREATE INDEX recordorder ON records (domain_id, ordername);
34
35
36CREATE TABLE supermasters (
37 ip VARCHAR(64) NOT NULL,
38 nameserver VARCHAR(255) NOT NULL,
39 account VARCHAR(40) NOT NULL,
40 PRIMARY KEY (ip, nameserver)
41) Engine=InnoDB;
42
43
44CREATE TABLE comments (
45 id INT AUTO_INCREMENT,
46 domain_id INT NOT NULL,
47 name VARCHAR(255) NOT NULL,
48 type VARCHAR(10) NOT NULL,
49 modified_at INT NOT NULL,
50 account VARCHAR(40) NOT NULL,
51 -- Changed to "TEXT", as VARCHAR(65000) is too big for most MySQL installs
52 comment TEXT NOT NULL,
53 PRIMARY KEY (id)
54) Engine=InnoDB;
55
56CREATE INDEX comments_domain_id_idx ON comments (domain_id);
57CREATE INDEX comments_name_type_idx ON comments (name, type);
58CREATE INDEX comments_order_idx ON comments (domain_id, modified_at);
59
60
61CREATE TABLE domainmetadata (
62 id INT AUTO_INCREMENT,
63 domain_id INT NOT NULL,
64 kind VARCHAR(32),
65 content TEXT,
66 PRIMARY KEY (id)
67) Engine=InnoDB;
68
69CREATE INDEX domainmetadata_idx ON domainmetadata (domain_id, kind);
70
71
72CREATE TABLE cryptokeys (
73 id INT AUTO_INCREMENT,
74 domain_id INT NOT NULL,
75 flags INT NOT NULL,
76 active BOOL,
77 content TEXT,
78 PRIMARY KEY(id)
79) Engine=InnoDB;
80
81CREATE INDEX domainidindex ON cryptokeys(domain_id);
82
83
84CREATE TABLE tsigkeys (
85 id INT AUTO_INCREMENT,
86 name VARCHAR(255),
87 algorithm VARCHAR(50),
88 secret VARCHAR(255),
89 PRIMARY KEY (id)
90) Engine=InnoDB;
91
92CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm);