Coding style fixes
This commit is contained in:
parent
aa1cd44c25
commit
10cb81468e
17 changed files with 100 additions and 67 deletions
23
.project
Normal file
23
.project
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>postgresql</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.cloudsmith.geppetto.pp.dsl.ui.puppetNature</nature>
|
||||||
|
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
|
@ -5,7 +5,7 @@ author 'Inkling/Puppet Labs'
|
||||||
description 'PostgreSQL defined resource types'
|
description 'PostgreSQL defined resource types'
|
||||||
summary 'PostgreSQL defined resource types'
|
summary 'PostgreSQL defined resource types'
|
||||||
license 'Apache'
|
license 'Apache'
|
||||||
project_page 'https://github.com/puppetlabs/puppet-postgresql/issues'
|
project_page 'https://github.com/puppetlabs/puppet-postgresql'
|
||||||
|
|
||||||
dependency 'puppetlabs/stdlib', '>=3.2.0 <4.0.0'
|
dependency 'puppetlabs/stdlib', '>=3.2.0 <4.0.0'
|
||||||
dependency 'puppetlabs/firewall', '>= 0.0.4'
|
dependency 'puppetlabs/firewall', '>= 0.0.4'
|
||||||
|
|
|
@ -73,15 +73,15 @@ class postgresql::config::beforeservice(
|
||||||
# managing their own settings in a second conf file.
|
# managing their own settings in a second conf file.
|
||||||
file_line { 'postgresql.conf#include':
|
file_line { 'postgresql.conf#include':
|
||||||
path => $postgresql_conf_path,
|
path => $postgresql_conf_path,
|
||||||
line => "include 'postgresql_puppet_extras.conf'",
|
line => 'include \'postgresql_puppet_extras.conf\'',
|
||||||
notify => Service['postgresqld'],
|
notify => Service['postgresqld'],
|
||||||
}
|
}
|
||||||
|
|
||||||
# Since we're adding an "include" for this extras config file, we need
|
# Since we're adding an "include" for this extras config file, we need
|
||||||
# to make sure it exists.
|
# to make sure it exists.
|
||||||
exec { "touch `dirname $postgresql_conf_path`/postgresql_puppet_extras.conf" :
|
exec { "touch `dirname ${postgresql_conf_path}`/postgresql_puppet_extras.conf" :
|
||||||
path => "/usr/bin:/bin",
|
path => '/usr/bin:/bin',
|
||||||
unless => "[ -f `dirname $postgresql_conf_path`/postgresql_puppet_extras.conf ]"
|
unless => "[ -f `dirname ${postgresql_conf_path}`/postgresql_puppet_extras.conf ]"
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: is this a reasonable place for this firewall stuff?
|
# TODO: is this a reasonable place for this firewall stuff?
|
||||||
|
|
|
@ -34,10 +34,10 @@ define postgresql::database(
|
||||||
undef => '',
|
undef => '',
|
||||||
default => "--locale=${locale}",
|
default => "--locale=${locale}",
|
||||||
}
|
}
|
||||||
$public_revoke_privilege = "CONNECT"
|
$public_revoke_privilege = 'CONNECT'
|
||||||
} else {
|
} else {
|
||||||
$locale_option = ""
|
$locale_option = ''
|
||||||
$public_revoke_privilege = "ALL"
|
$public_revoke_privilege = 'ALL'
|
||||||
}
|
}
|
||||||
|
|
||||||
$createdb_command_tmp = "${postgresql::params::createdb_path} --template=template0 --encoding '${charset}' ${locale_option} '${dbname}'"
|
$createdb_command_tmp = "${postgresql::params::createdb_path} --template=template0 --encoding '${charset}' ${locale_option} '${dbname}'"
|
||||||
|
@ -49,9 +49,9 @@ define postgresql::database(
|
||||||
$createdb_command = "${createdb_command_tmp} --tablespace='${tablespace}'"
|
$createdb_command = "${createdb_command_tmp} --tablespace='${tablespace}'"
|
||||||
}
|
}
|
||||||
|
|
||||||
postgresql_psql { "Check for existence of db '$dbname'":
|
postgresql_psql { "Check for existence of db '${dbname}'":
|
||||||
command => "SELECT 1",
|
command => 'SELECT 1',
|
||||||
unless => "SELECT datname FROM pg_database WHERE datname='$dbname'",
|
unless => "SELECT datname FROM pg_database WHERE datname='${dbname}'",
|
||||||
cwd => $postgresql::params::datadir,
|
cwd => $postgresql::params::datadir,
|
||||||
require => Class['postgresql::server']
|
require => Class['postgresql::server']
|
||||||
} ~>
|
} ~>
|
||||||
|
@ -65,7 +65,7 @@ define postgresql::database(
|
||||||
|
|
||||||
# This will prevent users from connecting to the database unless they've been
|
# This will prevent users from connecting to the database unless they've been
|
||||||
# granted privileges.
|
# granted privileges.
|
||||||
postgresql_psql {"REVOKE ${public_revoke_privilege} ON DATABASE $dbname FROM public":
|
postgresql_psql {"REVOKE ${public_revoke_privilege} ON DATABASE ${dbname} FROM public":
|
||||||
db => 'postgres',
|
db => 'postgres',
|
||||||
refreshonly => true,
|
refreshonly => true,
|
||||||
cwd => $postgresql::params::datadir,
|
cwd => $postgresql::params::datadir,
|
||||||
|
|
|
@ -50,10 +50,10 @@ define postgresql::database_grant(
|
||||||
default => $privilege,
|
default => $privilege,
|
||||||
}
|
}
|
||||||
|
|
||||||
postgresql_psql {"GRANT $privilege ON database $db TO $role":
|
postgresql_psql {"GRANT ${privilege} ON database ${db} TO ${role}":
|
||||||
db => $psql_db,
|
db => $psql_db,
|
||||||
psql_user => $psql_user,
|
psql_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}')",
|
||||||
cwd => $postgresql::params::datadir,
|
cwd => $postgresql::params::datadir,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Class: postgresql
|
# == Class: postgresql
|
||||||
#
|
#
|
||||||
# This is a base class that can be used to modify catalog-wide settings relating
|
# This is a base class that can be used to modify catalog-wide settings relating
|
||||||
# to the various types in class contained in the postgresql module.
|
# to the various types in class contained in the postgresql module.
|
||||||
|
@ -10,28 +10,37 @@
|
||||||
# For examples, see the files in the `tests` directory; in particular,
|
# For examples, see the files in the `tests` directory; in particular,
|
||||||
# `/server-yum-postgresql-org.pp`.
|
# `/server-yum-postgresql-org.pp`.
|
||||||
#
|
#
|
||||||
# Parameters:
|
#
|
||||||
# [*version*] - The postgresql version to install. If not specified, the
|
# [*version*]
|
||||||
|
# The postgresql version to install. If not specified, the
|
||||||
# module will use whatever version is the default for your
|
# module will use whatever version is the default for your
|
||||||
# OS distro.
|
# OS distro.
|
||||||
# [*manage_package_repo*] - This determines whether or not the module should
|
# [*manage_package_repo*]
|
||||||
|
# This determines whether or not the module should
|
||||||
# attempt to manage the postgres package repository for your
|
# attempt to manage the postgres package repository for your
|
||||||
# distro. Defaults to `false`, but if set to `true`, it can
|
# distro. Defaults to `false`, but if set to `true`, it can
|
||||||
# be used to set up the official postgres yum/apt package
|
# be used to set up the official postgres yum/apt package
|
||||||
# repositories for you.
|
# repositories for you.
|
||||||
# [*package_source*] - This setting is only used if `manage_package_repo` is
|
# [*package_source*]
|
||||||
|
# This setting is only used if `manage_package_repo` is
|
||||||
# set to `true`. It determines which package repository should
|
# set to `true`. It determines which package repository should
|
||||||
# be used to install the postgres packages. Currently supported
|
# be used to install the postgres packages. Currently supported
|
||||||
# values include `yum.postgresql.org`.
|
# values include `yum.postgresql.org`.
|
||||||
# [*locale*] - This setting defines the default locale for initdb and createdb
|
#
|
||||||
|
# [*locale*]
|
||||||
|
# This setting defines the default locale for initdb and createdb
|
||||||
# commands. This default to 'undef' which is effectively 'C'.
|
# commands. This default to 'undef' which is effectively 'C'.
|
||||||
# [*charset*] - Sets the default charset to be used for initdb and createdb.
|
# [*charset*]
|
||||||
|
# Sets the default charset to be used for initdb and createdb.
|
||||||
# Defaults to 'UTF8'.
|
# Defaults to 'UTF8'.
|
||||||
# Actions:
|
|
||||||
#
|
#
|
||||||
# Requires:
|
# === Examples:
|
||||||
|
#
|
||||||
|
# class { 'postgresql':
|
||||||
|
# version => '9.2',
|
||||||
|
# manage_package_repo => true,
|
||||||
|
# }
|
||||||
#
|
#
|
||||||
# Sample Usage:
|
|
||||||
#
|
#
|
||||||
class postgresql (
|
class postgresql (
|
||||||
$version = $::postgres_default_version,
|
$version = $::postgres_default_version,
|
||||||
|
@ -41,6 +50,7 @@ class postgresql (
|
||||||
$charset = 'UTF8'
|
$charset = 'UTF8'
|
||||||
) {
|
) {
|
||||||
class { 'postgresql::params':
|
class { 'postgresql::params':
|
||||||
|
|
||||||
version => $version,
|
version => $version,
|
||||||
manage_package_repo => $manage_package_repo,
|
manage_package_repo => $manage_package_repo,
|
||||||
package_source => $package_source,
|
package_source => $package_source,
|
||||||
|
|
|
@ -6,10 +6,10 @@ class postgresql::package_source::yum_postgresql_org(
|
||||||
$package_version = "${version_parts[0]}${version_parts[1]}"
|
$package_version = "${version_parts[0]}${version_parts[1]}"
|
||||||
|
|
||||||
file { "/etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-${package_version}":
|
file { "/etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-${package_version}":
|
||||||
source => "puppet:///modules/postgresql/RPM-GPG-KEY-PGDG"
|
source => 'puppet:///modules/postgresql/RPM-GPG-KEY-PGDG'
|
||||||
} ->
|
} ->
|
||||||
|
|
||||||
yumrepo { "yum.postgresql.org":
|
yumrepo { 'yum.postgresql.org':
|
||||||
descr => "PostgreSQL ${version} \$releasever - \$basearch",
|
descr => "PostgreSQL ${version} \$releasever - \$basearch",
|
||||||
baseurl => "http://yum.postgresql.org/${version}/redhat/rhel-\$releasever-\$basearch",
|
baseurl => "http://yum.postgresql.org/${version}/redhat/rhel-\$releasever-\$basearch",
|
||||||
enabled => 1,
|
enabled => 1,
|
||||||
|
@ -17,6 +17,6 @@ class postgresql::package_source::yum_postgresql_org(
|
||||||
gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-${package_version}",
|
gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-${package_version}",
|
||||||
}
|
}
|
||||||
|
|
||||||
Yumrepo["yum.postgresql.org"] -> Package<|tag == 'postgresql'|>
|
Yumrepo['yum.postgresql.org'] -> Package<|tag == 'postgresql'|>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ class postgresql::params(
|
||||||
|
|
||||||
case $rh_pkg_source {
|
case $rh_pkg_source {
|
||||||
'yum.postgresql.org': {
|
'yum.postgresql.org': {
|
||||||
class { "postgresql::package_source::yum_postgresql_org":
|
class { 'postgresql::package_source::yum_postgresql_org':
|
||||||
version => $version
|
version => $version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ class postgresql::params(
|
||||||
}
|
}
|
||||||
|
|
||||||
'Debian': {
|
'Debian': {
|
||||||
class { "postgresql::package_source::apt_postgresql_org": }
|
class { 'postgresql::package_source::apt_postgresql_org': }
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
@ -81,7 +81,7 @@ class postgresql::params(
|
||||||
# that pluginsync might not be enabled. Ideally this would be handled directly
|
# that pluginsync might not be enabled. Ideally this would be handled directly
|
||||||
# in puppet.
|
# in puppet.
|
||||||
if ($::postgres_default_version == undef) {
|
if ($::postgres_default_version == undef) {
|
||||||
fail "No value for postgres_default_version facter fact; it's possible that you don't have pluginsync enabled."
|
fail 'No value for postgres_default_version facter fact; it\'s possible that you don\'t have pluginsync enabled.'
|
||||||
}
|
}
|
||||||
|
|
||||||
case $::operatingsystem {
|
case $::operatingsystem {
|
||||||
|
|
|
@ -38,10 +38,10 @@ define postgresql::psql(
|
||||||
$quoted_command = regsubst($command, '"', '\\"', 'G')
|
$quoted_command = regsubst($command, '"', '\\"', 'G')
|
||||||
$quoted_unless = regsubst($unless, '"', '\\"', 'G')
|
$quoted_unless = regsubst($unless, '"', '\\"', 'G')
|
||||||
|
|
||||||
$final_cmd = "/bin/echo \"$quoted_command\" | $psql |egrep -v -q '^$'"
|
$final_cmd = "/bin/echo \"${quoted_command}\" | ${psql} |egrep -v -q '^$'"
|
||||||
|
|
||||||
notify { "deprecation warning: $final_cmd":
|
notify { "deprecation warning: ${final_cmd}":
|
||||||
message => "postgresql::psql is deprecated ; please use postgresql_psql instead.",
|
message => 'postgresql::psql is deprecated ; please use postgresql_psql instead.',
|
||||||
} ->
|
} ->
|
||||||
|
|
||||||
exec { $final_cmd:
|
exec { $final_cmd:
|
||||||
|
|
|
@ -33,10 +33,10 @@ define postgresql::role(
|
||||||
$superuser_sql = $superuser ? { true => 'SUPERUSER' , default => 'NOSUPERUSER' }
|
$superuser_sql = $superuser ? { true => 'SUPERUSER' , default => 'NOSUPERUSER' }
|
||||||
|
|
||||||
# TODO: FIXME: Will not correct the superuser / createdb / createrole / login status of a role that already exists
|
# 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,
|
db => $db,
|
||||||
psql_user => 'postgres',
|
psql_user => 'postgres',
|
||||||
unless => "SELECT rolname FROM pg_roles WHERE rolname='$username'",
|
unless => "SELECT rolname FROM pg_roles WHERE rolname='${username}'",
|
||||||
cwd => $postgresql::params::datadir,
|
cwd => $postgresql::params::datadir,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,17 +38,17 @@ define postgresql::tablespace(
|
||||||
|
|
||||||
$create_tablespace_command = "CREATE TABLESPACE ${spcname} ${owner_section} LOCATION '${location}'"
|
$create_tablespace_command = "CREATE TABLESPACE ${spcname} ${owner_section} LOCATION '${location}'"
|
||||||
|
|
||||||
file { "${location}":
|
file { $location:
|
||||||
ensure => directory,
|
ensure => directory,
|
||||||
owner => 'postgres',
|
owner => 'postgres',
|
||||||
group => 'postgres',
|
group => 'postgres',
|
||||||
mode => 700,
|
mode => '0700',
|
||||||
}
|
}
|
||||||
|
|
||||||
postgresql_psql { "Create tablespace '${spcname}'":
|
postgresql_psql { "Create tablespace '${spcname}'":
|
||||||
command => $create_tablespace_command,
|
command => $create_tablespace_command,
|
||||||
unless => "SELECT spcname FROM pg_tablespace WHERE spcname='${spcname}'",
|
unless => "SELECT spcname FROM pg_tablespace WHERE spcname='${spcname}'",
|
||||||
cwd => $postgresql::params::datadir,
|
cwd => $postgresql::params::datadir,
|
||||||
require => [Class['postgresql::server'], File["${location}"]],
|
require => [Class['postgresql::server'], File[$location]],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ user {'puppet':
|
||||||
file {'/etc/sudoers.d/puppet_postgresql_tests':
|
file {'/etc/sudoers.d/puppet_postgresql_tests':
|
||||||
ensure => file,
|
ensure => file,
|
||||||
content => 'vagrant ALL=(ALL) ALL',
|
content => 'vagrant ALL=(ALL) ALL',
|
||||||
mode => 0440,
|
mode => '0440',
|
||||||
owner => root,
|
owner => root,
|
||||||
group => root,
|
group => root,
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class postgresql_tests::system_default::test_grant_create($user, $password, $db)
|
||||||
require => Class['postgresql::server'],
|
require => Class['postgresql::server'],
|
||||||
}
|
}
|
||||||
|
|
||||||
postgresql::database_grant { "grant create test":
|
postgresql::database_grant { 'grant create test':
|
||||||
privilege => 'CREATE',
|
privilege => 'CREATE',
|
||||||
db => $db,
|
db => $db,
|
||||||
role => $user,
|
role => $user,
|
||||||
|
|
|
@ -27,7 +27,7 @@ class postgresql_tests::system_default::test_tablespace {
|
||||||
ensure => 'directory',
|
ensure => 'directory',
|
||||||
owner => 'postgres',
|
owner => 'postgres',
|
||||||
group => 'postgres',
|
group => 'postgres',
|
||||||
mode => 700,
|
mode => '0700',
|
||||||
require => File['/tmp'],
|
require => File['/tmp'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
# still need to use the 'postgresql' class to specify the postgres version
|
# still need to use the 'postgresql' class to specify the postgres version
|
||||||
# number, though, in order for the other classes to be able to find the
|
# number, though, in order for the other classes to be able to find the
|
||||||
# correct paths to the postgres dirs.
|
# correct paths to the postgres dirs.
|
||||||
class { "postgresql":
|
class { 'postgresql':
|
||||||
version => '9.2',
|
version => '9.2',
|
||||||
manage_package_repo => true,
|
manage_package_repo => true,
|
||||||
}->
|
}->
|
||||||
class { "postgresql::server": }
|
class { 'postgresql::server': }
|
||||||
|
|
|
@ -8,7 +8,7 @@ class { 'postgresql::server':
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
include "postgresql::params"
|
include 'postgresql::params'
|
||||||
|
|
||||||
$pg_conf_include_file = "${postgresql::params::confdir}/postgresql_puppet_extras.conf"
|
$pg_conf_include_file = "${postgresql::params::confdir}/postgresql_puppet_extras.conf"
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ file { '/tmp/pg_tablespaces':
|
||||||
ensure => 'directory',
|
ensure => 'directory',
|
||||||
owner => 'postgres',
|
owner => 'postgres',
|
||||||
group => 'postgres',
|
group => 'postgres',
|
||||||
mode => 700,
|
mode => '0700',
|
||||||
require => File['/tmp'],
|
require => File['/tmp'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue