Skip to content

Commit

Permalink
Merge pull request #157 from bastelfreak/postgresql
Browse files Browse the repository at this point in the history
puppetlabs/postgresql: Require 9.x
  • Loading branch information
ju5t authored Aug 22, 2023
2 parents fbba61f + b57a719 commit 0623f38
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 17 deletions.
8 changes: 5 additions & 3 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ fixtures:
ref: "3.0.1"
stdlib:
repo: "puppetlabs/stdlib"
ref: "5.2.0"
ref: "9.3.0"
mysql:
repo: "puppetlabs/mysql"
ref: "10.9.0"
ref: "15.0.0"
postgresql:
repo: "puppetlabs/postgresql"
ref: "6.4.0"
ref: "9.1.0"
concat:
repo: "puppetlabs/concat"
ref: "5.3.0"
Expand All @@ -26,5 +26,7 @@ fixtures:
repo: "puppetlabs/augeas_core"
puppet_version: ">= 6.0.0"
ref: "1.0.4"
repositories:
systemd: 'https://github.com/voxpupuli/puppet-systemd'
symlinks:
powerdns: "#{source_dir}"
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,14 @@ We believe it also on other operating systems such as:
* Scientific Linux
* Arch Linux

The packages on EL are a bit stupid. The schemas have the exact PowerDNS version
hardcoded in the paths. The main class has three parameters where you can adjust
it:

* `mysql_schema_file`
* `pgsql_schema_file`
* `sqlite_schema_file`

## Development

We strongly believe in the power of open source. This module is our way
Expand Down
2 changes: 1 addition & 1 deletion manifests/authoritative.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
ensure => $package_ensure,
}

ensure_packages($install_packages)
stdlib::ensure_packages($install_packages)

# install the right backend
case $::powerdns::backend {
Expand Down
6 changes: 5 additions & 1 deletion manifests/backends/postgresql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@
}

if $::powerdns::backend_create_tables {
$password_hash = $db_password ? {
Undef => undef,
default => postgresql_password($::powerdns::db_username, $_db_password),
}
postgresql::server::db { $::powerdns::db_name:
user => $::powerdns::db_username,
password => postgresql_password($::powerdns::db_username, $_db_password),
password => $password_hash,
require => Package[$::powerdns::params::pgsql_backend_package_name],
}

Expand Down
15 changes: 12 additions & 3 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@

case $facts['os']['family'] {
'RedHat': {
case $facts['os']['release']['major'] {
'7': {
$mysql_schema_file = '/usr/share/doc/pdns-backend-mysql-4.1.14/schema.mysql.sql'
$pgsql_schema_file = '/usr/share/doc/pdns-backend-postgresql-4.1.14/schema.pgsql.sql'
$sqlite_schema_file = '/usr/share/doc/pdns-backend-sqlite-4.1.14/schema.sqlite.sql'
}
default: {
$mysql_schema_file = '/usr/share/doc/pdns-backend-mysql-4.8.1/schema.mysql.sql'
$pgsql_schema_file = '/usr/share/doc/pdns-backend-postgresql-4.8.1/schema.pgsql.sql'
$sqlite_schema_file = '/usr/share/doc/pdns-backend-sqlite-4.8.1/schema.sqlite.sql'
}
}
$authoritative_package = 'pdns'
$authoritative_service = 'pdns'
$authoritative_config = '/etc/pdns/pdns.conf'
Expand All @@ -14,9 +26,6 @@
$ldap_backend_package_name = 'pdns-backend-ldap'
$pgsql_backend_package_name = 'pdns-backend-postgresql'
$sqlite_backend_package_name = 'pdns-backend-sqlite'
$mysql_schema_file = '/usr/share/doc/pdns-backend-mysql-4.*.*/schema.mysql.sql'
$pgsql_schema_file = '/usr/share/doc/pdns-backend-postgresql-4.*.*/schema.pgsql.sql'
$sqlite_schema_file = '/usr/share/doc/pdns-backend-sqlite-4.*.*/schema.sqlite.sql'
$sqlite_package_name = 'sqlite'
$authoritative_configdir = '/etc/pdns'
$recursor_package = 'pdns-recursor'
Expand Down
2 changes: 1 addition & 1 deletion manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Yumrepo['powerdns-recursor'] -> Package <| title == $::powerdns::params::recursor_package |>

if versioncmp($::operatingsystemmajrelease, '7') <= 0 {
ensure_packages('yum-plugin-priorities')
stdlib::ensure_packages('yum-plugin-priorities')

Package['yum-plugin-priorities']
-> Yumrepo['powerdns']
Expand Down
6 changes: 3 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">=4.3.2 < 9.0.0"
"version_requirement": ">= 9.0.0 < 10.0.0"
},
{
"name": "puppetlabs/mysql",
"version_requirement": ">=3.4.0 < 15.0.0"
"version_requirement": ">= 15.0.0 < 16.0.0"
},
{
"name": "puppetlabs/postgresql",
"version_requirement": ">=6.4.0 < 10.0.0"
"version_requirement": ">= 9.1.0 < 10.0.0"
},
{
"name": "puppetlabs/apt",
Expand Down
2 changes: 2 additions & 0 deletions pdk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
ignore: []
17 changes: 12 additions & 5 deletions spec/classes/powerdns_init_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
override_facts = {
root_home: '/root'
root_home: '/root',
service_provider: 'systemd'
}

require 'spec_helper'
Expand All @@ -11,17 +12,23 @@
facts.merge(override_facts)
end

case facts[:osfamily]
case facts[:os]['family']
when 'RedHat'
authoritative_package_name = 'pdns'
authoritative_service_name = 'pdns'
authoritative_config = '/etc/pdns/pdns.conf'
mysql_schema_file = '/usr/share/doc/pdns-backend-mysql-4.*.*/schema.mysql.sql'
if facts[:os]['release']['major'].to_i == 7
mysql_schema_file = '/usr/share/doc/pdns-backend-mysql-4.1.14/schema.mysql.sql'
pgsql_schema_file = '/usr/share/doc/pdns-backend-postgresql-4.1.14/schema.pgsql.sql'
sqlite_schema_file = '/usr/share/doc/pdns-backend-sqlite-4.1.14/schema.sqlite.sql'
else
mysql_schema_file = '/usr/share/doc/pdns-backend-mysql-4.8.1/schema.mysql.sql'
pgsql_schema_file = '/usr/share/doc/pdns-backend-postgresql-4.8.1/schema.pgsql.sql'
sqlite_schema_file = '/usr/share/doc/pdns-backend-sqlite-4.8.1/schema.sqlite.sql'
end
pgsql_backend_package_name = 'pdns-backend-postgresql'
pgsql_schema_file = '/usr/share/doc/pdns-backend-postgresql-4.*.*/schema.pgsql.sql'
sqlite_backend_package_name = 'pdns-backend-sqlite'
sqlite_binary_package_name = 'sqlite'
sqlite_schema_file = '/usr/share/doc/pdns-backend-sqlite-4.*.*/schema.sqlite.sql'
recursor_package_name = 'pdns-recursor'
recursor_service_name = 'pdns-recursor'
when 'Debian'
Expand Down

0 comments on commit 0623f38

Please sign in to comment.