diff --git a/.project b/.project new file mode 100644 index 0000000..a680a0b --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + postgresql + + + + + + org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + + org.cloudsmith.geppetto.pp.dsl.ui.puppetNature + org.eclipse.xtext.ui.shared.xtextNature + + diff --git a/Modulefile b/Modulefile index 52cba03..e621243 100644 --- a/Modulefile +++ b/Modulefile @@ -5,7 +5,7 @@ author 'Inkling/Puppet Labs' description 'PostgreSQL defined resource types' summary 'PostgreSQL defined resource types' 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/firewall', '>= 0.0.4' diff --git a/manifests/config/beforeservice.pp b/manifests/config/beforeservice.pp index 8f14aaf..2545848 100644 --- a/manifests/config/beforeservice.pp +++ b/manifests/config/beforeservice.pp @@ -73,15 +73,15 @@ class postgresql::config::beforeservice( # managing their own settings in a second conf file. file_line { 'postgresql.conf#include': path => $postgresql_conf_path, - line => "include 'postgresql_puppet_extras.conf'", + line => 'include \'postgresql_puppet_extras.conf\'', notify => Service['postgresqld'], } # Since we're adding an "include" for this extras config file, we need # to make sure it exists. - exec { "touch `dirname $postgresql_conf_path`/postgresql_puppet_extras.conf" : - path => "/usr/bin:/bin", - unless => "[ -f `dirname $postgresql_conf_path`/postgresql_puppet_extras.conf ]" + exec { "touch `dirname ${postgresql_conf_path}`/postgresql_puppet_extras.conf" : + path => '/usr/bin:/bin', + unless => "[ -f `dirname ${postgresql_conf_path}`/postgresql_puppet_extras.conf ]" } # TODO: is this a reasonable place for this firewall stuff? diff --git a/manifests/database.pp b/manifests/database.pp index ab9a0cf..f22a217 100644 --- a/manifests/database.pp +++ b/manifests/database.pp @@ -34,10 +34,10 @@ define postgresql::database( undef => '', default => "--locale=${locale}", } - $public_revoke_privilege = "CONNECT" + $public_revoke_privilege = 'CONNECT' } else { - $locale_option = "" - $public_revoke_privilege = "ALL" + $locale_option = '' + $public_revoke_privilege = 'ALL' } $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}'" } - postgresql_psql { "Check for existence of db '$dbname'": - command => "SELECT 1", - unless => "SELECT datname FROM pg_database WHERE datname='$dbname'", + postgresql_psql { "Check for existence of db '${dbname}'": + command => 'SELECT 1', + unless => "SELECT datname FROM pg_database WHERE datname='${dbname}'", cwd => $postgresql::params::datadir, require => Class['postgresql::server'] } ~> @@ -65,7 +65,7 @@ define postgresql::database( # This will prevent users from connecting to the database unless they've been # 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', refreshonly => true, cwd => $postgresql::params::datadir, diff --git a/manifests/database_grant.pp b/manifests/database_grant.pp index 6904e71..833663b 100644 --- a/manifests/database_grant.pp +++ b/manifests/database_grant.pp @@ -50,10 +50,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, 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, } } diff --git a/manifests/init.pp b/manifests/init.pp index 7748c2f..4f9fe07 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,37 +1,46 @@ -# Class: postgresql +# == Class: postgresql # -# 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. +# 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. # -# If you don't declare this class in your catalog, sensible defaults will -# be used. However, if you choose to declare it, it needs to appear *before* -# any other types or classes from the postgresql module. +# If you don't declare this class in your catalog, sensible defaults will +# be used. However, if you choose to declare it, it needs to appear *before* +# any other types or classes from the postgresql module. # -# For examples, see the files in the `tests` directory; in particular, -# `/server-yum-postgresql-org.pp`. +# For examples, see the files in the `tests` directory; in particular, +# `/server-yum-postgresql-org.pp`. # -# Parameters: -# [*version*] - The postgresql version to install. If not specified, the -# module will use whatever version is the default for your -# OS distro. -# [*manage_package_repo*] - This determines whether or not the module should -# attempt to manage the postgres package repository for your -# distro. Defaults to `false`, but if set to `true`, it can -# be used to set up the official postgres yum/apt package -# repositories for you. -# [*package_source*] - This setting is only used if `manage_package_repo` is -# set to `true`. It determines which package repository should -# be used to install the postgres packages. Currently supported -# values include `yum.postgresql.org`. -# [*locale*] - This setting defines the default locale for initdb and createdb -# commands. This default to 'undef' which is effectively 'C'. -# [*charset*] - Sets the default charset to be used for initdb and createdb. -# Defaults to 'UTF8'. -# Actions: # -# Requires: +# [*version*] +# The postgresql version to install. If not specified, the +# module will use whatever version is the default for your +# OS distro. +# [*manage_package_repo*] +# This determines whether or not the module should +# attempt to manage the postgres package repository for your +# distro. Defaults to `false`, but if set to `true`, it can +# be used to set up the official postgres yum/apt package +# repositories for you. +# [*package_source*] +# This setting is only used if `manage_package_repo` is +# set to `true`. It determines which package repository should +# be used to install the postgres packages. Currently supported +# values include `yum.postgresql.org`. +# +# [*locale*] +# This setting defines the default locale for initdb and createdb +# commands. This default to 'undef' which is effectively 'C'. +# [*charset*] +# Sets the default charset to be used for initdb and createdb. +# Defaults to 'UTF8'. +# +# === Examples: +# +# class { 'postgresql': +# version => '9.2', +# manage_package_repo => true, +# } # -# Sample Usage: # class postgresql ( $version = $::postgres_default_version, @@ -41,6 +50,7 @@ class postgresql ( $charset = 'UTF8' ) { class { 'postgresql::params': + version => $version, manage_package_repo => $manage_package_repo, package_source => $package_source, diff --git a/manifests/package_source/yum_postgresql_org.pp b/manifests/package_source/yum_postgresql_org.pp index f755351..848911c 100644 --- a/manifests/package_source/yum_postgresql_org.pp +++ b/manifests/package_source/yum_postgresql_org.pp @@ -6,10 +6,10 @@ class postgresql::package_source::yum_postgresql_org( $package_version = "${version_parts[0]}${version_parts[1]}" 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", baseurl => "http://yum.postgresql.org/${version}/redhat/rhel-\$releasever-\$basearch", 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}", } - Yumrepo["yum.postgresql.org"] -> Package<|tag == 'postgresql'|> + Yumrepo['yum.postgresql.org'] -> Package<|tag == 'postgresql'|> } diff --git a/manifests/params.pp b/manifests/params.pp index 2936226..7b39cd4 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -52,7 +52,7 @@ class postgresql::params( case $rh_pkg_source { 'yum.postgresql.org': { - class { "postgresql::package_source::yum_postgresql_org": + class { 'postgresql::package_source::yum_postgresql_org': version => $version } } @@ -64,7 +64,7 @@ class postgresql::params( } 'Debian': { - class { "postgresql::package_source::apt_postgresql_org": } + class { 'postgresql::package_source::apt_postgresql_org': } } default: { @@ -81,7 +81,7 @@ class postgresql::params( # that pluginsync might not be enabled. Ideally this would be handled directly # in puppet. 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 { diff --git a/manifests/psql.pp b/manifests/psql.pp index c685a3f..3450ca2 100644 --- a/manifests/psql.pp +++ b/manifests/psql.pp @@ -38,10 +38,10 @@ define postgresql::psql( $quoted_command = regsubst($command, '"', '\\"', '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": - message => "postgresql::psql is deprecated ; please use postgresql_psql instead.", + notify { "deprecation warning: ${final_cmd}": + message => 'postgresql::psql is deprecated ; please use postgresql_psql instead.', } -> exec { $final_cmd: diff --git a/manifests/role.pp b/manifests/role.pp index 031a797..f1ec916 100644 --- a/manifests/role.pp +++ b/manifests/role.pp @@ -33,10 +33,10 @@ 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, 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, } } diff --git a/manifests/tablespace.pp b/manifests/tablespace.pp index 5d60b8a..946c7b2 100644 --- a/manifests/tablespace.pp +++ b/manifests/tablespace.pp @@ -38,17 +38,17 @@ define postgresql::tablespace( $create_tablespace_command = "CREATE TABLESPACE ${spcname} ${owner_section} LOCATION '${location}'" - file { "${location}": + file { $location: ensure => directory, owner => 'postgres', group => 'postgres', - mode => 700, + mode => '0700', } postgresql_psql { "Create tablespace '${spcname}'": command => $create_tablespace_command, unless => "SELECT spcname FROM pg_tablespace WHERE spcname='${spcname}'", cwd => $postgresql::params::datadir, - require => [Class['postgresql::server'], File["${location}"]], + require => [Class['postgresql::server'], File[$location]], } } diff --git a/spec/system/base.pp b/spec/system/base.pp index d27ad18..0c22683 100644 --- a/spec/system/base.pp +++ b/spec/system/base.pp @@ -28,7 +28,7 @@ user {'puppet': file {'/etc/sudoers.d/puppet_postgresql_tests': ensure => file, content => 'vagrant ALL=(ALL) ALL', - mode => 0440, + mode => '0440', owner => root, group => root, } diff --git a/spec/system/test_module/manifests/system_default/test_grant_create.pp b/spec/system/test_module/manifests/system_default/test_grant_create.pp index 35036fe..b3e2169 100644 --- a/spec/system/test_module/manifests/system_default/test_grant_create.pp +++ b/spec/system/test_module/manifests/system_default/test_grant_create.pp @@ -35,7 +35,7 @@ class postgresql_tests::system_default::test_grant_create($user, $password, $db) require => Class['postgresql::server'], } - postgresql::database_grant { "grant create test": + postgresql::database_grant { 'grant create test': privilege => 'CREATE', db => $db, role => $user, diff --git a/spec/system/test_module/manifests/system_default/test_tablespace.pp b/spec/system/test_module/manifests/system_default/test_tablespace.pp index d07de81..5d67f8c 100644 --- a/spec/system/test_module/manifests/system_default/test_tablespace.pp +++ b/spec/system/test_module/manifests/system_default/test_tablespace.pp @@ -27,7 +27,7 @@ class postgresql_tests::system_default::test_tablespace { ensure => 'directory', owner => 'postgres', group => 'postgres', - mode => 700, + mode => '0700', require => File['/tmp'], } @@ -61,5 +61,5 @@ class postgresql_tests::system_default::test_tablespace { tablespace => 'tablespace2', require => Postgresql::Tablespace['tablespace2'], } - + } diff --git a/tests/official-postgresql-repos.pp b/tests/official-postgresql-repos.pp index 8665809..3c48134 100644 --- a/tests/official-postgresql-repos.pp +++ b/tests/official-postgresql-repos.pp @@ -12,8 +12,8 @@ # 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 # correct paths to the postgres dirs. -class { "postgresql": +class { 'postgresql': version => '9.2', manage_package_repo => true, }-> -class { "postgresql::server": } +class { 'postgresql::server': } diff --git a/tests/postgresql_pgconf_extras.pp b/tests/postgresql_pgconf_extras.pp index 52cb979..22b210d 100644 --- a/tests/postgresql_pgconf_extras.pp +++ b/tests/postgresql_pgconf_extras.pp @@ -8,7 +8,7 @@ class { 'postgresql::server': }, } -include "postgresql::params" +include 'postgresql::params' $pg_conf_include_file = "${postgresql::params::confdir}/postgresql_puppet_extras.conf" diff --git a/tests/postgresql_tablespace.pp b/tests/postgresql_tablespace.pp index 311c04e..9629410 100644 --- a/tests/postgresql_tablespace.pp +++ b/tests/postgresql_tablespace.pp @@ -12,10 +12,10 @@ file { '/tmp': ensure => 'directory', } file { '/tmp/pg_tablespaces': - ensure => 'directory', - owner => 'postgres', - group => 'postgres', - mode => 700, + ensure => 'directory', + owner => 'postgres', + group => 'postgres', + mode => '0700', require => File['/tmp'], }