Skip to content

Commit 04f81ee

Browse files
committed
Merge pull request #162 from bastelfreak/add-postgres-repo
add ability to manage postgres repo
2 parents 021562d + 767fe5c commit 04f81ee

4 files changed

Lines changed: 155 additions & 133 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,14 @@ Conditionally manages the PostgresQL server via `postgresql::server`. Defaults t
543543

544544
The URL to use for testing if the PuppetDB instance is running. Defaults to `/v3/version`.
545545

546+
####`manage_package_repo`
547+
548+
if this is true, the official postgres.org repo will be added and postgres won't be installed from the regular repository.
549+
550+
####`postgres_version`
551+
552+
if the postgres.org repo is installed, you can install several versions of postgres, this currently defaults to 9.4 which is the latest stable version.
553+
546554
Implementation
547555
---------------
548556

manifests/database/postgresql.pp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
# Class for creating the PuppetDB postgresql database. See README.md for more
22
# information.
33
class puppetdb::database::postgresql(
4-
$listen_addresses = $puppetdb::params::database_host,
5-
$database_name = $puppetdb::params::database_name,
6-
$database_username = $puppetdb::params::database_username,
7-
$database_password = $puppetdb::params::database_password,
8-
$manage_server = $puppetdb::params::manage_dbserver,
4+
$listen_addresses = $puppetdb::params::database_host,
5+
$database_name = $puppetdb::params::database_name,
6+
$database_username = $puppetdb::params::database_username,
7+
$database_password = $puppetdb::params::database_password,
8+
$manage_server = $puppetdb::params::manage_dbserver,
9+
$manage_package_repo = $puppetdb::params::manage_pg_repo,
10+
$postgres_version = $puppetdb::params::postgres_version,
911
) inherits puppetdb::params {
1012

11-
if $manage_server == true {
13+
if $manage_server {
14+
if $manage_package_repo {
15+
class { '::postgresql::globals':
16+
manage_package_repo => true,
17+
version => $postgres_version,
18+
}
19+
}
1220
# get the pg server up and running
1321
class { '::postgresql::server':
1422
ip_mask_allow_all_users => '0.0.0.0/0',

manifests/init.pp

Lines changed: 124 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,135 @@
11
# All in one class for setting up a PuppetDB instance. See README.md for more
22
# details.
33
class puppetdb (
4-
$listen_address = $puppetdb::params::listen_address,
5-
$listen_port = $puppetdb::params::listen_port,
6-
$open_listen_port = $puppetdb::params::open_listen_port,
7-
$ssl_listen_address = $puppetdb::params::ssl_listen_address,
8-
$ssl_listen_port = $puppetdb::params::ssl_listen_port,
9-
$disable_ssl = $puppetdb::params::disable_ssl,
10-
$open_ssl_listen_port = $puppetdb::params::open_ssl_listen_port,
11-
$ssl_dir = $puppetdb::params::ssl_dir,
12-
$ssl_set_cert_paths = $puppetdb::params::ssl_set_cert_paths,
13-
$ssl_cert_path = $puppetdb::params::ssl_cert_path,
14-
$ssl_key_path = $puppetdb::params::ssl_key_path,
15-
$ssl_ca_cert_path = $puppetdb::params::ssl_ca_cert_path,
16-
$ssl_deploy_certs = $puppetdb::params::ssl_deploy_certs,
17-
$ssl_key = $puppetdb::params::ssl_key,
18-
$ssl_cert = $puppetdb::params::ssl_cert,
19-
$ssl_ca_cert = $puppetdb::params::ssl_ca_cert,
20-
$ssl_protocols = $puppetdb::params::ssl_protocols,
21-
$manage_dbserver = $puppetdb::params::manage_dbserver,
22-
$database = $puppetdb::params::database,
23-
$database_host = $puppetdb::params::database_host,
24-
$database_port = $puppetdb::params::database_port,
25-
$database_username = $puppetdb::params::database_username,
26-
$database_password = $puppetdb::params::database_password,
27-
$database_name = $puppetdb::params::database_name,
28-
$database_ssl = $puppetdb::params::database_ssl,
29-
$database_listen_address = $puppetdb::params::postgres_listen_addresses,
30-
$database_validate = $puppetdb::params::database_validate,
31-
$node_ttl = $puppetdb::params::node_ttl,
32-
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
33-
$report_ttl = $puppetdb::params::report_ttl,
34-
$gc_interval = $puppetdb::params::gc_interval,
35-
$log_slow_statements = $puppetdb::params::log_slow_statements,
36-
$conn_max_age = $puppetdb::params::conn_max_age,
37-
$conn_keep_alive = $puppetdb::params::conn_keep_alive,
38-
$conn_lifetime = $puppetdb::params::conn_lifetime,
39-
$puppetdb_package = $puppetdb::params::puppetdb_package,
40-
$puppetdb_version = $puppetdb::params::puppetdb_version,
41-
$puppetdb_service = $puppetdb::params::puppetdb_service,
42-
$puppetdb_service_status = $puppetdb::params::puppetdb_service_status,
43-
$puppetdb_user = $puppetdb::params::puppetdb_user,
44-
$puppetdb_group = $puppetdb::params::puppetdb_group,
45-
$read_database = $puppetdb::params::read_database,
46-
$read_database_host = $puppetdb::params::read_database_host,
47-
$read_database_port = $puppetdb::params::read_database_port,
48-
$read_database_username = $puppetdb::params::read_database_username,
49-
$read_database_password = $puppetdb::params::read_database_password,
50-
$read_database_name = $puppetdb::params::read_database_name,
51-
$read_database_ssl = $puppetdb::params::read_database_ssl,
52-
$read_database_validate = $puppetdb::params::read_database_validate,
53-
$read_log_slow_statements = $puppetdb::params::read_log_slow_statements,
54-
$read_conn_max_age = $puppetdb::params::read_conn_max_age,
55-
$read_conn_keep_alive = $puppetdb::params::read_conn_keep_alive,
56-
$read_conn_lifetime = $puppetdb::params::read_conn_lifetime,
57-
$confdir = $puppetdb::params::confdir,
58-
$manage_firewall = $puppetdb::params::manage_firewall,
59-
$java_args = $puppetdb::params::java_args,
60-
$max_threads = $puppetdb::params::max_threads,
4+
$listen_address = $puppetdb::params::listen_address,
5+
$listen_port = $puppetdb::params::listen_port,
6+
$open_listen_port = $puppetdb::params::open_listen_port,
7+
$ssl_listen_address = $puppetdb::params::ssl_listen_address,
8+
$ssl_listen_port = $puppetdb::params::ssl_listen_port,
9+
$disable_ssl = $puppetdb::params::disable_ssl,
10+
$open_ssl_listen_port = $puppetdb::params::open_ssl_listen_port,
11+
$ssl_dir = $puppetdb::params::ssl_dir,
12+
$ssl_set_cert_paths = $puppetdb::params::ssl_set_cert_paths,
13+
$ssl_cert_path = $puppetdb::params::ssl_cert_path,
14+
$ssl_key_path = $puppetdb::params::ssl_key_path,
15+
$ssl_ca_cert_path = $puppetdb::params::ssl_ca_cert_path,
16+
$ssl_deploy_certs = $puppetdb::params::ssl_deploy_certs,
17+
$ssl_key = $puppetdb::params::ssl_key,
18+
$ssl_cert = $puppetdb::params::ssl_cert,
19+
$ssl_ca_cert = $puppetdb::params::ssl_ca_cert,
20+
$ssl_protocols = $puppetdb::params::ssl_protocols,
21+
$manage_dbserver = $puppetdb::params::manage_dbserver,
22+
$manage_package_repo = $puppetdb::params::manage_pg_repo,
23+
$postgres_version = $puppetdb::params::postgres_version,
24+
$database = $puppetdb::params::database,
25+
$database_host = $puppetdb::params::database_host,
26+
$database_port = $puppetdb::params::database_port,
27+
$database_username = $puppetdb::params::database_username,
28+
$database_password = $puppetdb::params::database_password,
29+
$database_name = $puppetdb::params::database_name,
30+
$database_ssl = $puppetdb::params::database_ssl,
31+
$database_listen_address = $puppetdb::params::postgres_listen_addresses,
32+
$database_validate = $puppetdb::params::database_validate,
33+
$node_ttl = $puppetdb::params::node_ttl,
34+
$node_purge_ttl = $puppetdb::params::node_purge_ttl,
35+
$report_ttl = $puppetdb::params::report_ttl,
36+
$gc_interval = $puppetdb::params::gc_interval,
37+
$log_slow_statements = $puppetdb::params::log_slow_statements,
38+
$conn_max_age = $puppetdb::params::conn_max_age,
39+
$conn_keep_alive = $puppetdb::params::conn_keep_alive,
40+
$conn_lifetime = $puppetdb::params::conn_lifetime,
41+
$puppetdb_package = $puppetdb::params::puppetdb_package,
42+
$puppetdb_version = $puppetdb::params::puppetdb_version,
43+
$puppetdb_service = $puppetdb::params::puppetdb_service,
44+
$puppetdb_service_status = $puppetdb::params::puppetdb_service_status,
45+
$puppetdb_user = $puppetdb::params::puppetdb_user,
46+
$puppetdb_group = $puppetdb::params::puppetdb_group,
47+
$read_database = $puppetdb::params::read_database,
48+
$read_database_host = $puppetdb::params::read_database_host,
49+
$read_database_port = $puppetdb::params::read_database_port,
50+
$read_database_username = $puppetdb::params::read_database_username,
51+
$read_database_password = $puppetdb::params::read_database_password,
52+
$read_database_name = $puppetdb::params::read_database_name,
53+
$read_database_ssl = $puppetdb::params::read_database_ssl,
54+
$read_database_validate = $puppetdb::params::read_database_validate,
55+
$read_log_slow_statements = $puppetdb::params::read_log_slow_statements,
56+
$read_conn_max_age = $puppetdb::params::read_conn_max_age,
57+
$read_conn_keep_alive = $puppetdb::params::read_conn_keep_alive,
58+
$read_conn_lifetime = $puppetdb::params::read_conn_lifetime,
59+
$confdir = $puppetdb::params::confdir,
60+
$manage_firewall = $puppetdb::params::manage_firewall,
61+
$java_args = $puppetdb::params::java_args,
62+
$max_threads = $puppetdb::params::max_threads,
6163
) inherits puppetdb::params {
6264

63-
class { 'puppetdb::server':
64-
listen_address => $listen_address,
65-
listen_port => $listen_port,
66-
open_listen_port => $open_listen_port,
67-
ssl_listen_address => $ssl_listen_address,
68-
ssl_listen_port => $ssl_listen_port,
69-
disable_ssl => $disable_ssl,
70-
open_ssl_listen_port => $open_ssl_listen_port,
71-
ssl_dir => $ssl_dir,
72-
ssl_set_cert_paths => $ssl_set_cert_paths,
73-
ssl_cert_path => $ssl_cert_path,
74-
ssl_key_path => $ssl_key_path,
75-
ssl_ca_cert_path => $ssl_ca_cert_path,
76-
ssl_deploy_certs => $ssl_deploy_certs,
77-
ssl_key => $ssl_key,
78-
ssl_cert => $ssl_cert,
79-
ssl_ca_cert => $ssl_ca_cert,
80-
ssl_protocols => $ssl_protocols,
81-
database => $database,
82-
database_host => $database_host,
83-
database_port => $database_port,
84-
database_username => $database_username,
85-
database_password => $database_password,
86-
database_name => $database_name,
87-
database_ssl => $database_ssl,
88-
database_validate => $database_validate,
89-
node_ttl => $node_ttl,
90-
node_purge_ttl => $node_purge_ttl,
91-
report_ttl => $report_ttl,
92-
gc_interval => $gc_interval,
93-
log_slow_statements => $log_slow_statements,
94-
conn_max_age => $conn_max_age,
95-
conn_keep_alive => $conn_keep_alive,
96-
conn_lifetime => $conn_lifetime,
97-
puppetdb_package => $puppetdb_package,
98-
puppetdb_version => $puppetdb_version,
99-
puppetdb_service => $puppetdb_service,
100-
puppetdb_service_status => $puppetdb_service_status,
101-
confdir => $confdir,
102-
java_args => $java_args,
103-
max_threads => $max_threads,
104-
read_database => $read_database,
105-
read_database_host => $read_database_host,
106-
read_database_port => $read_database_port,
107-
read_database_username => $read_database_username,
108-
read_database_password => $read_database_password,
109-
read_database_name => $read_database_name,
110-
read_database_ssl => $read_database_ssl,
111-
read_database_validate => $read_database_validate,
112-
read_log_slow_statements => $read_log_slow_statements,
113-
read_conn_max_age => $read_conn_max_age,
114-
read_conn_keep_alive => $read_conn_keep_alive,
115-
read_conn_lifetime => $read_conn_lifetime,
116-
puppetdb_user => $puppetdb_user,
117-
puppetdb_group => $puppetdb_group,
118-
manage_firewall => $manage_firewall,
65+
class { '::puppetdb::server':
66+
listen_address => $listen_address,
67+
listen_port => $listen_port,
68+
open_listen_port => $open_listen_port,
69+
ssl_listen_address => $ssl_listen_address,
70+
ssl_listen_port => $ssl_listen_port,
71+
disable_ssl => $disable_ssl,
72+
open_ssl_listen_port => $open_ssl_listen_port,
73+
ssl_dir => $ssl_dir,
74+
ssl_set_cert_paths => $ssl_set_cert_paths,
75+
ssl_cert_path => $ssl_cert_path,
76+
ssl_key_path => $ssl_key_path,
77+
ssl_ca_cert_path => $ssl_ca_cert_path,
78+
ssl_deploy_certs => $ssl_deploy_certs,
79+
ssl_key => $ssl_key,
80+
ssl_cert => $ssl_cert,
81+
ssl_ca_cert => $ssl_ca_cert,
82+
ssl_protocols => $ssl_protocols,
83+
database => $database,
84+
database_host => $database_host,
85+
database_port => $database_port,
86+
database_username => $database_username,
87+
database_password => $database_password,
88+
database_name => $database_name,
89+
database_ssl => $database_ssl,
90+
database_validate => $database_validate,
91+
node_ttl => $node_ttl,
92+
node_purge_ttl => $node_purge_ttl,
93+
report_ttl => $report_ttl,
94+
gc_interval => $gc_interval,
95+
log_slow_statements => $log_slow_statements,
96+
conn_max_age => $conn_max_age,
97+
conn_keep_alive => $conn_keep_alive,
98+
conn_lifetime => $conn_lifetime,
99+
puppetdb_package => $puppetdb_package,
100+
puppetdb_version => $puppetdb_version,
101+
puppetdb_service => $puppetdb_service,
102+
puppetdb_service_status => $puppetdb_service_status,
103+
confdir => $confdir,
104+
java_args => $java_args,
105+
max_threads => $max_threads,
106+
read_database => $read_database,
107+
read_database_host => $read_database_host,
108+
read_database_port => $read_database_port,
109+
read_database_username => $read_database_username,
110+
read_database_password => $read_database_password,
111+
read_database_name => $read_database_name,
112+
read_database_ssl => $read_database_ssl,
113+
read_database_validate => $read_database_validate,
114+
read_log_slow_statements => $read_log_slow_statements,
115+
read_conn_max_age => $read_conn_max_age,
116+
read_conn_keep_alive => $read_conn_keep_alive,
117+
read_conn_lifetime => $read_conn_lifetime,
118+
puppetdb_user => $puppetdb_user,
119+
puppetdb_group => $puppetdb_group,
120+
manage_firewall => $manage_firewall,
119121
}
120122

121123
if ($database == 'postgres') {
122-
class { 'puppetdb::database::postgresql':
123-
listen_addresses => $database_listen_address,
124-
database_name => $database_name,
125-
database_username => $database_username,
126-
database_password => $database_password,
127-
manage_server => $manage_dbserver,
128-
before => [Class['puppetdb::server'], Class['puppetdb::server::validate_db']],
124+
class { '::puppetdb::database::postgresql':
125+
listen_addresses => $database_listen_address,
126+
database_name => $database_name,
127+
database_username => $database_username,
128+
database_password => $database_password,
129+
manage_server => $manage_dbserver,
130+
manage_package_repo => $manage_package_repo,
131+
postgres_version => $postgres_version,
132+
before => [Class['::puppetdb::server'], Class['::puppetdb::server::validate_db']],
129133
}
130134
}
131135
}

manifests/params.pp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
$manage_dbserver = true
1717

1818
# The remaining database settings are not used for an embedded database
19-
$database_host = 'localhost'
20-
$database_port = '5432'
21-
$database_name = 'puppetdb'
22-
$database_username = 'puppetdb'
23-
$database_password = 'puppetdb'
24-
$database_ssl = false
25-
$database_validate = true
19+
$database_host = 'localhost'
20+
$database_port = '5432'
21+
$database_name = 'puppetdb'
22+
$database_username = 'puppetdb'
23+
$database_password = 'puppetdb'
24+
$database_ssl = false
25+
$database_validate = true
26+
$postgres_version = '9.4'
27+
$manage_pg_repo = false
2628

2729
# These settings manage the various auto-deactivation and auto-purge settings
2830
$node_ttl = '0s'

0 commit comments

Comments
 (0)