complies with style guide

This commit is contained in:
Garrett Honeycutt 2012-09-20 14:46:26 -07:00
parent 4ad02dd772
commit 1aab5d98b0
13 changed files with 254 additions and 251 deletions

View file

@ -10,4 +10,3 @@ project_page 'https://github.com/puppetlabs-puppet/puppetlabs-puppetdb'
dependency 'cprice404/inifile', '0.0.x'
dependency 'inkling/postgresql', '0.3.x'
dependency 'puppetlabs/firewall', '0.0.x'

View file

@ -31,27 +31,26 @@
# listen_addresses => 'my.postgres.host.name',
# }
#
class puppetdb::database::postgresql(
# TODO: expose more of the parameters from `inkling/postgresql`!
$listen_addresses = $puppetdb::params::database_host,
# TODO: expose more of the parameters from `inkling/postgresql`!
$listen_addresses = $puppetdb::params::database_host,
) inherits puppetdb::params {
# get the pg server up and running
class { '::postgresql::server':
config_hash => {
# TODO: make this stuff configurable
'ip_mask_allow_all_users' => '0.0.0.0/0',
'listen_addresses' => $listen_addresses,
'manage_redhat_firewall' => true,
},
}
# get the pg server up and running
class { '::postgresql::server':
config_hash => {
# TODO: make this stuff configurable
'ip_mask_allow_all_users' => '0.0.0.0/0',
'listen_addresses' => $listen_addresses,
'manage_redhat_firewall' => true,
},
}
# create the puppetdb database
postgresql::db{ 'puppetdb':
user => 'puppetdb',
password => 'puppetdb',
grant => 'all',
require => Class['::postgresql::server'],
}
# create the puppetdb database
postgresql::db{ 'puppetdb':
user => 'puppetdb',
password => 'puppetdb',
grant => 'all',
require => Class['::postgresql::server'],
}
}

View file

@ -34,21 +34,22 @@
# Sample Usage:
# include puppetdb
#
#
# TODO: expose more parameters
#
class puppetdb(
$database = $puppetdb::params::database,
$puppetdb_version = $puppetdb::params::puppetdb_version,
$database = $puppetdb::params::database,
$puppetdb_version = $puppetdb::params::puppetdb_version,
) inherits puppetdb::params {
class { 'puppetdb::server':
database => $database,
puppetdb_version => $puppetdb_version,
}
if ($database == "postgres") {
class { 'puppetdb::database::postgresql':
before => Class['puppetdb::server']
}
class { 'puppetdb::server':
database => $database,
puppetdb_version => $puppetdb_version,
}
if ($database == 'postgres') {
class { 'puppetdb::database::postgresql':
before => Class['puppetdb::server']
}
}
}

View file

@ -36,17 +36,16 @@
# puppetdb_port => 8081,
# }
#
# TODO: port this to use params
#
class puppetdb::master::config(
$puppetdb_server = $::clientcert,
$puppetdb_port = 8081,
$manage_routes = true,
$manage_storeconfigs = true,
$puppet_confdir = '/etc/puppet',
$puppet_conf = '/etc/puppet/puppet.conf',
$puppetdb_version = $puppetdb::params::puppetdb_version,
$puppetdb_server = $::clientcert,
$puppetdb_port = 8081,
$manage_routes = true,
$manage_storeconfigs = true,
$puppet_confdir = '/etc/puppet',
$puppet_conf = '/etc/puppet/puppet.conf',
$puppetdb_version = $puppetdb::params::puppetdb_version,
) inherits puppetdb::params {
package { 'puppetdb-terminus':
@ -56,9 +55,9 @@ class puppetdb::master::config(
# Validate the puppetdb connection. If we can't connect to puppetdb then we
# *must* not perform the other configuration steps, or else
puppetdb_conn_validator { 'puppetdb_conn':
puppetdb_server => $puppetdb_server,
puppetdb_port => $puppetdb_port,
require => Package['puppetdb-terminus'],
puppetdb_server => $puppetdb_server,
puppetdb_port => $puppetdb_port,
require => Package['puppetdb-terminus'],
}
# This is a bit of puppet chicanery that allows us to create a
@ -67,11 +66,10 @@ class puppetdb::master::config(
# this validator."
Service<|title == 'puppetdb'|> -> Puppetdb_conn_validator['puppetdb_conn']
# We will need to restart the puppet master service if certain config
# files are changed, so here we make sure it's in the catalog.
if ! defined(Service[$puppet_service_name]) {
service { $puppet_service_name:
if ! defined(Service[$puppetdb::params::puppet_service_name]) {
service { $puppetdb::params::puppet_service_name:
ensure => running,
}
}
@ -82,7 +80,7 @@ class puppetdb::master::config(
class { 'puppetdb::master::routes':
puppet_confdir => $puppet_confdir,
require => Puppetdb_conn_validator['puppetdb_conn'],
notify => Service[$puppet_service_name],
notify => Service[$puppetdb::params::puppet_service_name],
}
}
@ -92,7 +90,7 @@ class puppetdb::master::config(
if ($manage_storeconfigs) {
class { 'puppetdb::master::storeconfigs':
puppet_conf => $puppet_conf,
require => Puppetdb_conn_validator['puppetdb_conn'],
require => Puppetdb_conn_validator['puppetdb_conn'],
}
}
@ -103,8 +101,6 @@ class puppetdb::master::config(
port => $puppetdb_port,
puppet_confdir => $puppet_confdir,
require => Puppetdb_conn_validator['puppetdb_conn'],
notify => Service[$puppet_service_name],
notify => Service[$puppetdb::params::puppet_service_name],
}
}

View file

@ -19,29 +19,28 @@
# server => 'my.puppetdb.server'
# }
#
#
# TODO: port this to use params
#
class puppetdb::master::puppetdb_conf(
$server = 'localhost',
$port = 8081,
$puppet_confdir = '/etc/puppet',
)
{
Ini_setting {
ensure => present,
section => 'main',
path => "${puppet_confdir}/puppetdb.conf",
}
$server = 'localhost',
$port = '8081',
$puppet_confdir = '/etc/puppet',
) {
ini_setting {'puppetdbserver':
setting => 'server',
value => $server,
}
Ini_setting {
ensure => present,
section => 'main',
path => "${puppet_confdir}/puppetdb.conf",
}
ini_setting {'puppetdbport':
setting => 'port',
value => $port,
}
ini_setting {'puppetdbserver':
setting => 'server',
value => $server,
}
ini_setting {'puppetdbport':
setting => 'port',
value => $port,
}
}

View file

@ -18,20 +18,20 @@
# puppet_confdir => '/etc/puppet'
# }
#
#
# TODO: port this to use params
#
class puppetdb::master::routes(
$puppet_confdir = '/etc/puppet',
)
{
$puppet_confdir = '/etc/puppet',
) {
# TODO: this will overwrite any existing routes.yaml;
# to handle this properly we should just be ensuring
# that the proper settings exist, but to do that we'd need
# to parse the yaml file and rewrite it, dealing with indentation issues etc.
# I don't think there is currently a puppet module or an augeas lens for this.
file { "${puppet_confdir}/routes.yaml":
ensure => file,
source => 'puppet:///modules/puppetdb/routes.yaml',
ensure => file,
source => 'puppet:///modules/puppetdb/routes.yaml',
}
}

View file

@ -17,13 +17,12 @@
# puppet_conf => '/etc/puppet/puppet.conf'
# }
#
#
# TODO: port this to use params
#
class puppetdb::master::storeconfigs(
$puppet_conf = '/etc/puppet/puppet.conf',
)
{
$puppet_conf = '/etc/puppet/puppet.conf',
) {
Ini_setting{
section => 'master',

View file

@ -10,43 +10,45 @@
#
# Sample Usage:
#
class puppetdb::params {
# TODO: need to condition this based on whether we are a PE install or not
# TODO: need to condition this based on whether we are a PE install or not
$ssl_listen_address = $::clientcert
$ssl_listen_port = 8081
$ssl_listen_address = $::clientcert
$ssl_listen_port = '8081'
$database = 'postgres'
$database = 'postgres'
# The remaining database settings are not used for an embedded database
$database_host = 'localhost'
$database_port = '5432'
$database_name = 'puppetdb'
$database_username = 'puppetdb'
$database_password = 'puppetdb'
# The remaining database settings are not used for an embedded database
$database_host = 'localhost'
$database_port = '5432'
$database_name = 'puppetdb'
$database_username = 'puppetdb'
$database_password = 'puppetdb'
$puppetdb_version = 'present'
$puppetdb_version = 'present'
# TODO: figure out a way to make this not platform-specific
$manage_redhat_firewall = true
# TODO: figure out a way to make this not platform-specific
$manage_redhat_firewall = true
$gc_interval = 60
$confdir = '/etc/puppetdb/conf.d'
$gc_interval = '60'
$confdir = '/etc/puppetdb/conf.d'
case $::osfamily {
'RedHat': {
$firewall_supported = true
$persist_firewall_command = '/sbin/iptables-save > /etc/sysconfig/iptables'
}
'Debian': {
$firewall_supported = false
# TODO: not exactly sure yet what the right thing to do for Debian/Ubuntu is.
#$persist_firewall_command = '/sbin/iptables-save > /etc/iptables/rules.v4'
}
case $::osfamily {
'RedHat': {
$firewall_supported = true
$persist_firewall_command = '/sbin/iptables-save > /etc/sysconfig/iptables'
}
# TODO: need to condition this for PE
$puppet_service_name = 'puppetmaster'
'Debian': {
$firewall_supported = false
# TODO: not exactly sure yet what the right thing to do for Debian/Ubuntu is.
#$persist_firewall_command = '/sbin/iptables-save > /etc/iptables/rules.v4'
}
default: {
fail("${module_name} supports osfamily's RedHat and Debian. Your osfamily is recognized as ${::osfamily}")
}
}
# TODO: need to condition this for PE
$puppet_service_name = 'puppetmaster'
}

View file

@ -67,59 +67,57 @@
# database_host => 'puppetdb-postgres',
# }
#
class puppetdb::server(
$ssl_listen_address = $puppetdb::params::ssl_listen_address,
$ssl_listen_port = $puppetdb::params::ssl_listen_port,
$database = $puppetdb::params::database,
$database_host = $puppetdb::params::database_host,
$database_port = $puppetdb::params::database_port,
$database_username = $puppetdb::params::database_username,
$database_password = $puppetdb::params::database_password,
$database_name = $puppetdb::params::database_name,
$puppetdb_version = $puppetdb::params::puppetdb_version,
$manage_redhat_firewall = $puppetdb::params::manage_redhat_firewall,
$confdir = $puppetdb::params::confdir,
$gc_interval = $puppetdb::params::gc_interval,
$ssl_listen_address = $puppetdb::params::ssl_listen_address,
$ssl_listen_port = $puppetdb::params::ssl_listen_port,
$database = $puppetdb::params::database,
$database_host = $puppetdb::params::database_host,
$database_port = $puppetdb::params::database_port,
$database_username = $puppetdb::params::database_username,
$database_password = $puppetdb::params::database_password,
$database_name = $puppetdb::params::database_name,
$puppetdb_version = $puppetdb::params::puppetdb_version,
$manage_redhat_firewall = $puppetdb::params::manage_redhat_firewall,
$confdir = $puppetdb::params::confdir,
$gc_interval = $puppetdb::params::gc_interval,
) inherits puppetdb::params {
package { 'puppetdb':
ensure => $puppetdb_version,
notify => Service['puppetdb'],
}
package { 'puppetdb':
ensure => $puppetdb_version,
notify => Service['puppetdb'],
}
class { 'puppetdb::server::firewall':
port => $ssl_listen_port,
manage_redhat_firewall => $manage_redhat_firewall,
}
class { 'puppetdb::server::firewall':
port => $ssl_listen_port,
manage_redhat_firewall => $manage_redhat_firewall,
}
class { 'puppetdb::server::database_ini':
database => $database,
database_host => $database_host,
database_port => $database_port,
database_username => $database_username,
database_password => $database_password,
database_name => $database_name,
confdir => $confdir,
notify => Service['puppetdb'],
}
class { 'puppetdb::server::database_ini':
database => $database,
database_host => $database_host,
database_port => $database_port,
database_username => $database_username,
database_password => $database_password,
database_name => $database_name,
confdir => $confdir,
notify => Service['puppetdb'],
}
class { 'puppetdb::server::jetty_ini':
ssl_listen_address => $ssl_listen_address,
ssl_listen_port => $ssl_listen_port,
confdir => $confdir,
notify => Service['puppetdb'],
}
class { 'puppetdb::server::jetty_ini':
ssl_listen_address => $ssl_listen_address,
ssl_listen_port => $ssl_listen_port,
confdir => $confdir,
notify => Service['puppetdb'],
}
service { 'puppetdb':
ensure => running,
enable => true,
}
service { 'puppetdb':
ensure => running,
enable => true,
}
Package['puppetdb'] ->
Class['puppetdb::server::firewall'] ->
Class['puppetdb::server::database_ini'] ->
Class['puppetdb::server::jetty_ini'] ->
Service['puppetdb']
Package['puppetdb'] ->
Class['puppetdb::server::firewall'] ->
Class['puppetdb::server::database_ini'] ->
Class['puppetdb::server::jetty_ini'] ->
Service['puppetdb']
}

View file

@ -29,81 +29,89 @@
#
# Sample Usage:
# class { 'puppetdb::server::database_ini':
# database_host => 'my.postgres.host',
# database_port => 5432,
# database_username => 'puppetdb_pguser',
# database_password => 'puppetdb_pgpasswd',
# database_name => 'puppetdb',
# database_host => 'my.postgres.host',
# database_port => '5432',
# database_username => 'puppetdb_pguser',
# database_password => 'puppetdb_pgpasswd',
# database_name => 'puppetdb',
# }
#
class puppetdb::server::database_ini(
$database = $puppetdb::params::database,
$database_host = $puppetdb::params::database_host,
$database_port = $puppetdb::params::database_port,
$database_username = $puppetdb::params::database_username,
$database_password = $puppetdb::params::database_password,
$database_name = $puppetdb::params::database_name,
$confdir = $puppetdb::params::confdir,
$database = $puppetdb::params::database,
$database_host = $puppetdb::params::database_host,
$database_port = $puppetdb::params::database_port,
$database_username = $puppetdb::params::database_username,
$database_password = $puppetdb::params::database_password,
$database_name = $puppetdb::params::database_name,
$confdir = $puppetdb::params::confdir,
) inherits puppetdb::params {
# Validate the database connection. If we can't connect, we want to fail
# and skip the rest of the configuration, so that we don't leave puppetdb
# in a broken state.
class { 'puppetdb::server::validate_db':
database => $database,
database_host => $database_host,
database_port => $database_port,
database_username => $database_username,
database_password => $database_password,
database_name => $database_name,
database => $database,
database_host => $database_host,
database_port => $database_port,
database_username => $database_username,
database_password => $database_password,
database_name => $database_name,
}
#Set the defaults
Ini_setting {
path => "${confdir}/database.ini",
ensure => present,
section => 'database',
require => Class['puppetdb::server::validate_db'],
path => "${confdir}/database.ini",
ensure => present,
section => 'database',
require => Class['puppetdb::server::validate_db'],
}
if $database == 'embedded'{
$classname = 'org.hsqldb.jdbcDriver'
$subprotocol = 'hsqldb'
$subname = 'file:/usr/share/puppetdb/db/db;hsqldb.tx=mvcc;sql.syntax_pgs=true'
} elsif $database == 'postgres' {
$classname = 'org.postgresql.Driver'
$subprotocol = 'postgresql'
$subname = "//${database_host}:${database_port}/${database}"
##Only setup for postgres
ini_setting {'puppetdb_psdatabase_username':
setting => 'username',
value => $database_username,
}
ini_setting {'puppetdb_psdatabase_password':
setting => 'password',
value => $database_password,
}
if $database == 'embedded'{
$classname = 'org.hsqldb.jdbcDriver'
$subprotocol = 'hsqldb'
$subname = 'file:/usr/share/puppetdb/db/db;hsqldb.tx=mvcc;sql.syntax_pgs=true'
} elsif $database == 'postgres' {
$classname = 'org.postgresql.Driver'
$subprotocol = 'postgresql'
$subname = "//${database_host}:${database_port}/${database}"
##Only setup for postgres
ini_setting {'puppetdb_psdatabase_username':
setting => 'username',
value => $database_username,
}
ini_setting {'puppetdb_psdatabase_password':
setting => 'password',
value => $database_password,
}
}
ini_setting {'puppetdb_classname':
setting => 'classname',
value => $classname,
setting => 'classname',
value => $classname,
}
ini_setting {'puppetdb_subprotocol':
setting => 'subprotocol',
value => $subprotocol,
setting => 'subprotocol',
value => $subprotocol,
}
ini_setting {'puppetdb_pgs':
setting => 'syntax_pgs',
value => true,
setting => 'syntax_pgs',
value => true,
}
ini_setting {'puppetdb_subname':
setting => 'subname',
value => $subname,
setting => 'subname',
value => $subname,
}
ini_setting {'puppetdb_gc_interval':
setting => 'gc-interval',
value => $gc_interval ,
setting => 'gc-interval',
value => $puppetdb::params::gc_interval,
}
}

View file

@ -5,20 +5,21 @@ class puppetdb::server::firewall(
# TODO: figure out a way to make this not platform-specific; debian and ubuntu
# have an out-of-the-box firewall configuration that seems trickier to manage.
# TODO: the firewall module should be able to handle this itself
if ($manage_redhat_firewall and $firewall_supported) {
exec { "persist-firewall":
command => $persist_firewall_command,
refreshonly => true,
}
if ($manage_redhat_firewall and $puppetdb::params::firewall_supported) {
Firewall {
notify => Exec["persist-firewall"]
}
exec { 'persist-firewall':
command => $puppetdb::params::persist_firewall_command,
refreshonly => true,
}
firewall { "${port} accept - puppetdb":
port => $port,
proto => 'tcp',
action => 'accept',
}
Firewall {
notify => Exec['persist-firewall']
}
firewall { "${port} accept - puppetdb":
port => $port,
proto => 'tcp',
action => 'accept',
}
}
}

View file

@ -25,30 +25,31 @@
# ssl_listen_port => 8081,
# }
#
#TODO add support for non-ssl config
#
class puppetdb::server::jetty_ini(
$ssl_listen_address = $puppetdb::params::ssl_listen_address,
$ssl_listen_port = $puppetdb::params::ssl_listen_port,
$confdir = $puppetdb::params::confdir,
$ssl_listen_address = $puppetdb::params::ssl_listen_address,
$ssl_listen_port = $puppetdb::params::ssl_listen_port,
$confdir = $puppetdb::params::confdir,
) inherits puppetdb::params {
#Set the defaults
Ini_setting {
path => "${confdir}/jetty.ini",
ensure => present,
section => 'jetty',
path => "${confdir}/jetty.ini",
ensure => present,
section => 'jetty',
}
# TODO: figure out some way to make sure that the ini_file module is installed,
# because otherwise these will silently fail to do anything.
ini_setting {'puppetdb_sslhost':
setting => 'ssl-host',
value => $ssl_listen_address,
setting => 'ssl-host',
value => $ssl_listen_address,
}
ini_setting {'puppetdb_sslport':
setting => 'ssl-port',
value => $ssl_listen_port,
setting => 'ssl-port',
value => $ssl_listen_port,
}
}

View file

@ -42,23 +42,23 @@
# database_name => 'mydbname',
# }
#
class puppetdb::server::validate_db(
$database = $puppetdb::params::database,
$database_host = $puppetdb::params::database_host,
$database_port = $puppetdb::params::database_port,
$database_username = $puppetdb::params::database_username,
$database_password = $puppetdb::params::database_password,
$database_name = $puppetdb::params::database_name
$database = $puppetdb::params::database,
$database_host = $puppetdb::params::database_host,
$database_port = $puppetdb::params::database_port,
$database_username = $puppetdb::params::database_username,
$database_password = $puppetdb::params::database_password,
$database_name = $puppetdb::params::database_name
) inherits puppetdb::params {
# We don't need any validation for the embedded database, presumably.
if ($database == "postgres") {
::postgresql::validate_db_connection { 'validate puppetdb postgres connection':
database_host => $database_host,
database_port => $database_port,
database_username => $database_username,
database_password => $database_password,
database_name => $database_name,
}
# We don't need any validation for the embedded database, presumably.
if ($database == 'postgres') {
::postgresql::validate_db_connection { 'validate puppetdb postgres connection':
database_host => $database_host,
database_port => $database_port,
database_username => $database_username,
database_password => $database_password,
database_name => $database_name,
}
}
}