Use database schemas provided by PowerDNS
ju5t opened this issue · 3 comments
PowerDNS comes with a ready to use database schema.
- Rename
powerdns::backends::mysql::create_table
topowerdns::backends::mysql::sql
- Don't create temporary sql files anymore. Use the one specified.
- Add a new parameter to
powerdns::params
for the database schema location per OS. - Simplify
powerdns::backends::mysql
so it usespowerdns::backends::mysql::sql
. - Don't forget
unless
to check for existing tables. A single table is probably sufficient.
The schema is stored in /usr/share/doc/pdns-backend-mysql-FULLVERSION/schema.mysql.sql
.
We only specify a minor version, not the patch level. We can't use $::powerdns::version
reliably. The exec
-resource can be changed to provider => 'shell'
so you can use $mysql_schema_file = "/usr/share/doc/pdns-backend-mysql-${version}.*/schema.mysql.sql
but the expansion to 4.1.1 for some reason doesn't work.
Notice: /Stage[main]/Powerdns::Backends::Mysql/Exec[create-powerdns-schema]/returns: /bin/sh: /usr/share/doc/pdns-backend-mysql-4.1.*/schema.mysql.sql: No such file or directory
Error: '/usr/bin/mysql --defaults-file=/root/.my.cnf powerdns < /usr/share/doc/pdns-backend-mysql-4.1.*/schema.mysql.sql' returned 1 instead of one of [0]
Error: /Stage[main]/Powerdns::Backends::Mysql/Exec[create-powerdns-schema]/returns: change from notrun to 0 failed: '/usr/bin/mysql --defaults-file=/root/.my.cnf powerdns < /usr/share/doc/pdns-backend-mysql-4.1.*/schema.mysql.sql' returned 1 instead of one of [0]
Even though the file is there:
# ls -l /usr/share/doc/pdns-backend-mysql-4.1.*/schema.mysql.sql
-rw-r--r-- 1 root root 2982 Feb 16 09:52 /usr/share/doc/pdns-backend-mysql-4.1.1/schema.mysql.sql
Needs some further investigation.
The shell-provider runs:
super(['/bin/sh', '-c', command], check)
Some further testing
[root@centos-72-x64 vagrant]# touch test
[root@centos-72-x64 vagrant]# /bin/sh -c ls /usr/share/doc/pdns-backend-mysql-4.1.*/schema.mysql.sql
test
[root@centos-72-x64 vagrant]# /bin/sh -c 'ls /usr/share/doc/pdns-backend-mysql-4.1.*/schema.mysql.sql'
/usr/share/doc/pdns-backend-mysql-4.1.1/schema.mysql.sql
Not sure yet why it can't find the file during a Puppet run.
It makes more sense to do this from within mysql::db
's sql
-parameter.