From dcc68df155123cd5ce4af59485abf744f11eb2c5 Mon Sep 17 00:00:00 2001 From: Eric Putnam Date: Wed, 24 May 2017 10:34:25 -0700 Subject: [PATCH] (MODULES-4973) rip out data in modules this module is not able to find a value for `$keyserver` when it is included in postgresql, as stated in the ticket. this changes the module back to using the params.pp model. we can revisit data in modules once LTS moves up from 4.7.0. for now, we need the compatibility. --- data/Debian-6.0.yaml | 5 - data/Debian.yaml | 4 - data/Ubuntu-10.04.yaml | 4 - data/Ubuntu-12.04.yaml | 4 - data/Ubuntu-14.04.yaml | 4 - data/Ubuntu.yaml | 4 - data/common.yaml | 11 -- hiera.yaml | 22 --- manifests/init.pp | 54 +++---- manifests/params.pp | 319 +++++++++++++++++++++++++++++++++++++++++ metadata.json | 2 +- 11 files changed, 347 insertions(+), 86 deletions(-) delete mode 100644 data/Debian-6.0.yaml delete mode 100644 data/Debian.yaml delete mode 100644 data/Ubuntu-10.04.yaml delete mode 100644 data/Ubuntu-12.04.yaml delete mode 100644 data/Ubuntu-14.04.yaml delete mode 100644 data/Ubuntu.yaml delete mode 100644 data/common.yaml delete mode 100644 hiera.yaml create mode 100644 manifests/params.pp diff --git a/data/Debian-6.0.yaml b/data/Debian-6.0.yaml deleted file mode 100644 index f03bccdc58..0000000000 --- a/data/Debian-6.0.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -#Squeeze -apt::backports: { location: 'http://httpredir.debian.org/debian-backports', key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', repos: 'main contrib non-free' } -apt::ppa_options: ~ -apt::ppa_package: ~ diff --git a/data/Debian.yaml b/data/Debian.yaml deleted file mode 100644 index 823bc02d04..0000000000 --- a/data/Debian.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -apt::backports: { location: 'http://httpredir.debian.org/debian', key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', repos: 'main contrib non-free' } -apt::ppa_options: ~ -apt::ppa_package: ~ diff --git a/data/Ubuntu-10.04.yaml b/data/Ubuntu-10.04.yaml deleted file mode 100644 index 567548bb9f..0000000000 --- a/data/Ubuntu-10.04.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -#Lucid -apt::ppa_options: ~ -apt::ppa_package: 'python-software-properties' diff --git a/data/Ubuntu-12.04.yaml b/data/Ubuntu-12.04.yaml deleted file mode 100644 index 992cb25668..0000000000 --- a/data/Ubuntu-12.04.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -#Precise -apt::ppa_options: '-y' -apt::ppa_package: 'python-software-properties' diff --git a/data/Ubuntu-14.04.yaml b/data/Ubuntu-14.04.yaml deleted file mode 100644 index d1681642af..0000000000 --- a/data/Ubuntu-14.04.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -#Trusty -apt::ppa_options: '-y' -apt::ppa_package: 'software-properties-common' diff --git a/data/Ubuntu.yaml b/data/Ubuntu.yaml deleted file mode 100644 index ee62a25770..0000000000 --- a/data/Ubuntu.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -apt::backports: { location: 'http://archive.ubuntu.com/ubuntu', key: '630239CC130E1A7FD81A27B140976EAF437D05B5', repos: 'main universe multiverse restricted' } -apt::ppa_options: '-y' -apt::ppa_package: 'python-software-properties' diff --git a/data/common.yaml b/data/common.yaml deleted file mode 100644 index 2ed9e162a3..0000000000 --- a/data/common.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -apt::provider: '/usr/bin/apt-get' -apt::keyserver: 'keyserver.ubuntu.com' -apt::update_defaults: { frequency: 'reluctantly', timeout: ~, tries: ~ } -apt::proxy_defaults: { ensure: ~, host: ~, port: 8080, https: false } -apt::purge_defaults: { sources.list: false, sources.list.d: false, preferences: false, preferences.d: false } -apt::proxy_defaults: { ensure: ~, host: ~, port: 8080, https: false } -apt::include_defaults: { deb: true, src: false } -apt::ppa_options: ~ -apt::ppa_package: ~ -apt::backports: ~ diff --git a/hiera.yaml b/hiera.yaml deleted file mode 100644 index 4bfe502a4a..0000000000 --- a/hiera.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -version: 4 -datadir: data -hierarchy: - - name: "Full Version" - backend: yaml - path: "%{facts.os.name}-%{facts.os.release.full}" - - - name: "Major Version" - backend: yaml - path: "%{facts.os.name}-%{facts.os.release.major}" - - - name: "Distribution Name" - backend: yaml - path: "%{facts.os.name}" - - - name: "Operating System Family" - backend: yaml - path: "%{facts.os.family}" - - - name: "common" - backend: yaml diff --git a/manifests/init.pp b/manifests/init.pp index 5654b3c626..c89c2230cf 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,33 +3,33 @@ # Manage APT (Advanced Packaging Tool) # class apt ( - Hash $update_defaults, - Hash $purge_defaults, - Hash $proxy_defaults, - Hash $include_defaults, - String $provider, - String $keyserver, - Optional[String] $ppa_options, - Optional[String] $ppa_package, - Optional[Hash] $backports, - Hash $confs = {}, - Hash $update = {}, - Hash $purge = {}, - Hash $proxy = {}, - Hash $sources = {}, - Hash $keys = {}, - Hash $ppas = {}, - Hash $pins = {}, - Hash $settings = {}, - String $root = '/etc/apt', - String $sources_list = "${root}/sources.list", - String $sources_list_d = "${root}/sources.list.d", - String $conf_d = "${root}/apt.conf.d", - String $preferences = "${root}/preferences", - String $preferences_d = "${root}/preferences.d", - Hash $config_files = { conf => { path => $conf_d, ext => '' }, pref => { path => $preferences_d, ext => '.pref' }, list => { path => $sources_list_d, ext => '.list' } }, - Hash $source_key_defaults = { 'server' => $keyserver, 'options' => undef, 'content' => undef, 'source' => undef }, -) { + Hash $update_defaults = $apt::params::update_defaults, + Hash $purge_defaults = $apt::params::purge_defaults, + Hash $proxy_defaults = $apt::params::proxy_defaults, + Hash $include_defaults = $apt::params::include_defaults, + String $provider = $apt::params::provider, + String $keyserver = $apt::params::keyserver, + Optional[String] $ppa_options = $apt::params::ppa_options, + Optional[String] $ppa_package = $apt::params::ppa_package, + Optional[Hash] $backports = $apt::params::backports, + Hash $confs = $apt::params::confs, + Hash $update = $apt::params::update, + Hash $purge = $apt::params::purge, + Hash $proxy = $apt::params::proxy, + Hash $sources = $apt::params::sources, + Hash $keys = $apt::params::keys, + Hash $ppas = $apt::params::ppas, + Hash $pins = $apt::params::pins, + Hash $settings = $apt::params::settings, + String $root = $apt::params::root, + String $sources_list = $apt::params::sources_list, + String $sources_list_d = $apt::params::sources_list_d, + String $conf_d = $apt::params::conf_d, + String $preferences = $apt::params::preferences, + String $preferences_d = $apt::params::preferences_d, + Hash $config_files = $apt::params::config_files, + Hash $source_key_defaults = $apt::params::source_key_defaults +) inherits apt::params { if $facts['osfamily'] != 'Debian' { fail('This module only works on Debian or derivatives like Ubuntu') diff --git a/manifests/params.pp b/manifests/params.pp new file mode 100644 index 0000000000..8b30728bda --- /dev/null +++ b/manifests/params.pp @@ -0,0 +1,319 @@ +# PRIVATE CLASS: do not use directly +class postgresql::params inherits postgresql::globals { + $version = $postgresql::globals::globals_version + $postgis_version = $postgresql::globals::globals_postgis_version + $listen_addresses = 'localhost' + $port = 5432 + $log_line_prefix = '%t ' + $ip_mask_deny_postgres_user = '0.0.0.0/0' + $ip_mask_allow_all_users = '127.0.0.1/32' + $ipv4acls = [] + $ipv6acls = [] + $encoding = $postgresql::globals::encoding + $locale = $postgresql::globals::locale + $timezone = $postgresql::globals::timezone + $service_ensure = 'running' + $service_enable = true + $service_manage = true + $service_restart_on_change = true + $service_provider = $postgresql::globals::service_provider + $manage_pg_hba_conf = pick($manage_pg_hba_conf, true) + $manage_pg_ident_conf = pick($manage_pg_ident_conf, true) + $manage_recovery_conf = pick($manage_recovery_conf, false) + $package_ensure = 'present' + $module_workdir = pick($module_workdir,'/tmp') + + # Amazon Linux's OS Family is 'Linux', operating system 'Amazon'. + case $::osfamily { + 'RedHat', 'Linux': { + $link_pg_config = true + $user = pick($user, 'postgres') + $group = pick($group, 'postgres') + $needs_initdb = pick($needs_initdb, true) + $version_parts = split($version, '[.]') + $package_version = "${version_parts[0]}${version_parts[1]}" + + if $version == $postgresql::globals::default_version and $::operatingsystem != 'Amazon' { + $client_package_name = pick($client_package_name, 'postgresql') + $server_package_name = pick($server_package_name, 'postgresql-server') + $contrib_package_name = pick($contrib_package_name,'postgresql-contrib') + $devel_package_name = pick($devel_package_name, 'postgresql-devel') + $java_package_name = pick($java_package_name, 'postgresql-jdbc') + $docs_package_name = pick($docs_package_name, 'postgresql-docs') + $plperl_package_name = pick($plperl_package_name, 'postgresql-plperl') + $plpython_package_name = pick($plpython_package_name, 'postgresql-plpython') + $service_name = pick($service_name, 'postgresql') + $bindir = pick($bindir, '/usr/bin') + $datadir = $::operatingsystem ? { + 'Amazon' => pick($datadir, "/var/lib/pgsql${package_version}/data"), + default => pick($datadir, '/var/lib/pgsql/data'), + } + $confdir = pick($confdir, $datadir) + } else { + $client_package_name = pick($client_package_name, "postgresql${package_version}") + $server_package_name = pick($server_package_name, "postgresql${package_version}-server") + $contrib_package_name = pick($contrib_package_name,"postgresql${package_version}-contrib") + $devel_package_name = pick($devel_package_name, "postgresql${package_version}-devel") + $java_package_name = pick($java_package_name, "postgresql${package_version}-jdbc") + $docs_package_name = pick($docs_package_name, "postgresql${package_version}-docs") + $plperl_package_name = pick($plperl_package_name, "postgresql${package_version}-plperl") + $plpython_package_name = pick($plpython_package_name, "postgresql${package_version}-plpython") + $service_name = $::operatingsystem ? { + 'Amazon' => pick($service_name, "postgresql${version_parts[0]}${version_parts[1]}"), + default => pick($service_name, "postgresql-${version}"), + } + $bindir = $::operatingsystem ? { + 'Amazon' => pick($bindir, '/usr/bin'), + default => pick($bindir, "/usr/pgsql-${version}/bin"), + } + $datadir = $::operatingsystem ? { + 'Amazon' => pick($datadir, "/var/lib/pgsql${package_version}/data"), + default => pick($datadir, "/var/lib/pgsql/${version}/data"), + } + $confdir = pick($confdir, $datadir) + } + $psql_path = pick($psql_path, "${bindir}/psql") + + $service_status = $service_status + $service_reload = "service ${service_name} reload" + $perl_package_name = pick($perl_package_name, 'perl-DBD-Pg') + $python_package_name = pick($python_package_name, 'python-psycopg2') + + if $postgresql::globals::postgis_package_name { + $postgis_package_name = $postgresql::globals::postgis_package_name + } elsif $::operatingsystemrelease =~ /^5\./ { + $postgis_package_name = 'postgis' + } elsif $postgis_version and versioncmp($postgis_version, '2') < 0 { + $postgis_package_name = "postgis${package_version}" + } else { + $postgis_package_name = "postgis2_${package_version}" + } + } + + 'Archlinux': { + $link_pg_config = true + $needs_initdb = pick($needs_initdb, true) + $user = pick($user, 'postgres') + $group = pick($group, 'postgres') + + # Archlinux doesn't have a client-package but has a libs package which + # pulls in postgresql server + $client_package_name = pick($client_package_name, 'postgresql') + $server_package_name = pick($server_package_name, 'postgresql-libs') + $java_package_name = pick($java_package_name, 'postgresql-jdbc') + # Archlinux doesn't have develop packages + $devel_package_name = pick($devel_package_name, 'postgresql-devel') + # Archlinux does have postgresql-contrib but it isn't maintained + $contrib_package_name = pick($contrib_package_name,'undef') + # Archlinux postgresql package provides plperl + $plperl_package_name = pick($plperl_package_name, 'undef') + $plpython_package_name = pick($plpython_package_name, 'undef') + $service_name = pick($service_name, 'postgresql') + $bindir = pick($bindir, '/usr/bin') + $datadir = pick($datadir, '/var/lib/postgres/data') + $confdir = pick($confdir, $datadir) + $psql_path = pick($psql_path, "${bindir}/psql") + + $service_status = $service_status + $service_reload = "systemctl reload ${service_name}" + $python_package_name = pick($python_package_name, 'python-psycopg2') + # Archlinux does not have a perl::DBD::Pg package + $perl_package_name = pick($perl_package_name, 'undef') + } + + 'Debian': { + $link_pg_config = false + $user = pick($user, 'postgres') + $group = pick($group, 'postgres') + + if $postgresql::globals::manage_package_repo == true { + $needs_initdb = pick($needs_initdb, true) + $service_name = pick($service_name, 'postgresql') + } else { + $needs_initdb = pick($needs_initdb, false) + $service_name = $::operatingsystem ? { + 'Debian' => pick($service_name, 'postgresql'), + 'Ubuntu' => $::lsbmajdistrelease ? { + /^10/ => pick($service_name, "postgresql-${version}"), + default => pick($service_name, 'postgresql'), + }, + default => undef + } + } + + $client_package_name = pick($client_package_name, "postgresql-client-${version}") + $server_package_name = pick($server_package_name, "postgresql-${version}") + $contrib_package_name = pick($contrib_package_name, "postgresql-contrib-${version}") + if $postgis_version and versioncmp($postgis_version, '2') < 0 { + $postgis_package_name = pick($postgis_package_name, "postgresql-${version}-postgis") + } else { + $postgis_package_name = pick($postgis_package_name, "postgresql-${version}-postgis-${postgis_version}") + } + $devel_package_name = pick($devel_package_name, 'libpq-dev') + $java_package_name = $::operatingsystem ? { + 'Debian' => $::operatingsystemrelease ? { + /^6/ => pick($java_package_name, 'libpg-java'), + default => pick($java_package_name, 'libpostgresql-jdbc-java'), + }, + default => pick($java_package_name, 'libpostgresql-jdbc-java'), + } + $perl_package_name = pick($perl_package_name, 'libdbd-pg-perl') + $plperl_package_name = pick($plperl_package_name, "postgresql-plperl-${version}") + $plpython_package_name = pick($plpython_package_name, "postgresql-plpython-${version}") + $python_package_name = pick($python_package_name, 'python-psycopg2') + + $bindir = pick($bindir, "/usr/lib/postgresql/${version}/bin") + $datadir = pick($datadir, "/var/lib/postgresql/${version}/main") + $confdir = pick($confdir, "/etc/postgresql/${version}/main") + if $::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '8.0') >= 0 { + # Jessie uses systemd + $service_status = pick($service_status, "/usr/sbin/service ${service_name}@*-main status") + } elsif $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '15.04') >= 0 { + # Ubuntu releases since vivid use systemd + $service_status = pick($service_status, "/usr/sbin/service ${service_name} status") + } else { + $service_status = pick($service_status, "/etc/init.d/${service_name} status | /bin/egrep -q 'Running clusters: .+|online'") + } + $service_reload = "service ${service_name} reload" + $psql_path = pick($psql_path, '/usr/bin/psql') + } + + 'Gentoo': { + $user = pick($user, 'postgres') + $group = pick($group, 'postgres') + + $client_package_name = pick($client_package_name, 'UNSET') + $server_package_name = pick($server_package_name, 'postgresql') + $contrib_package_name = pick_default($contrib_package_name, undef) + $devel_package_name = pick_default($devel_package_name, undef) + $java_package_name = pick($java_package_name, 'jdbc-postgresql') + $perl_package_name = pick($perl_package_name, 'DBD-Pg') + $plperl_package_name = undef + $python_package_name = pick($python_package_name, 'psycopg') + + $service_name = pick($service_name, "postgresql-${version}") + $bindir = pick($bindir, "/usr/lib/postgresql-${version}/bin") + $datadir = pick($datadir, "/var/lib/postgresql/${version}_data") + $confdir = pick($confdir, "/etc/postgresql-${version}") + $service_status = pick($service_status, "systemctl status ${service_name}") + $service_reload = "systemctl reload ${service_name}" + $psql_path = pick($psql_path, "${bindir}/psql") + + $needs_initdb = pick($needs_initdb, true) + } + + 'FreeBSD': { + case $version { + '96': { + $user = pick($user, 'postgres') + $group = pick($group, 'postgres') + $datadir = pick($datadir, "/var/db/postgres/data${version}") + } + default: { + $user = pick($user, 'pgsql') + $group = pick($group, 'pgsql') + $datadir = pick($datadir, '/usr/local/pgsql/data') + } + } + + $link_pg_config = true + $client_package_name = pick($client_package_name, "databases/postgresql${version}-client") + $server_package_name = pick($server_package_name, "databases/postgresql${version}-server") + $contrib_package_name = pick($contrib_package_name, "databases/postgresql${version}-contrib") + $devel_package_name = pick($devel_package_name, 'databases/postgresql-libpqxx3') + $java_package_name = pick($java_package_name, 'databases/postgresql-jdbc') + $perl_package_name = pick($plperl_package_name, 'databases/p5-DBD-Pg') + $plperl_package_name = pick($plperl_package_name, "databases/postgresql${version}-plperl") + $python_package_name = pick($python_package_name, 'databases/py-psycopg2') + + $service_name = pick($service_name, 'postgresql') + $bindir = pick($bindir, '/usr/local/bin') + $confdir = pick($confdir, $datadir) + $service_status = pick($service_status, "/usr/local/etc/rc.d/${service_name} onestatus") + $service_reload = "service ${service_name} reload" + $psql_path = pick($psql_path, "${bindir}/psql") + + $needs_initdb = pick($needs_initdb, true) + } + + 'OpenBSD': { + $user = pick($user, '_postgresql') + $group = pick($group, '_postgresql') + + $client_package_name = pick($client_package_name, 'postgresql-client') + $server_package_name = pick($server_package_name, 'postgresql-server') + $contrib_package_name = pick($contrib_package_name, 'postgresql-contrib') + $devel_package_name = pick($devel_package_name, 'postgresql-client') + $java_package_name = pick($java_package_name, 'postgresql-jdbc') + $perl_package_name = pick($perl_package_name, 'databases/p5-DBD-Pg') + $plperl_package_name = undef + $python_package_name = pick($python_package_name, 'py-psycopg2') + + $service_name = pick($service_name, 'postgresql') + $bindir = pick($bindir, '/usr/local/bin') + $datadir = pick($datadir, '/var/postgresql/data') + $confdir = pick($confdir, $datadir) + $service_status = pick($service_status, "/etc/rc.d/${service_name} check") + $service_reload = "/etc/rc.d/${service_name} reload" + $psql_path = pick($psql_path, "${bindir}/psql") + + $needs_initdb = pick($needs_initdb, true) + } + + 'Suse': { + $link_pg_config = true + $user = pick($user, 'postgres') + $group = pick($group, 'postgres') + + $client_package_name = pick($client_package_name, "postgresql${version}") + $server_package_name = pick($server_package_name, "postgresql${version}-server") + $contrib_package_name = pick($contrib_package_name, "postgresql${version}-contrib") + $devel_package_name = pick($devel_package_name, "postgresql${version}-devel") + $java_package_name = pick($java_package_name, "postgresql${version}-jdbc") + $perl_package_name = pick($plperl_package_name, 'perl-DBD-Pg') + $plperl_package_name = pick($plperl_package_name, "postgresql${version}-plperl") + $python_package_name = pick($python_package_name, 'python-psycopg2') + + $service_name = pick($service_name, 'postgresql') + $bindir = pick($bindir, "/usr/lib/postgresql${version}/bin") + $datadir = pick($datadir, '/var/lib/pgsql/data') + $confdir = pick($confdir, $datadir) + if $::operatingsystem == 'SLES' and versioncmp($::operatingsystemrelease, '11.4') <= 0 { + $service_status = pick($service_status, "/etc/init.d/${service_name} status") + $service_reload = "/etc/init.d/${service_name} reload" + } else { + $service_status = pick($service_status, "systemctl status ${service_name}") + $service_reload = "systemctl reload ${service_name}" + } + $psql_path = pick($psql_path, "${bindir}/psql") + + $needs_initdb = pick($needs_initdb, true) + } + + default: { + $link_pg_config = true + $psql_path = pick($psql_path, "${bindir}/psql") + + # Since we can't determine defaults on our own, we rely on users setting + # parameters with the postgresql::globals class. Here we are checking + # that the mandatory minimum is set for the module to operate. + $err_prefix = "Module ${module_name} does not provide defaults for osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}; please specify a value for ${module_name}::globals::" + if ($needs_initdb == undef) { fail("${err_prefix}needs_initdb") } + if ($service_name == undef) { fail("${err_prefix}service_name") } + if ($client_package_name == undef) { fail("${err_prefix}client_package_name") } + if ($server_package_name == undef) { fail("${err_prefix}server_package_name") } + if ($bindir == undef) { fail("${err_prefix}bindir") } + if ($datadir == undef) { fail("${err_prefix}datadir") } + if ($confdir == undef) { fail("${err_prefix}confdir") } + } + } + + $validcon_script_path = pick($validcon_script_path, '/usr/local/bin/validate_postgresql_connection.sh') + $initdb_path = pick($initdb_path, "${bindir}/initdb") + $pg_hba_conf_path = pick($pg_hba_conf_path, "${confdir}/pg_hba.conf") + $pg_hba_conf_defaults = pick($pg_hba_conf_defaults, true) + $pg_ident_conf_path = pick($pg_ident_conf_path, "${confdir}/pg_ident.conf") + $postgresql_conf_path = pick($postgresql_conf_path, "${confdir}/postgresql.conf") + $recovery_conf_path = pick($recovery_conf_path, "${datadir}/recovery.conf") + $default_database = pick($default_database, 'postgres') +} diff --git a/metadata.json b/metadata.json index f4fadeb4c4..562f0436e4 100644 --- a/metadata.json +++ b/metadata.json @@ -10,7 +10,7 @@ "dependencies": [ {"name":"puppetlabs/stdlib","version_requirement":">= 4.16.0 < 5.0.0"} ], - "data_provider": "hiera", + "data_provider": null, "operatingsystem_support": [ { "operatingsystem": "Debian",