freighthop 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (270) hide show
  1. data/Puppetfile +1 -0
  2. data/Puppetfile.lock +3 -0
  3. data/Vagrantfile +1 -1
  4. data/bin/fh +2 -78
  5. data/lib/freighthop/cli/help.rb +69 -0
  6. data/lib/freighthop/cli/ssh.rb +46 -0
  7. data/lib/freighthop/cli/vagrant.rb +26 -0
  8. data/lib/freighthop/cli.rb +40 -0
  9. data/lib/freighthop/config.rb +4 -0
  10. data/lib/freighthop/vagrant_env.rb +24 -0
  11. data/lib/freighthop/version.rb +1 -1
  12. data/lib/freighthop.rb +7 -4
  13. data/local_modules/freighthop/manifests/database/mysql.pp +20 -0
  14. data/local_modules/freighthop/manifests/database/postgres.pp +6 -6
  15. data/local_modules/freighthop/manifests/database.pp +6 -8
  16. data/local_modules/freighthop/manifests/init.pp +1 -8
  17. data/local_modules/freighthop/manifests/params.pp +0 -3
  18. data/modules/apt/CHANGELOG +12 -2
  19. data/modules/apt/Gemfile +6 -5
  20. data/modules/apt/Gemfile.lock +40 -5
  21. data/modules/apt/Modulefile +1 -1
  22. data/modules/apt/README.md +2 -1
  23. data/modules/apt/Rakefile +1 -0
  24. data/modules/apt/manifests/init.pp +4 -1
  25. data/modules/apt/manifests/ppa.pp +1 -1
  26. data/modules/apt/manifests/update.pp +1 -0
  27. data/modules/apt/metadata.json +21 -13
  28. data/modules/apt/spec/defines/ppa_spec.rb +3 -3
  29. data/modules/apt/spec/defines/source_spec.rb +2 -2
  30. data/modules/apt/spec/spec_helper_system.rb +30 -0
  31. data/modules/apt/spec/system/apt_builddep_spec.rb +38 -0
  32. data/modules/apt/spec/system/apt_key_spec.rb +53 -0
  33. data/modules/apt/spec/system/apt_ppa_spec.rb +59 -0
  34. data/modules/apt/spec/system/apt_source_spec.rb +51 -0
  35. data/modules/apt/spec/system/basic_spec.rb +10 -0
  36. data/modules/apt/spec/system/class_spec.rb +20 -0
  37. data/modules/apt/templates/source.list.erb +2 -2
  38. data/modules/freighthop/manifests/database/mysql.pp +20 -0
  39. data/modules/freighthop/manifests/database/postgres.pp +6 -6
  40. data/modules/freighthop/manifests/database.pp +6 -8
  41. data/modules/freighthop/manifests/init.pp +1 -8
  42. data/modules/freighthop/manifests/params.pp +0 -3
  43. data/modules/mysql/CHANGELOG +403 -0
  44. data/modules/mysql/Gemfile +24 -0
  45. data/modules/mysql/Gemfile.lock +129 -0
  46. data/modules/mysql/LICENSE +201 -0
  47. data/modules/mysql/Modulefile +9 -0
  48. data/modules/mysql/README.md +492 -0
  49. data/modules/mysql/Rakefile +2 -0
  50. data/modules/mysql/TODO +8 -0
  51. data/modules/mysql/files/mysqltuner.pl +966 -0
  52. data/modules/mysql/lib/puppet/parser/functions/mysql_deepmerge.rb +52 -0
  53. data/modules/mysql/lib/puppet/parser/functions/mysql_password.rb +15 -0
  54. data/modules/mysql/lib/puppet/parser/functions/mysql_strip_hash.rb +21 -0
  55. data/modules/mysql/lib/puppet/provider/database/mysql.rb +52 -0
  56. data/modules/mysql/lib/puppet/provider/database_grant/mysql.rb +210 -0
  57. data/modules/mysql/lib/puppet/provider/database_user/mysql.rb +76 -0
  58. data/modules/mysql/lib/puppet/provider/mysql.rb +67 -0
  59. data/modules/mysql/lib/puppet/provider/mysql_database/mysql.rb +68 -0
  60. data/modules/mysql/lib/puppet/provider/mysql_grant/mysql.rb +115 -0
  61. data/modules/mysql/lib/puppet/provider/mysql_user/mysql.rb +115 -0
  62. data/modules/mysql/lib/puppet/type/database.rb +21 -0
  63. data/modules/mysql/lib/puppet/type/database_grant.rb +79 -0
  64. data/modules/mysql/lib/puppet/type/database_user.rb +31 -0
  65. data/modules/mysql/lib/puppet/type/mysql_database.rb +22 -0
  66. data/modules/mysql/lib/puppet/type/mysql_grant.rb +72 -0
  67. data/modules/mysql/lib/puppet/type/mysql_user.rb +45 -0
  68. data/modules/mysql/manifests/backup.pp +31 -0
  69. data/modules/mysql/manifests/bindings/java.pp +10 -0
  70. data/modules/mysql/manifests/bindings/perl.pp +10 -0
  71. data/modules/mysql/manifests/bindings/php.pp +10 -0
  72. data/modules/mysql/manifests/bindings/python.pp +10 -0
  73. data/modules/mysql/manifests/bindings/ruby.pp +10 -0
  74. data/modules/mysql/manifests/bindings.pp +33 -0
  75. data/modules/mysql/manifests/client/install.pp +8 -0
  76. data/modules/mysql/manifests/client.pp +27 -0
  77. data/modules/mysql/manifests/db.pp +59 -0
  78. data/modules/mysql/manifests/init.pp +100 -0
  79. data/modules/mysql/manifests/params.pp +230 -0
  80. data/modules/mysql/manifests/server/account_security.pp +22 -0
  81. data/modules/mysql/manifests/server/backup.pp +56 -0
  82. data/modules/mysql/manifests/server/config.pp +31 -0
  83. data/modules/mysql/manifests/server/install.pp +9 -0
  84. data/modules/mysql/manifests/server/monitor.pp +24 -0
  85. data/modules/mysql/manifests/server/mysqltuner.pp +9 -0
  86. data/modules/mysql/manifests/server/providers.pp +8 -0
  87. data/modules/mysql/manifests/server/root_password.pp +21 -0
  88. data/modules/mysql/manifests/server/service.pp +19 -0
  89. data/modules/mysql/manifests/server.pp +69 -0
  90. data/modules/mysql/metadata.json +289 -0
  91. data/modules/mysql/spec/classes/mysql_bindings_spec.rb +58 -0
  92. data/modules/mysql/spec/classes/mysql_client_spec.rb +16 -0
  93. data/modules/mysql/spec/classes/mysql_server_account_security_spec.rb +41 -0
  94. data/modules/mysql/spec/classes/mysql_server_backup_spec.rb +112 -0
  95. data/modules/mysql/spec/classes/mysql_server_monitor_spec.rb +31 -0
  96. data/modules/mysql/spec/classes/mysql_server_mysqltuner_spec.rb +5 -0
  97. data/modules/mysql/spec/classes/mysql_server_spec.rb +162 -0
  98. data/modules/mysql/spec/defines/mysql_db_spec.rb +51 -0
  99. data/modules/mysql/spec/spec.opts +6 -0
  100. data/modules/mysql/spec/spec_helper.rb +5 -0
  101. data/modules/mysql/spec/spec_helper_system.rb +28 -0
  102. data/modules/mysql/spec/system/mysql_account_delete_spec.rb +35 -0
  103. data/modules/mysql/spec/system/mysql_backup_spec.rb +77 -0
  104. data/modules/mysql/spec/system/mysql_bindings_spec.rb +90 -0
  105. data/modules/mysql/spec/system/mysql_db_spec.rb +61 -0
  106. data/modules/mysql/spec/system/mysql_server_monitor_spec.rb +30 -0
  107. data/modules/mysql/spec/system/mysql_server_root_password_spec.rb +71 -0
  108. data/modules/mysql/spec/system/mysql_server_spec.rb +85 -0
  109. data/modules/mysql/spec/system/types/mysql_grant_spec.rb +314 -0
  110. data/modules/mysql/spec/system/types/mysql_user_spec.rb +35 -0
  111. data/modules/mysql/spec/unit/mysql_password_spec.rb +27 -0
  112. data/modules/mysql/spec/unit/puppet/functions/mysql_deepmerge_spec.rb +77 -0
  113. data/modules/mysql/spec/unit/puppet/provider/database/mysql_spec.rb +86 -0
  114. data/modules/mysql/spec/unit/puppet/provider/database_grant/mysql_spec.rb +95 -0
  115. data/modules/mysql/spec/unit/puppet/provider/database_user/mysql_spec.rb +119 -0
  116. data/modules/mysql/spec/unit/puppet/provider/mysql_database/mysql_spec.rb +118 -0
  117. data/modules/mysql/spec/unit/puppet/provider/mysql_user/mysql_spec.rb +130 -0
  118. data/modules/mysql/spec/unit/puppet/type/mysql_database_spec.rb +29 -0
  119. data/modules/mysql/spec/unit/puppet/type/mysql_user_spec.rb +30 -0
  120. data/modules/mysql/templates/my.cnf.erb +17 -0
  121. data/modules/mysql/templates/my.cnf.pass.erb +7 -0
  122. data/modules/mysql/templates/my.conf.cnf.erb +17 -0
  123. data/modules/mysql/templates/mysqlbackup.sh.erb +57 -0
  124. data/modules/mysql/tests/backup.pp +8 -0
  125. data/modules/mysql/tests/bindings.pp +3 -0
  126. data/modules/mysql/tests/init.pp +1 -0
  127. data/modules/mysql/tests/java.pp +1 -0
  128. data/modules/mysql/tests/mysql_database.pp +12 -0
  129. data/modules/mysql/tests/mysql_grant.pp +5 -0
  130. data/modules/mysql/tests/mysql_user.pp +23 -0
  131. data/modules/mysql/tests/perl.pp +1 -0
  132. data/modules/mysql/tests/python.pp +1 -0
  133. data/modules/mysql/tests/ruby.pp +1 -0
  134. data/modules/mysql/tests/server/account_security.pp +4 -0
  135. data/modules/mysql/tests/server/config.pp +11 -0
  136. data/modules/mysql/tests/server.pp +3 -0
  137. data/modules/postgresql/Changelog +191 -0
  138. data/modules/postgresql/Gemfile +1 -0
  139. data/modules/postgresql/Gemfile.lock +9 -0
  140. data/modules/postgresql/LICENSE +198 -12
  141. data/modules/postgresql/Modulefile +2 -2
  142. data/modules/postgresql/NOTICE +14 -0
  143. data/modules/postgresql/README.md +435 -184
  144. data/modules/postgresql/files/validate_postgresql_connection.sh +31 -0
  145. data/modules/postgresql/lib/puppet/provider/postgresql_conf/parsed.rb +37 -0
  146. data/modules/postgresql/lib/puppet/provider/postgresql_psql/ruby.rb +4 -0
  147. data/modules/postgresql/lib/puppet/type/postgresql_conf.rb +31 -0
  148. data/modules/postgresql/lib/puppet/type/postgresql_psql.rb +4 -0
  149. data/modules/postgresql/manifests/client.pp +17 -16
  150. data/modules/postgresql/manifests/globals.pp +95 -0
  151. data/modules/postgresql/manifests/lib/devel.pp +15 -0
  152. data/modules/postgresql/manifests/lib/java.pp +15 -0
  153. data/modules/postgresql/manifests/lib/python.pp +13 -0
  154. data/modules/postgresql/manifests/params.pp +127 -222
  155. data/modules/postgresql/manifests/repo/apt_postgresql_org.pp +30 -0
  156. data/modules/postgresql/manifests/repo/yum_postgresql_org.pp +38 -0
  157. data/modules/postgresql/manifests/repo.pp +22 -0
  158. data/modules/postgresql/manifests/server/config.pp +113 -0
  159. data/modules/postgresql/manifests/server/config_entry.pp +43 -0
  160. data/modules/postgresql/manifests/server/contrib.pp +27 -0
  161. data/modules/postgresql/manifests/server/database.pp +75 -0
  162. data/modules/postgresql/manifests/server/database_grant.pp +18 -0
  163. data/modules/postgresql/manifests/server/db.pp +36 -0
  164. data/modules/postgresql/manifests/server/firewall.pp +21 -0
  165. data/modules/postgresql/manifests/server/grant.pp +81 -0
  166. data/modules/postgresql/manifests/server/initdb.pp +52 -0
  167. data/modules/postgresql/manifests/server/install.pp +49 -0
  168. data/modules/postgresql/manifests/server/passwd.pp +34 -0
  169. data/modules/postgresql/manifests/server/pg_hba_rule.pp +54 -0
  170. data/modules/postgresql/manifests/server/plperl.pp +27 -0
  171. data/modules/postgresql/manifests/server/reload.pp +15 -0
  172. data/modules/postgresql/manifests/{role.pp → server/role.pp} +19 -33
  173. data/modules/postgresql/manifests/server/service.pp +40 -0
  174. data/modules/postgresql/manifests/{table_grant.pp → server/table_grant.pp} +4 -4
  175. data/modules/postgresql/manifests/server/tablespace.pp +42 -0
  176. data/modules/postgresql/manifests/server.pp +61 -83
  177. data/modules/postgresql/manifests/validate_db_connection.pp +49 -50
  178. data/modules/postgresql/metadata.json +123 -73
  179. data/modules/postgresql/spec/spec_helper_system.rb +13 -1
  180. data/modules/postgresql/spec/system/client_spec.rb +22 -0
  181. data/modules/postgresql/spec/system/common_patterns_spec.rb +53 -0
  182. data/modules/postgresql/spec/system/contrib_spec.rb +33 -0
  183. data/modules/postgresql/spec/system/lib/devel_spec.rb +22 -0
  184. data/modules/postgresql/spec/system/lib/java_spec.rb +25 -0
  185. data/modules/postgresql/spec/system/lib/python_spec.rb +24 -0
  186. data/modules/postgresql/spec/system/postgresql_psql_spec.rb +51 -0
  187. data/modules/postgresql/spec/system/server/config_entry_spec.rb +32 -0
  188. data/modules/postgresql/spec/system/server/database_grant_spec.rb +54 -0
  189. data/modules/postgresql/spec/system/server/database_spec.rb +35 -0
  190. data/modules/postgresql/spec/system/server/db_spec.rb +143 -0
  191. data/modules/postgresql/spec/system/server/grant_spec.rb +55 -0
  192. data/modules/postgresql/spec/system/server/pg_hba_rule_spec.rb +85 -0
  193. data/modules/postgresql/spec/system/server/plperl_spec.rb +29 -0
  194. data/modules/postgresql/spec/system/server/role_spec.rb +103 -0
  195. data/modules/postgresql/spec/system/server/table_grant_spec.rb +72 -0
  196. data/modules/postgresql/spec/system/server/tablespace_spec.rb +74 -0
  197. data/modules/postgresql/spec/system/server_spec.rb +217 -0
  198. data/modules/postgresql/spec/system/validate_db_connection_spec.rb +91 -0
  199. data/modules/postgresql/spec/unit/classes/client_spec.rb +27 -2
  200. data/modules/postgresql/spec/unit/classes/globals_spec.rb +28 -0
  201. data/modules/postgresql/spec/unit/classes/lib/devel_spec.rb +12 -0
  202. data/modules/postgresql/spec/unit/classes/{postgresql_java_spec.rb → lib/java_spec.rb} +9 -19
  203. data/modules/postgresql/spec/unit/classes/lib/python_spec.rb +31 -0
  204. data/modules/postgresql/spec/unit/classes/params_spec.rb +2 -1
  205. data/modules/postgresql/spec/unit/classes/repo_spec.rb +17 -0
  206. data/modules/postgresql/spec/unit/classes/server/contrib_spec.rb +42 -0
  207. data/modules/postgresql/spec/unit/classes/server/initdb_spec.rb +28 -0
  208. data/modules/postgresql/spec/unit/classes/server/plperl_spec.rb +45 -0
  209. data/modules/postgresql/spec/unit/classes/server_spec.rb +83 -2
  210. data/modules/postgresql/spec/unit/defines/server/config_entry_spec.rb +23 -0
  211. data/modules/postgresql/spec/unit/defines/server/database_grant_spec.rb +26 -0
  212. data/modules/postgresql/spec/unit/defines/server/database_spec.rb +16 -0
  213. data/modules/postgresql/spec/unit/defines/server/db_spec.rb +28 -0
  214. data/modules/postgresql/spec/unit/defines/{database_grant_spec.rb → server/grant_spec.rb} +7 -4
  215. data/modules/postgresql/spec/unit/defines/{pg_hba_rule_spec.rb → server/pg_hba_rule_spec.rb} +59 -2
  216. data/modules/postgresql/spec/unit/defines/server/role_spec.rb +23 -0
  217. data/modules/postgresql/spec/unit/defines/server/table_grant_spec.rb +27 -0
  218. data/modules/postgresql/spec/unit/defines/server/tablespace_spec.rb +23 -0
  219. data/modules/postgresql/spec/unit/defines/validate_db_connection_spec.rb +22 -9
  220. data/modules/postgresql/spec/unit/provider/postgresql_conf/parsed_spec.rb +112 -0
  221. data/modules/postgresql/spec/unit/puppet/provider/postgresql_psql/ruby_spec.rb +29 -0
  222. data/modules/postgresql/spec/unit/puppet/type/postgresql_psql_spec.rb +1 -0
  223. data/modules/postgresql/spec/unit/type/postgresql_conf_spec.rb +50 -0
  224. metadata +177 -53
  225. data/modules/postgresql/examples/init.pp +0 -1
  226. data/modules/postgresql/examples/official-postgresql-repos.pp +0 -19
  227. data/modules/postgresql/examples/postgresql_database.pp +0 -22
  228. data/modules/postgresql/examples/postgresql_db.pp +0 -30
  229. data/modules/postgresql/examples/postgresql_grant.pp +0 -14
  230. data/modules/postgresql/examples/postgresql_pg_hba_rule.pp +0 -18
  231. data/modules/postgresql/examples/postgresql_pgconf_extras.pp +0 -19
  232. data/modules/postgresql/examples/postgresql_tablespace.pp +0 -73
  233. data/modules/postgresql/examples/postgresql_user.pp +0 -28
  234. data/modules/postgresql/examples/server.pp +0 -10
  235. data/modules/postgresql/lib/facter/postgres_default_version.rb +0 -69
  236. data/modules/postgresql/manifests/config/afterservice.pp +0 -47
  237. data/modules/postgresql/manifests/config/beforeservice.pp +0 -171
  238. data/modules/postgresql/manifests/config.pp +0 -74
  239. data/modules/postgresql/manifests/contrib.pp +0 -29
  240. data/modules/postgresql/manifests/database.pp +0 -85
  241. data/modules/postgresql/manifests/database_grant.pp +0 -35
  242. data/modules/postgresql/manifests/database_user.pp +0 -60
  243. data/modules/postgresql/manifests/db.pp +0 -77
  244. data/modules/postgresql/manifests/devel.pp +0 -27
  245. data/modules/postgresql/manifests/grant.pp +0 -77
  246. data/modules/postgresql/manifests/init.pp +0 -145
  247. data/modules/postgresql/manifests/initdb.pp +0 -52
  248. data/modules/postgresql/manifests/java.pp +0 -29
  249. data/modules/postgresql/manifests/package_source/apt_postgresql_org.pp +0 -21
  250. data/modules/postgresql/manifests/package_source/yum_postgresql_org.pp +0 -30
  251. data/modules/postgresql/manifests/pg_hba.pp +0 -19
  252. data/modules/postgresql/manifests/pg_hba_rule.pp +0 -41
  253. data/modules/postgresql/manifests/plperl.pp +0 -24
  254. data/modules/postgresql/manifests/psql.pp +0 -56
  255. data/modules/postgresql/manifests/python.pp +0 -18
  256. data/modules/postgresql/manifests/tablespace.pp +0 -59
  257. data/modules/postgresql/spec/system/install_spec.rb +0 -707
  258. data/modules/postgresql/spec/system/non_defaults_spec.rb +0 -114
  259. data/modules/postgresql/spec/unit/classes/contrib_spec.rb +0 -11
  260. data/modules/postgresql/spec/unit/classes/devel_spec.rb +0 -11
  261. data/modules/postgresql/spec/unit/classes/init_spec.rb +0 -71
  262. data/modules/postgresql/spec/unit/classes/postgresql_python_spec.rb +0 -53
  263. data/modules/postgresql/spec/unit/defines/database_spec.rb +0 -14
  264. data/modules/postgresql/spec/unit/defines/database_user_spec.rb +0 -19
  265. data/modules/postgresql/spec/unit/defines/db_spec.rb +0 -20
  266. data/modules/postgresql/spec/unit/defines/pg_hba_spec.rb +0 -20
  267. data/modules/postgresql/spec/unit/defines/psql_spec.rb +0 -20
  268. data/modules/postgresql/spec/unit/defines/role_spec.rb +0 -14
  269. data/modules/postgresql/spec/unit/defines/tablespace_spec.rb +0 -19
  270. data/modules/postgresql/spec/unit/facts/postgres_default_version_spec.rb +0 -14
@@ -1,73 +0,0 @@
1
- class { 'postgresql::server':
2
- config_hash => {
3
- 'ip_mask_deny_postgres_user' => '0.0.0.0/32',
4
- 'ip_mask_allow_all_users' => '0.0.0.0/0',
5
- 'listen_addresses' => '*',
6
- 'manage_redhat_firewall' => true,
7
- 'postgres_password' => 'postgres',
8
- },
9
- }
10
-
11
- file { '/tmp':
12
- ensure => 'directory',
13
- }
14
- file { '/tmp/pg_tablespaces':
15
- ensure => 'directory',
16
- owner => 'postgres',
17
- group => 'postgres',
18
- mode => '0700',
19
- require => File['/tmp'],
20
- }
21
-
22
- postgresql::tablespace{ 'tablespace1':
23
- location => '/tmp/pg_tablespaces/space1',
24
- require => [Class['postgresql::server'], File['/tmp/pg_tablespaces']],
25
- }
26
- postgresql::database{ 'tablespacedb1':
27
- # TODO: ensure not yet supported
28
- #ensure => present,
29
- charset => 'utf8',
30
- require => Class['postgresql::server'],
31
- }
32
- postgresql::database{ 'tablespacedb2':
33
- # TODO: ensure not yet supported
34
- #ensure => present,
35
- charset => 'utf8',
36
- tablespace => 'tablespace1',
37
- require => Postgresql::Tablespace['tablespace1'],
38
- }
39
- postgresql::db{ 'tablespacedb3':
40
- # TODO: ensure not yet supported
41
- #ensure => present,
42
- user => 'dbuser1',
43
- password => 'dbuser1',
44
- require => Class['postgresql::server'],
45
- }
46
- postgresql::db{ 'tablespacedb4':
47
- # TODO: ensure not yet supported
48
- #ensure => present,
49
- user => 'dbuser2',
50
- password => 'dbuser2',
51
- tablespace => 'tablespace1',
52
- require => Postgresql::Tablespace['tablespace1'],
53
- }
54
-
55
- postgresql::database_user{ 'spcuser':
56
- # TODO: ensure is not yet supported
57
- #ensure => present,
58
- password_hash => postgresql_password('spcuser', 'spcuser'),
59
- require => Class['postgresql::server'],
60
- }
61
- postgresql::tablespace{ 'tablespace2':
62
- location => '/tmp/pg_tablespaces/space2',
63
- owner => 'spcuser',
64
- require => [Postgresql::Database_user['spcuser'], File['/tmp/pg_tablespaces']],
65
- }
66
- postgresql::database{ 'tablespacedb5':
67
- # TODO: ensure not yet supported
68
- #ensure => present,
69
- charset => 'utf8',
70
- tablespace => 'tablespace2',
71
- require => Postgresql::Tablespace['tablespace2'],
72
- }
73
-
@@ -1,28 +0,0 @@
1
- class { 'postgresql::server':
2
- config_hash => {
3
- 'ip_mask_deny_postgres_user' => '0.0.0.0/32',
4
- 'ip_mask_allow_all_users' => '0.0.0.0/0',
5
- 'listen_addresses' => '*',
6
- 'manage_redhat_firewall' => true,
7
- 'postgres_password' => 'postgres',
8
- },
9
- }
10
-
11
- # TODO: in mysql module, the username includes, e.g., '@%' or '@localhost', which
12
- # affects the user's ability to connect from remote hosts. In postgres this is
13
- # managed via pg_hba.conf; not sure if we want to try to reconcile that difference
14
- # in the modules or not.
15
- postgresql::database_user{ 'redmine':
16
- # TODO: ensure is not yet supported
17
- #ensure => present,
18
- password_hash => postgresql_password('redmine', 'redmine'),
19
- require => Class['postgresql::server'],
20
- }
21
-
22
- postgresql::database_user{ 'dan':
23
- # TODO: ensure is not yet supported
24
- #ensure => present,
25
- password_hash => postgresql_password('dan', 'blah'),
26
- require => Class['postgresql::server'],
27
- }
28
-
@@ -1,10 +0,0 @@
1
- class { 'postgresql::server':
2
- config_hash => {
3
- 'ip_mask_deny_postgres_user' => '0.0.0.0/32',
4
- 'ip_mask_allow_all_users' => '0.0.0.0/0',
5
- 'listen_addresses' => '*',
6
- 'ipv4acls' => ['hostssl all johndoe 192.168.0.0/24 cert'],
7
- 'manage_redhat_firewall' => true,
8
- 'postgres_password' => 'postgres',
9
- },
10
- }
@@ -1,69 +0,0 @@
1
- def get_debianfamily_postgres_version
2
- case Facter.value('operatingsystem')
3
- when "Debian"
4
- get_debian_postgres_version()
5
- when "Ubuntu"
6
- get_ubuntu_postgres_version()
7
- else
8
- nil
9
- end
10
- end
11
-
12
- def get_debian_postgres_version
13
- case Facter.value('operatingsystemrelease')
14
- # TODO: add more debian versions or better logic here
15
- when /^6\./
16
- "8.4"
17
- when /^wheezy/, /^7\./
18
- "9.1"
19
- else
20
- nil
21
- end
22
- end
23
-
24
- def get_ubuntu_postgres_version
25
- case Facter.value('operatingsystemrelease')
26
- when "11.10", "12.04", "12.10", "13.04"
27
- "9.1"
28
- when "10.04", "10.10", "11.04"
29
- "8.4"
30
- else
31
- nil
32
- end
33
- end
34
-
35
- def get_redhatfamily_postgres_version
36
- case Facter.value('operatingsystemrelease')
37
- when /^6\./
38
- "8.4"
39
- when /^5\./
40
- "8.1"
41
- else
42
- nil
43
- end
44
- end
45
-
46
- Facter.add("postgres_default_version") do
47
- setcode do
48
- result =
49
- case Facter.value('osfamily')
50
- when 'RedHat'
51
- get_redhatfamily_postgres_version()
52
- when 'Linux'
53
- get_redhatfamily_postgres_version()
54
- when 'Debian'
55
- get_debianfamily_postgres_version()
56
- else
57
- nil
58
- end
59
-
60
- # TODO: not sure if this is really a great idea, but elsewhere in the code
61
- # it is useful to be able to distinguish between the case where the fact
62
- # does not exist at all (e.g., if pluginsync is not enabled), and the case
63
- # where the fact is not known for the OS in question.
64
- if result == nil
65
- result = 'unknown'
66
- end
67
- result
68
- end
69
- end
@@ -1,47 +0,0 @@
1
- # Class: postgresql::config::afterservice
2
- #
3
- # Parameters:
4
- #
5
- # [*postgres_password*] - postgres db user password.
6
- #
7
- # Actions:
8
- #
9
- # Requires:
10
- #
11
- # Usage:
12
- # This class is not intended to be used directly; it is
13
- # managed by postgresl::config. It contains resources
14
- # that should be handled *after* the postgres service
15
- # has been started up.
16
- #
17
- # class { 'postgresql::config::afterservice':
18
- # postgres_password => 'postgres'
19
- # }
20
- #
21
- class postgresql::config::afterservice(
22
- $postgres_password = undef
23
- ) inherits postgresql::params {
24
-
25
- if ($postgres_password != undef) {
26
- # NOTE: this password-setting logic relies on the pg_hba.conf being configured
27
- # to allow the postgres system user to connect via psql without specifying
28
- # a password ('ident' or 'trust' security). This is the default
29
- # for pg_hba.conf.
30
- $escapedpassword = postgresql_escape($postgres_password)
31
-
32
- exec { 'set_postgres_postgrespw':
33
- # This command works w/no password because we run it as postgres system user
34
- command => "psql -c 'ALTER ROLE \"${postgresql::params::user}\" PASSWORD ${escapedpassword}'",
35
- user => $postgresql::params::user,
36
- group => $postgresql::params::group,
37
- logoutput => true,
38
- cwd => '/tmp',
39
- # With this command we're passing -h to force TCP authentication, which does require
40
- # a password. We specify the password via the PGPASSWORD environment variable. If
41
- # the password is correct (current), this command will exit with an exit code of 0,
42
- # which will prevent the main command from running.
43
- unless => "env PGPASSWORD='${postgres_password}' psql -h localhost -c 'select 1' > /dev/null",
44
- path => '/usr/bin:/usr/local/bin:/bin',
45
- }
46
- }
47
- }
@@ -1,171 +0,0 @@
1
- # Class: postgresql::config::beforeservice
2
- #
3
- # Parameters:
4
- #
5
- # [*firewall_supported*] - Is the firewall supported?
6
- # [*ip_mask_deny_postgres_user*] - ip mask for denying remote access for postgres user; defaults to '0.0.0.0/0',
7
- # meaning that all TCP access for postgres user is denied.
8
- # [*ip_mask_allow_all_users*] - ip mask for allowing remote access for other users (besides postgres);
9
- # defaults to '127.0.0.1/32', meaning only allow connections from localhost
10
- # [*listen_addresses*] - what IP address(es) to listen on; comma-separated list of addresses; defaults to
11
- # 'localhost', '*' = all
12
- # [*ipv4acls*] - list of strings for access control for connection method, users, databases, IPv4
13
- # addresses; see postgresql documentation about pg_hba.conf for information
14
- # [*ipv6acls*] - list of strings for access control for connection method, users, databases, IPv6
15
- # addresses; see postgresql documentation about pg_hba.conf for information
16
- # [*pg_hba_conf_path*] - path to pg_hba.conf file
17
- # [*postgresql_conf_path*] - path to postgresql.conf file
18
- # [*manage_redhat_firewall*] - boolean indicating whether or not the module should open a port in the firewall on
19
- # redhat-based systems; this parameter is likely to change in future versions. Possible
20
- # changes include support for non-RedHat systems and finer-grained control over the
21
- # firewall rule (currently, it simply opens up the postgres port to all TCP connections).
22
- # [*manage_pg_hba_conf*] - boolean indicating whether or not the module manages pg_hba.conf file.
23
- # [*persist_firewall_command*] - Command to persist firewall connections.
24
- #
25
- # Actions:
26
- #
27
- # Requires:
28
- #
29
- # Usage:
30
- # This class is not intended to be used directly; it is
31
- # managed by postgresl::config. It contains resources
32
- # that should be handled *before* the postgres service
33
- # has been started up.
34
- #
35
- # class { 'postgresql::config::before_service':
36
- # ip_mask_allow_all_users => '0.0.0.0/0',
37
- # }
38
- #
39
- class postgresql::config::beforeservice(
40
- $pg_hba_conf_path,
41
- $postgresql_conf_path,
42
- $firewall_supported = $postgresql::params::firewall_supported,
43
- $ip_mask_deny_postgres_user = $postgresql::params::ip_mask_deny_postgres_user,
44
- $ip_mask_allow_all_users = $postgresql::params::ip_mask_allow_all_users,
45
- $listen_addresses = $postgresql::params::listen_addresses,
46
- $ipv4acls = $postgresql::params::ipv4acls,
47
- $ipv6acls = $postgresql::params::ipv6acls,
48
- $manage_redhat_firewall = $postgresql::params::manage_redhat_firewall,
49
- $manage_pg_hba_conf = $postgresql::params::manage_pg_hba_conf,
50
- $persist_firewall_command = $postgresql::params::persist_firewall_command,
51
- ) inherits postgresql::params {
52
-
53
-
54
- File {
55
- owner => $postgresql::params::user,
56
- group => $postgresql::params::group,
57
- }
58
-
59
- if $manage_pg_hba_conf {
60
- # Create the main pg_hba resource
61
- postgresql::pg_hba { 'main':
62
- notify => Exec['reload_postgresql'],
63
- }
64
-
65
- Postgresql::Pg_hba_rule {
66
- database => 'all',
67
- user => 'all',
68
- }
69
-
70
- # Lets setup the base rules
71
- $auth_option = $postgresql::params::version ? {
72
- '8.1' => 'sameuser',
73
- default => undef,
74
- }
75
-
76
- postgresql::pg_hba_rule { 'local access as postgres user':
77
- type => 'local',
78
- user => $postgresql::params::user,
79
- auth_method => 'ident',
80
- auth_option => $auth_option,
81
- order => '001',
82
- }
83
- postgresql::pg_hba_rule { 'local access to database with same name':
84
- type => 'local',
85
- auth_method => 'ident',
86
- auth_option => $auth_option,
87
- order => '002',
88
- }
89
- postgresql::pg_hba_rule { 'deny access to postgresql user':
90
- type => 'host',
91
- user => $postgresql::params::user,
92
- address => $ip_mask_deny_postgres_user,
93
- auth_method => 'reject',
94
- order => '003',
95
- }
96
-
97
- # ipv4acls are passed as an array of rule strings, here we transform them into
98
- # a resources hash, and pass the result to create_resources
99
- $ipv4acl_resources = postgresql_acls_to_resources_hash($ipv4acls, 'ipv4acls', 10)
100
- create_resources('postgresql::pg_hba_rule', $ipv4acl_resources)
101
-
102
- postgresql::pg_hba_rule { 'allow access to all users':
103
- type => 'host',
104
- address => $ip_mask_allow_all_users,
105
- auth_method => 'md5',
106
- order => '100',
107
- }
108
- postgresql::pg_hba_rule { 'allow access to ipv6 localhost':
109
- type => 'host',
110
- address => '::1/128',
111
- auth_method => 'md5',
112
- order => '101',
113
- }
114
-
115
- # ipv6acls are passed as an array of rule strings, here we transform them into
116
- # a resources hash, and pass the result to create_resources
117
- $ipv6acl_resources = postgresql_acls_to_resources_hash($ipv6acls, 'ipv6acls', 102)
118
- create_resources('postgresql::pg_hba_rule', $ipv6acl_resources)
119
- }
120
-
121
- # We must set a "listen_addresses" line in the postgresql.conf if we
122
- # want to allow any connections from remote hosts.
123
- file_line { 'postgresql.conf#listen_addresses':
124
- path => $postgresql_conf_path,
125
- match => '^listen_addresses\s*=.*$',
126
- line => "listen_addresses = '${listen_addresses}'",
127
- notify => Service['postgresqld'],
128
- }
129
-
130
- # Here we are adding an 'include' line so that users have the option of
131
- # managing their own settings in a second conf file. This only works for
132
- # postgresql 8.2 and higher.
133
- if(versioncmp($postgresql::params::version, '8.2') >= 0) {
134
- # Since we're adding an "include" for this extras config file, we need
135
- # to make sure it exists.
136
- exec { 'create_postgresql_conf_path':
137
- command => "touch `dirname ${postgresql_conf_path}`/postgresql_puppet_extras.conf",
138
- path => '/usr/bin:/bin',
139
- unless => "[ -f `dirname ${postgresql_conf_path}`/postgresql_puppet_extras.conf ]"
140
- }
141
-
142
- file_line { 'postgresql.conf#include':
143
- path => $postgresql_conf_path,
144
- line => 'include \'postgresql_puppet_extras.conf\'',
145
- require => Exec['create_postgresql_conf_path'],
146
- notify => Service['postgresqld'],
147
- }
148
- }
149
-
150
-
151
- # TODO: is this a reasonable place for this firewall stuff?
152
- # TODO: figure out a way to make this not platform-specific; debian and ubuntu have
153
- # an out-of-the-box firewall configuration that seems trickier to manage
154
- # TODO: get rid of hard-coded port
155
- if ( $manage_redhat_firewall and $firewall_supported ) {
156
- exec { 'postgresql-persist-firewall':
157
- command => $persist_firewall_command,
158
- refreshonly => true,
159
- }
160
-
161
- Firewall {
162
- notify => Exec['postgresql-persist-firewall']
163
- }
164
-
165
- firewall { '5432 accept - postgres':
166
- port => '5432',
167
- proto => 'tcp',
168
- action => 'accept',
169
- }
170
- }
171
- }
@@ -1,74 +0,0 @@
1
- # Class: postgresql::config
2
- #
3
- # Parameters:
4
- #
5
- # [*postgres_password*] - postgres db user password.
6
- # [*ip_mask_deny_postgres_user*] - ip mask for denying remote access for postgres user; defaults to '0.0.0.0/0',
7
- # meaning that all TCP access for postgres user is denied.
8
- # [*ip_mask_allow_all_users*] - ip mask for allowing remote access for other users (besides postgres);
9
- # defaults to '127.0.0.1/32', meaning only allow connections from localhost
10
- # [*listen_addresses*] - what IP address(es) to listen on; comma-separated list of addresses; defaults to
11
- # 'localhost', '*' = all
12
- # [*ipv4acls*] - list of strings for access control for connection method, users, databases, IPv4
13
- # addresses; see postgresql documentation about pg_hba.conf for information
14
- # [*ipv6acls*] - list of strings for access control for connection method, users, databases, IPv6
15
- # addresses; see postgresql documentation about pg_hba.conf for information
16
- # [*pg_hba_conf_path*] - path to pg_hba.conf file
17
- # [*postgresql_conf_path*] - path to postgresql.conf file
18
- # [*manage_redhat_firewall*] - boolean indicating whether or not the module should open a port in the firewall on
19
- # redhat-based systems; this parameter is likely to change in future versions. Possible
20
- # changes include support for non-RedHat systems and finer-grained control over the
21
- # firewall rule (currently, it simply opens up the postgres port to all TCP connections).
22
- # [*manage_pg_hba_conf*] - boolean indicating whether or not the module manages pg_hba.conf file.
23
- #
24
- #
25
- # Actions:
26
- #
27
- # Requires:
28
- #
29
- # Usage:
30
- #
31
- # class { 'postgresql::config':
32
- # postgres_password => 'postgres',
33
- # ip_mask_allow_all_users => '0.0.0.0/0',
34
- # }
35
- #
36
- class postgresql::config(
37
- $postgres_password = undef,
38
- $ip_mask_deny_postgres_user = $postgresql::params::ip_mask_deny_postgres_user,
39
- $ip_mask_allow_all_users = $postgresql::params::ip_mask_allow_all_users,
40
- $listen_addresses = $postgresql::params::listen_addresses,
41
- $ipv4acls = $postgresql::params::ipv4acls,
42
- $ipv6acls = $postgresql::params::ipv6acls,
43
- $pg_hba_conf_path = $postgresql::params::pg_hba_conf_path,
44
- $postgresql_conf_path = $postgresql::params::postgresql_conf_path,
45
- $manage_redhat_firewall = $postgresql::params::manage_redhat_firewall,
46
- $manage_pg_hba_conf = $postgresql::params::manage_pg_hba_conf
47
- ) inherits postgresql::params {
48
-
49
- # Basically, all this class needs to handle is passing parameters on
50
- # to the "beforeservice" and "afterservice" classes, and ensure
51
- # the proper ordering.
52
-
53
- class { 'postgresql::config::beforeservice':
54
- ip_mask_deny_postgres_user => $ip_mask_deny_postgres_user,
55
- ip_mask_allow_all_users => $ip_mask_allow_all_users,
56
- listen_addresses => $listen_addresses,
57
- ipv4acls => $ipv4acls,
58
- ipv6acls => $ipv6acls,
59
- pg_hba_conf_path => $pg_hba_conf_path,
60
- postgresql_conf_path => $postgresql_conf_path,
61
- manage_redhat_firewall => $manage_redhat_firewall,
62
- manage_pg_hba_conf => $manage_pg_hba_conf,
63
- }
64
-
65
- class { 'postgresql::config::afterservice':
66
- postgres_password => $postgres_password,
67
- }
68
-
69
- Class['postgresql::config'] ->
70
- Class['postgresql::config::beforeservice'] ->
71
- Service['postgresqld'] ->
72
- Class['postgresql::config::afterservice']
73
-
74
- }
@@ -1,29 +0,0 @@
1
- # Class: postgresql::contrib
2
- #
3
- # This class installs the postgresql contrib package.
4
- #
5
- # Parameters:
6
- # [*package_name*] - The name of the postgresql contrib package.
7
- # [*package_ensure*] - The ensure value of the package.
8
- #
9
- # Actions:
10
- #
11
- # Requires:
12
- #
13
- # Sample Usage:
14
- #
15
- # class { 'postgresql::contrib': }
16
- #
17
- class postgresql::contrib (
18
- $package_name = $postgresql::params::contrib_package_name,
19
- $package_ensure = 'present'
20
- ) inherits postgresql::params {
21
-
22
- validate_string($package_name)
23
-
24
- package { 'postgresql-contrib':
25
- ensure => $package_ensure,
26
- name => $package_name,
27
- tag => 'postgresql',
28
- }
29
- }
@@ -1,85 +0,0 @@
1
- # puppet-postgresql
2
- # For all details and documentation:
3
- # http://github.com/inkling/puppet-postgresql
4
- #
5
- # Copyright 2012- Inkling Systems, Inc.
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
-
19
- # TODO: in order to match up more closely with the mysql module, this probably
20
- # needs to be moved over to ruby, and add support for ensurable.
21
-
22
- define postgresql::database(
23
- $dbname = $title,
24
- $owner = $postgresql::params::user,
25
- $tablespace = undef,
26
- $charset = $postgresql::params::charset,
27
- $locale = $postgresql::params::locale,
28
- $istemplate = false
29
- ) {
30
- include postgresql::params
31
-
32
- # Set the defaults for the postgresql_psql resource
33
- Postgresql_psql {
34
- psql_user => $postgresql::params::user,
35
- psql_group => $postgresql::params::group,
36
- psql_path => $postgresql::params::psql_path,
37
- }
38
-
39
- # Optionally set the locale switch. Older versions of createdb may not accept
40
- # --locale, so if the parameter is undefined its safer not to pass it.
41
- if ($postgresql::params::version != '8.1') {
42
- $locale_option = $locale ? {
43
- undef => '',
44
- default => "--locale=${locale}",
45
- }
46
- $public_revoke_privilege = 'CONNECT'
47
- } else {
48
- $locale_option = ''
49
- $public_revoke_privilege = 'ALL'
50
- }
51
-
52
- $createdb_command_tmp = "${postgresql::params::createdb_path} --owner='${owner}' --template=template0 --encoding '${charset}' ${locale_option} '${dbname}'"
53
-
54
- if($tablespace == undef) {
55
- $createdb_command = $createdb_command_tmp
56
- }
57
- else {
58
- $createdb_command = "${createdb_command_tmp} --tablespace='${tablespace}'"
59
- }
60
-
61
- postgresql_psql { "Check for existence of db '${dbname}'":
62
- command => 'SELECT 1',
63
- unless => "SELECT datname FROM pg_database WHERE datname='${dbname}'",
64
- require => Class['postgresql::server']
65
- } ~>
66
-
67
- exec { $createdb_command :
68
- refreshonly => true,
69
- user => $postgresql::params::user,
70
- logoutput => on_failure,
71
- } ~>
72
-
73
- # This will prevent users from connecting to the database unless they've been
74
- # granted privileges.
75
- postgresql_psql {"REVOKE ${public_revoke_privilege} ON DATABASE \"${dbname}\" FROM public":
76
- db => $postgresql::params::user,
77
- refreshonly => true,
78
- }
79
-
80
- Exec [ $createdb_command ] ->
81
-
82
- postgresql_psql {"UPDATE pg_database SET datistemplate = ${istemplate} WHERE datname = '${dbname}'":
83
- unless => "SELECT datname FROM pg_database WHERE datname = '${dbname}' AND datistemplate = ${istemplate}",
84
- }
85
- }
@@ -1,35 +0,0 @@
1
- # puppet-postgresql
2
- # For all details and documentation:
3
- # http://github.com/inkling/puppet-postgresql
4
- #
5
- # Copyright 2012- Inkling Systems, Inc.
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- define postgresql::database_grant(
19
- $privilege,
20
- $db,
21
- $role,
22
- $psql_db = undef,
23
- $psql_user = undef
24
- ) {
25
- include postgresql::params
26
- postgresql::grant { "database:${name}":
27
- role => $role,
28
- db => $db,
29
- privilege => $privilege,
30
- object_type => 'DATABASE',
31
- object_name => $db,
32
- psql_db => $psql_db,
33
- psql_user => $psql_user,
34
- }
35
- }