diff --git a/manifests/params.pp b/manifests/params.pp index 8241899..2ff6e71 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -26,6 +26,11 @@ default => 'pdns-backend-mysql' } + $package_sqlite = $::operatingsystem ? { + /(?i:centos|redhat|amazon)/ => 'pdns-backend-sqlite', + default => 'pdns-backend-sqlite' + } + $package_ldap = $::operatingsystem ? { /(?i:centos|redhat|amazon)/ => 'pdns-backend-ldap', default => 'pdns-backend-ldap' @@ -46,6 +51,11 @@ default => '/etc/powerdns/pdns.d/pdns.local.gmysql.conf' } + $sqlite_cfg_path = $::operatingsystem ? { + /(?i:centos|redhat|amazon)/ => '/etc/pdns/pdns.conf', + default => '/etc/powerdns/pdns.d/pdns.local.gsqlite3.conf' + } + $ldap_cfg_path = $::operatingsystem ? { /(?i:centos|redhat|amazon)/ => '/etc/pdns/pdns.conf', default => '/etc/powerdns/pdns.d/pdns.local.ldap.conf' diff --git a/manifests/recursor.pp b/manifests/recursor.pp index efbe2a0..df05156 100644 --- a/manifests/recursor.pp +++ b/manifests/recursor.pp @@ -8,6 +8,7 @@ # configs used into the template: # forward_zones # forward_zones_recurse +# allow_from # local_address # local_port # log_common_errors @@ -25,10 +26,12 @@ # class powerdns::recursor( $package = $powerdns::params::package_recursor, + $recursor_cfg_path = $powerdns::params::recursor_cfg_path, $ensure = 'present', $source = '', $forward_zones = undef, $forward_zones_recurse = undef, + $allow_from = undef, $local_address = '127.0.0.1', $local_port = '53', $log_common_errors = 'yes', @@ -60,7 +63,7 @@ source => $package_source } - file { $powerdns::params::recursor_cfg_path: + file { $recursor_cfg_path: ensure => $ensure, owner => root, group => root, diff --git a/manifests/sqlite.pp b/manifests/sqlite.pp new file mode 100644 index 0000000..63213f7 --- /dev/null +++ b/manifests/sqlite.pp @@ -0,0 +1,49 @@ +# Public: Install the powerdns sqlite backend +# +# package - which package to install +# ensure - ensure mysql backend to be present or absent +# source - where to get the package from +# user - which user powerdns should connect as +# password - which password to use with user +# host - host to connect to +# port - port to connect to +# dbname - which database to use +# dnssec - enable or disable dnssec either yes or no +# +class powerdns::sqlite( + $package = $powerdns::params::package_sqlite, + $ensure = 'present', + $source = '', + $dnssec = 'yes', + $database_path = "/etc/pdns/pdns.db", + $sqlite_synchronous = 'off', +) inherits powerdns::params { + + $package_source = $source ? { + '' => undef, + default => $source + } + + $package_provider = $source ? { + '' => undef, + default => $powerdns::params::package_provider + } + + package { $package: + ensure => $ensure, + require => Package[$powerdns::params::package], + provider => $package_provider, + source => $package_source + } + + file { $powerdns::params::sqlite_cfg_path: + ensure => $ensure, + owner => root, + group => root, + mode => '0600', + backup => '.bak', + content => template('powerdns/pdns.sqlite.local.erb'), + notify => Service['pdns'], + require => Package[$powerdns::params::package], + } +} diff --git a/metadata.json b/metadata.json index 18c4f90..df67a9e 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "antonlindstrom-powerdns", - "version": "0.0.5", + "version": "0.0.6", "author": "Anton Lindstrom", "summary": "Module for managing PowerDNS", "license": "GPLv2", diff --git a/templates/pdns.conf.erb b/templates/pdns.conf.erb index e69de29..07c049c 100644 --- a/templates/pdns.conf.erb +++ b/templates/pdns.conf.erb @@ -0,0 +1 @@ +<%= $cfg_include_name %>=<%= $cfg_include_path %> diff --git a/templates/pdns.sqlite.local.erb b/templates/pdns.sqlite.local.erb new file mode 100644 index 0000000..997ab74 --- /dev/null +++ b/templates/pdns.sqlite.local.erb @@ -0,0 +1,20 @@ +# SQLite Configuration +# +# Managed by Puppet +# +# Launch gmysql backend +launch=gsqlite3 + +# gsqlite3 parameters +gsqlite3-database=<%= @database_path %> + +<% if @synchronous %> +gsqlite3-pragma-synchronous=<%= @synchronous %> +<% end %> + +gsqlite3-dnssec=<%= @dnssec %> + +<% if @osfamily == "RedHat" %> +<%= @cfg_include_name %>=<%= @cfg_include_path %> +<% end %> + diff --git a/templates/recursor.conf.erb b/templates/recursor.conf.erb index f0bd6ba..c3ffd0a 100644 --- a/templates/recursor.conf.erb +++ b/templates/recursor.conf.erb @@ -8,6 +8,9 @@ # allow-from If set, only allow these comma separated netmasks to recurse # # allow-from=127.0.0.0/8, 10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, ::1/128, fe80::/10 +<%- if @allow_from -%> +allow-from=<%= @allow_from.join(',') %> +<%- end -%> ################################# # allow-from-file If set, load allowed netmasks from this file