Merge pull request #24 from blkperl/fix_tests
Puppet lint fixes and test typo
This commit is contained in:
commit
a6f2e257c9
19 changed files with 84 additions and 84 deletions
|
@ -48,7 +48,7 @@ class postgresql::config(
|
|||
# to the "beforeservice" and "afterservice" classes, and ensure
|
||||
# the proper ordering.
|
||||
|
||||
class { "postgresql::config::beforeservice":
|
||||
class { 'postgresql::config::beforeservice':
|
||||
ip_mask_deny_postgres_user => $ip_mask_deny_postgres_user,
|
||||
ip_mask_allow_all_users => $ip_mask_allow_all_users,
|
||||
listen_addresses => $listen_addresses,
|
||||
|
@ -59,7 +59,7 @@ class postgresql::config(
|
|||
manage_redhat_firewall => $manage_redhat_firewall,
|
||||
}
|
||||
|
||||
class { "postgresql::config::afterservice":
|
||||
class { 'postgresql::config::afterservice':
|
||||
postgres_password => $postgres_password,
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class postgresql::config::afterservice(
|
|||
# for pg_hba.conf.
|
||||
exec { 'set_postgres_postgrespw':
|
||||
# This command works w/no password because we run it as postgres system user
|
||||
command => "psql -c \"ALTER ROLE postgres PASSWORD '$postgres_password'\"",
|
||||
command => "psql -c \"ALTER ROLE postgres PASSWORD '${postgres_password}'\"",
|
||||
user => $postgresql::params::user,
|
||||
group => $postgresql::params::group,
|
||||
logoutput => true,
|
||||
|
@ -37,7 +37,7 @@ class postgresql::config::afterservice(
|
|||
# a password. We specify the password via the PGPASSWORD environment variable. If
|
||||
# the password is correct (current), this command will exit with an exit code of 0,
|
||||
# which will prevent the main command from running.
|
||||
unless => "env PGPASSWORD=\"$postgres_password\" psql -h localhost -c 'select 1' > /dev/null",
|
||||
unless => "env PGPASSWORD=\"${postgres_password}\" psql -h localhost -c 'select 1' > /dev/null",
|
||||
path => '/usr/bin:/usr/local/bin:/bin',
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ class postgresql::config::beforeservice(
|
|||
file { 'pg_hba.conf':
|
||||
ensure => file,
|
||||
path => $pg_hba_conf_path,
|
||||
content => template("postgresql/pg_hba.conf.erb"),
|
||||
content => template('postgresql/pg_hba.conf.erb'),
|
||||
notify => Service['postgresqld'],
|
||||
}
|
||||
|
||||
|
@ -73,18 +73,18 @@ class postgresql::config::beforeservice(
|
|||
# an out-of-the-box firewall configuration that seems trickier to manage
|
||||
# TODO: get rid of hard-coded port
|
||||
if ($manage_redhat_firewall and $firewall_supported) {
|
||||
exec { "postgresql-persist-firewall":
|
||||
command => $persist_firewall_command,
|
||||
exec { 'postgresql-persist-firewall':
|
||||
command => $persist_firewall_command,
|
||||
refreshonly => true,
|
||||
}
|
||||
|
||||
Firewall {
|
||||
notify => Exec["postgresql-persist-firewall"]
|
||||
notify => Exec['postgresql-persist-firewall']
|
||||
}
|
||||
|
||||
firewall { '5432 accept - postgres':
|
||||
port => '5432',
|
||||
proto => 'tcp',
|
||||
port => '5432',
|
||||
proto => 'tcp',
|
||||
action => 'accept',
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,25 +20,25 @@
|
|||
# needs to be moved over to ruby, and add support for ensurable.
|
||||
|
||||
define postgresql::database(
|
||||
$dbname = $title,
|
||||
$dbname = $title,
|
||||
$charset = 'UTF8')
|
||||
{
|
||||
require postgresql::params
|
||||
|
||||
if ($::postgres_default_version != "8.1") {
|
||||
$locale_option = "--locale=C"
|
||||
if ($::postgres_default_version != '8.1') {
|
||||
$locale_option = '--locale=C'
|
||||
}
|
||||
|
||||
$createdb_command = "${postgresql::params::createdb_path} --template=template0 --encoding '$charset' $locale_option '$dbname'"
|
||||
$createdb_command = "${postgresql::params::createdb_path} --template=template0 --encoding '${charset}' ${locale_option} '${dbname}'"
|
||||
|
||||
exec { $createdb_command :
|
||||
unless => "${postgresql::params::psql_path} --command=\"SELECT datname FROM pg_database WHERE datname=\'$dbname\' \" --pset=tuples_only | grep -q $dbname",
|
||||
unless => "${postgresql::params::psql_path} --command=\"SELECT datname FROM pg_database WHERE datname=\'${dbname}\' \" --pset=tuples_only | grep -q ${dbname}",
|
||||
user => 'postgres',
|
||||
}
|
||||
|
||||
# This will prevent users from connecting to the database unless they've been
|
||||
# granted privileges.
|
||||
postgresql::psql {"REVOKE CONNECT ON DATABASE $dbname FROM public":
|
||||
postgresql::psql {"REVOKE CONNECT ON DATABASE ${dbname} FROM public":
|
||||
db => 'postgres',
|
||||
user => 'postgres',
|
||||
unless => 'SELECT 1 where 1 = 0',
|
||||
|
|
|
@ -30,8 +30,8 @@ define postgresql::database_grant(
|
|||
$privilege,
|
||||
$db,
|
||||
$role,
|
||||
$psql_db = 'postgres',
|
||||
$psql_user='postgres'
|
||||
$psql_db = 'postgres',
|
||||
$psql_user ='postgres'
|
||||
) {
|
||||
|
||||
# TODO: FIXME: only works on databases, due to using has_database_privilege
|
||||
|
@ -49,10 +49,10 @@ define postgresql::database_grant(
|
|||
default => $privilege,
|
||||
}
|
||||
|
||||
postgresql::psql {"GRANT $privilege ON database $db TO \"$role\"":
|
||||
postgresql::psql { "GRANT ${privilege} ON database ${db} TO \"${role}\"":
|
||||
db => $psql_db,
|
||||
user => $psql_user,
|
||||
unless => "SELECT 1 WHERE has_database_privilege('$role', '$db', '$unless_privilege')",
|
||||
unless => "SELECT 1 WHERE has_database_privilege('${role}', '${db}', '${unless_privilege}')",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,14 +38,14 @@
|
|||
#
|
||||
|
||||
define postgresql::database_user(
|
||||
$user=$title,
|
||||
$password_hash,
|
||||
$db = 'postgres',
|
||||
$createdb=false,
|
||||
$superuser=false,
|
||||
$createrole=false
|
||||
$createdb = false,
|
||||
$createrole = false,
|
||||
$db = 'postgres',
|
||||
$superuser = false,
|
||||
$user = $title
|
||||
) {
|
||||
postgresql::role {$user:
|
||||
postgresql::role { $user:
|
||||
db => $db,
|
||||
password_hash => $password_hash,
|
||||
login => true,
|
||||
|
|
|
@ -46,7 +46,7 @@ define postgresql::db (
|
|||
require => Class['postgresql::server'],
|
||||
}
|
||||
|
||||
postgresql::database_user { "${user}":
|
||||
postgresql::database_user { $user:
|
||||
# TODO: ensure is not yet supported
|
||||
#ensure => present,
|
||||
password_hash => $password,
|
||||
|
@ -59,7 +59,7 @@ define postgresql::db (
|
|||
db => $name,
|
||||
role => $user,
|
||||
#provider => 'postgresql',
|
||||
require => Postgresql::Database_user["${user}"],
|
||||
require => Postgresql::Database_user[$user],
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class postgresql::devel(
|
|||
require postgresql
|
||||
|
||||
package { 'postgresql_devel':
|
||||
name => $package_name,
|
||||
ensure => $package_ensure,
|
||||
name => $package_name,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ class postgresql (
|
|||
) inherits postgresql::params {
|
||||
|
||||
package { 'postgresql_client':
|
||||
name => $package_name,
|
||||
ensure => $package_ensure,
|
||||
name => $package_name,
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,17 +17,17 @@
|
|||
# limitations under the License.
|
||||
|
||||
class postgresql::initdb(
|
||||
$datadir = $postgresql::params::datadir,
|
||||
$datadir = $postgresql::params::datadir,
|
||||
$encoding = 'UTF8',
|
||||
$group = 'postgres',
|
||||
$initdb_path = $postgresql::params::initdb_path,
|
||||
$user = 'postgres',
|
||||
$group = 'postgres',
|
||||
$encoding = 'UTF8',
|
||||
$options=''
|
||||
$options = '',
|
||||
$user = 'postgres'
|
||||
) inherits postgresql::params {
|
||||
|
||||
exec {"${initdb_path} --encoding '$encoding' --pgdata '$datadir'":
|
||||
exec { "${initdb_path} --encoding '${encoding}' --pgdata '${datadir}'":
|
||||
creates => "${datadir}/PG_VERSION",
|
||||
user => "$user",
|
||||
group => "$group",
|
||||
user => $user,
|
||||
group => $group,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,14 +57,14 @@ class postgresql::params {
|
|||
'Debian': {
|
||||
case $::operatingsystem {
|
||||
'Debian': {
|
||||
$service_name = "postgresql"
|
||||
$service_name = 'postgresql'
|
||||
}
|
||||
|
||||
'Ubuntu': {
|
||||
case $::lsbmajdistrelease {
|
||||
# thanks, ubuntu
|
||||
'10': { $service_name = "postgresql-${::postgres_default_version}" }
|
||||
default: { $service_name = "postgresql" }
|
||||
default: { $service_name = 'postgresql' }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
# limitations under the License.
|
||||
|
||||
define postgresql::psql(
|
||||
$command = $title,
|
||||
$unless,
|
||||
$db,
|
||||
$user = 'postgres',
|
||||
$refreshonly = false
|
||||
$unless,
|
||||
$command = $title,
|
||||
$refreshonly = false,
|
||||
$user = 'postgres'
|
||||
) {
|
||||
|
||||
require postgresql::params
|
||||
|
@ -30,19 +30,19 @@ define postgresql::psql(
|
|||
# Need a lexer, preferably a ruby SQL parser to catch errors at catalog time
|
||||
# Possibly https://github.com/omghax/sql ?
|
||||
|
||||
if ($::postgres_default_version != "8.1") {
|
||||
$no_password_option = "--no-password"
|
||||
if ($::postgres_default_version != '8.1') {
|
||||
$no_password_option = '--no-password'
|
||||
}
|
||||
|
||||
$psql = "${postgresql::params::psql_path} $no_password_option --tuples-only --quiet --dbname $db"
|
||||
$psql = "${postgresql::params::psql_path} ${no_password_option} --tuples-only --quiet --dbname ${db}"
|
||||
$quoted_command = regsubst($command, '"', '\\"', 'G')
|
||||
$quoted_unless = regsubst($unless, '"', '\\"', 'G')
|
||||
|
||||
exec {"/bin/echo \"$quoted_command\" | $psql |egrep -v -q '^$'":
|
||||
exec {"/bin/echo \"${quoted_command}\" | ${psql} |egrep -v -q '^$'":
|
||||
cwd => '/tmp',
|
||||
user => $user,
|
||||
returns => 1,
|
||||
unless => "/bin/echo \"$quoted_unless\" | $psql | egrep -v -q '^$'",
|
||||
unless => "/bin/echo \"${quoted_unless}\" | ${psql} | egrep -v -q '^$'",
|
||||
refreshonly => $refreshonly,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
# limitations under the License.
|
||||
|
||||
define postgresql::role(
|
||||
$username=$title,
|
||||
$password_hash,
|
||||
$db='postgres',
|
||||
$login=false,
|
||||
$createrole=false,
|
||||
$createdb=false,
|
||||
$superuser=false
|
||||
$createdb = false,
|
||||
$createrole = false,
|
||||
$db = 'postgres',
|
||||
$login = false,
|
||||
$superuser = false,
|
||||
$username = $title
|
||||
) {
|
||||
|
||||
$login_sql = $login ? { true => 'LOGIN' , default => 'NOLOGIN' }
|
||||
|
@ -32,9 +32,9 @@ define postgresql::role(
|
|||
$superuser_sql = $superuser ? { true => 'SUPERUSER' , default => 'NOSUPERUSER' }
|
||||
|
||||
# TODO: FIXME: Will not correct the superuser / createdb / createrole / login status of a role that already exists
|
||||
postgresql::psql {"CREATE ROLE \"${username}\" ENCRYPTED PASSWORD '${password_hash}' $login_sql $createrole_sql $createdb_sql $superuser_sql":
|
||||
postgresql::psql {"CREATE ROLE \"${username}\" ENCRYPTED PASSWORD '${password_hash}' ${login_sql} ${createrole_sql} ${createdb_sql} ${superuser_sql}":
|
||||
db => $db,
|
||||
user => 'postgres',
|
||||
unless => "SELECT rolname FROM pg_roles WHERE rolname='$username'",
|
||||
unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}'",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ class postgresql::server (
|
|||
) inherits postgresql::params {
|
||||
|
||||
package { 'postgresql-server':
|
||||
name => $package_name,
|
||||
ensure => $package_ensure,
|
||||
name => $package_name,
|
||||
}
|
||||
|
||||
$config_class = {}
|
||||
|
@ -41,8 +41,8 @@ class postgresql::server (
|
|||
}
|
||||
|
||||
service { 'postgresqld':
|
||||
name => $service_name,
|
||||
ensure => running,
|
||||
name => $service_name,
|
||||
enable => true,
|
||||
require => Package['postgresql-server'],
|
||||
provider => $service_provider,
|
||||
|
|
|
@ -46,11 +46,11 @@
|
|||
|
||||
define postgresql::validate_db_connection(
|
||||
$database_host,
|
||||
$database_port = 5432,
|
||||
$database_username,
|
||||
$database_password,
|
||||
$database_name,
|
||||
$client_package_name = ""
|
||||
$database_password,
|
||||
$database_username,
|
||||
$client_package_name = '',
|
||||
$database_port = 5432
|
||||
) {
|
||||
include postgresql::params
|
||||
|
||||
|
@ -65,18 +65,18 @@ define postgresql::validate_db_connection(
|
|||
# Make sure the postgres client package is installed; we need it for
|
||||
# `psql`.
|
||||
package { 'postgresql-client':
|
||||
name => $package_name,
|
||||
ensure => present,
|
||||
name => $package_name,
|
||||
}
|
||||
|
||||
# TODO: port to ruby
|
||||
$psql = "${postgresql::params::psql_path} --tuples-only --quiet -h $database_host -U $database_username -p $database_port --dbname $database_name"
|
||||
$psql = "${postgresql::params::psql_path} --tuples-only --quiet -h ${database_host} -U ${database_username} -p ${database_port} --dbname ${database_name}"
|
||||
|
||||
$exec_name = "validate postgres connection for $database_host/$database_name"
|
||||
exec {$exec_name:
|
||||
command => "/bin/echo \"SELECT 1\" | $psql",
|
||||
$exec_name = "validate postgres connection for ${database_host}/${database_name}"
|
||||
exec { $exec_name:
|
||||
command => "/bin/echo \"SELECT 1\" | ${psql}",
|
||||
cwd => '/tmp',
|
||||
environment => "PGPASSWORD=$database_password",
|
||||
environment => "PGPASSWORD=${database_password}",
|
||||
logoutput => 'on_failure',
|
||||
require => Package['postgresql-client'],
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
class { 'postgresql::server':
|
||||
config_hash => {
|
||||
'ip_mask_deny_postgres_user' => '0.0.0.0/32',
|
||||
'ip_mask_allow_all_users' => '0.0.0.0/0',
|
||||
'listen_addresses' => '*',
|
||||
'manage_redhat_firewall' => true,
|
||||
'postgres_password' => 'postgres',
|
||||
'ip_mask_allow_all_users' => '0.0.0.0/0',
|
||||
'listen_addresses' => '*',
|
||||
'manage_redhat_firewall' => true,
|
||||
'postgres_password' => 'postgres',
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
class { 'postgresql::server':
|
||||
config_hash => {
|
||||
'ip_mask_allow_all_users' => '0.0.0.0/0',
|
||||
'listen_addresses' => '*',
|
||||
'manage_redhat_firewall' => true,
|
||||
'listen_addresses' => '*',
|
||||
'manage_redhat_firewall' => true,
|
||||
|
||||
#'ip_mask_deny_postgres_user' => '0.0.0.0/32',
|
||||
#'postgres_password' => 'puppet',
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
class { 'postgresql::server':
|
||||
config_hash => {
|
||||
'ip_mask_deny_postgres_user' => '0.0.0.0/32',
|
||||
'ip_mask_allow_all_users' => '0.0.0.0/0',
|
||||
'listen_addresses' => '*',
|
||||
'manage_redhat_firewall' => true,
|
||||
'postgres_password' => 'postgres',
|
||||
'ip_mask_allow_all_users' => '0.0.0.0/0',
|
||||
'listen_addresses' => '*',
|
||||
'manage_redhat_firewall' => true,
|
||||
'postgres_password' => 'postgres',
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
class { 'postgresql::server':
|
||||
config_hash => {
|
||||
'ip_mask_deny_postgres_user' => '0.0.0.0/32',
|
||||
'ip_mask_allow_all_users' => '0.0.0.0/0',
|
||||
'listen_addresses' => '*',
|
||||
'ipv4acls' => ['hostssl all all johndoe 192.168.0.0/24 cert'],
|
||||
'manage_redhat_firewall' => true,
|
||||
'postgres_password' => 'postgres',
|
||||
'ip_mask_allow_all_users' => '0.0.0.0/0',
|
||||
'listen_addresses' => '*',
|
||||
'ipv4acls' => ['hostssl all johndoe 192.168.0.0/24 cert'],
|
||||
'manage_redhat_firewall' => true,
|
||||
'postgres_password' => 'postgres',
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue