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
@@ -0,0 +1,103 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'postgresql::server::role:' do
4
+ after :all do
5
+ # Cleanup after tests have ran
6
+ puppet_apply("class { 'postgresql::server': ensure => absent }") do |r|
7
+ r.exit_code.should_not == 1
8
+ end
9
+ end
10
+
11
+ it 'should idempotently create a user who can log in' do
12
+ pp = <<-EOS.unindent
13
+ $user = "postgresql_test_user"
14
+ $password = "postgresql_test_password"
15
+
16
+ class { 'postgresql::server': }
17
+
18
+ # Since we are not testing pg_hba or any of that, make a local user for ident auth
19
+ user { $user:
20
+ ensure => present,
21
+ }
22
+
23
+ postgresql::server::role { $user:
24
+ password_hash => postgresql_password($user, $password),
25
+ }
26
+ EOS
27
+
28
+ puppet_apply(pp) do |r|
29
+ r.exit_code.should_not == 1
30
+ r.refresh
31
+ r.exit_code.should == 0
32
+ end
33
+
34
+ # Check that the user can log in
35
+ psql('--command="select datname from pg_database" postgres', 'postgresql_test_user') do |r|
36
+ r.stdout.should =~ /template1/
37
+ r.stderr.should == ''
38
+ r.exit_code.should == 0
39
+ end
40
+ end
41
+
42
+ it 'should idempotently alter a user who can log in' do
43
+ pp = <<-EOS.unindent
44
+ $user = "postgresql_test_user"
45
+ $password = "postgresql_test_password2"
46
+
47
+ class { 'postgresql::server': }
48
+
49
+ # Since we are not testing pg_hba or any of that, make a local user for ident auth
50
+ user { $user:
51
+ ensure => present,
52
+ }
53
+
54
+ postgresql::server::role { $user:
55
+ password_hash => postgresql_password($user, $password),
56
+ }
57
+ EOS
58
+
59
+ puppet_apply(pp) do |r|
60
+ r.exit_code.should_not == 1
61
+ r.refresh
62
+ r.exit_code.should == 0
63
+ end
64
+
65
+ # Check that the user can log in
66
+ psql('--command="select datname from pg_database" postgres', 'postgresql_test_user') do |r|
67
+ r.stdout.should =~ /template1/
68
+ r.stderr.should == ''
69
+ r.exit_code.should == 0
70
+ end
71
+ end
72
+
73
+ it 'should idempotently create a user with a cleartext password' do
74
+ pp = <<-EOS.unindent
75
+ $user = "postgresql_test_user2"
76
+ $password = "postgresql_test_password2"
77
+
78
+ class { 'postgresql::server': }
79
+
80
+ # Since we are not testing pg_hba or any of that, make a local user for ident auth
81
+ user { $user:
82
+ ensure => present,
83
+ }
84
+
85
+ postgresql::server::role { $user:
86
+ password_hash => $password,
87
+ }
88
+ EOS
89
+
90
+ puppet_apply(pp) do |r|
91
+ r.exit_code.should_not == 1
92
+ r.refresh
93
+ r.exit_code.should == 0
94
+ end
95
+
96
+ # Check that the user can log in
97
+ psql('--command="select datname from pg_database" postgres', 'postgresql_test_user2') do |r|
98
+ r.stdout.should =~ /template1/
99
+ r.stderr.should == ''
100
+ r.exit_code.should == 0
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'postgresql::server::table_grant:' do
4
+ after :all do
5
+ # Cleanup after tests have ran
6
+ puppet_apply("class { 'postgresql::server': ensure => absent }") do |r|
7
+ r.exit_code.should_not == 1
8
+ end
9
+ end
10
+
11
+ it 'should grant access so a user can insert in a table' do
12
+ begin
13
+ pp = <<-EOS.unindent
14
+ $db = 'table_grant'
15
+ $user = 'psql_grant_tester'
16
+ $password = 'psql_table_pw'
17
+
18
+ class { 'postgresql::server': }
19
+
20
+ # Since we are not testing pg_hba or any of that, make a local user for ident auth
21
+ user { $user:
22
+ ensure => present,
23
+ }
24
+
25
+ postgresql::server::role { $user:
26
+ password_hash => postgresql_password($user, $password),
27
+ }
28
+
29
+ postgresql::server::database { $db: }
30
+
31
+ # Create a rule for the user
32
+ postgresql::server::pg_hba_rule { "allow ${user}":
33
+ type => 'local',
34
+ database => $db,
35
+ user => $user,
36
+ auth_method => 'ident',
37
+ order => 1,
38
+ }
39
+
40
+ postgresql_psql { 'Create testing table':
41
+ command => 'CREATE TABLE "test_table" (field integer NOT NULL)',
42
+ db => $db,
43
+ unless => "SELECT * FROM pg_tables WHERE tablename = 'test_table'",
44
+ require => Postgresql::Server::Database[$db],
45
+ }
46
+
47
+ postgresql::server::table_grant { 'grant insert test':
48
+ privilege => 'INSERT',
49
+ table => 'test_table',
50
+ db => $db,
51
+ role => $user,
52
+ require => Postgresql_psql['Create testing table'],
53
+ }
54
+ EOS
55
+
56
+ puppet_apply(pp) do |r|
57
+ r.exit_code.should_not == 1
58
+ r.refresh
59
+ r.exit_code.should == 0
60
+ end
61
+
62
+ ## Check that the user can create a table in the database
63
+ psql('--command="create table foo (foo int)" postgres', 'psql_grant_tester') do |r|
64
+ r.stdout.should =~ /CREATE TABLE/
65
+ r.stderr.should be_empty
66
+ r.exit_code.should == 0
67
+ end
68
+ ensure
69
+ psql('--command="drop table foo" postgres', 'psql_grant_tester')
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,74 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'postgresql::server::tablespace:' do
4
+ after :all do
5
+ # Cleanup after tests have ran
6
+ puppet_apply("class { 'postgresql::server': ensure => absent }") do |r|
7
+ r.exit_code.should_not == 1
8
+ end
9
+ end
10
+
11
+ it 'should idempotently create tablespaces and databases that are using them' do
12
+ pp = <<-EOS.unindent
13
+ class { 'postgresql::server': }
14
+
15
+ file { '/tmp/pg_tablespaces':
16
+ ensure => 'directory',
17
+ owner => 'postgres',
18
+ group => 'postgres',
19
+ mode => '0700',
20
+ }~>
21
+ # This works around rubies that lack Selinux support, I'm looking at you RHEL5
22
+ exec { "chcon -u system_u -r object_r -t postgresql_db_t /tmp/pg_tablespaces":
23
+ refreshonly => true,
24
+ path => "/bin:/usr/bin",
25
+ onlyif => "which chcon",
26
+ before => File["/tmp/pg_tablespaces/space1", "/tmp/pg_tablespaces/space2"]
27
+ }
28
+
29
+ postgresql::server::tablespace { 'tablespace1':
30
+ location => '/tmp/pg_tablespaces/space1',
31
+ }
32
+ postgresql::server::database { 'tablespacedb1':
33
+ encoding => 'utf8',
34
+ tablespace => 'tablespace1',
35
+ }
36
+ postgresql::server::db { 'tablespacedb2':
37
+ user => 'dbuser2',
38
+ password => postgresql_password('dbuser2', 'dbuser2'),
39
+ tablespace => 'tablespace1',
40
+ }
41
+
42
+ postgresql::server::role { 'spcuser':
43
+ password_hash => postgresql_password('spcuser', 'spcuser'),
44
+ }
45
+ postgresql::server::tablespace { 'tablespace2':
46
+ location => '/tmp/pg_tablespaces/space2',
47
+ owner => 'spcuser',
48
+ }
49
+ postgresql::server::database { 'tablespacedb3':
50
+ encoding => 'utf8',
51
+ tablespace => 'tablespace2',
52
+ }
53
+ EOS
54
+
55
+ puppet_apply(pp) do |r|
56
+ r.exit_code.should_not == 1
57
+ r.refresh
58
+ r.exit_code.should == 0
59
+ end
60
+
61
+ # Check that databases use correct tablespaces
62
+ psql('--command="select ts.spcname from pg_database db, pg_tablespace ts where db.dattablespace = ts.oid and db.datname = \'"\'tablespacedb1\'"\'"') do |r|
63
+ r.stdout.should =~ /tablespace1/
64
+ r.stderr.should == ''
65
+ r.exit_code.should == 0
66
+ end
67
+
68
+ psql('--command="select ts.spcname from pg_database db, pg_tablespace ts where db.dattablespace = ts.oid and db.datname = \'"\'tablespacedb3\'"\'"') do |r|
69
+ r.stdout.should =~ /tablespace2/
70
+ r.stderr.should == ''
71
+ r.exit_code.should == 0
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,217 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'server:' do
4
+ after :all do
5
+ # Cleanup after tests have ran
6
+ puppet_apply("class { 'postgresql::server': ensure => absent }") do |r|
7
+ r.exit_code.should_not == 1
8
+ end
9
+ end
10
+
11
+ it 'test loading class with no parameters' do
12
+ pp = <<-EOS.unindent
13
+ class { 'postgresql::server': }
14
+ EOS
15
+
16
+ puppet_apply(pp) do |r|
17
+ r.exit_code.should == 2
18
+ r.refresh
19
+ r.exit_code.should == 0
20
+ end
21
+ end
22
+
23
+ describe port(5432) do
24
+ it { should be_listening }
25
+ end
26
+
27
+ describe 'setting postgres password' do
28
+ it 'should install and successfully adjust the password' do
29
+ pp = <<-EOS.unindent
30
+ class { 'postgresql::server':
31
+ postgres_password => 'foobarbaz',
32
+ ip_mask_deny_postgres_user => '0.0.0.0/32',
33
+ }
34
+ EOS
35
+
36
+ puppet_apply(pp) do |r|
37
+ [0,2].should include(r.exit_code)
38
+ r.stdout.should =~ /\[set_postgres_postgrespw\]\/returns: executed successfully/
39
+ r.refresh
40
+ r.exit_code.should == 0
41
+ end
42
+
43
+ pp = <<-EOS.unindent
44
+ class { 'postgresql::server':
45
+ postgres_password => 'TPSR$$eports!',
46
+ ip_mask_deny_postgres_user => '0.0.0.0/32',
47
+ }
48
+ EOS
49
+
50
+ puppet_apply(pp) do |r|
51
+ [0,2].should include(r.exit_code)
52
+ r.stdout.should =~ /\[set_postgres_postgrespw\]\/returns: executed successfully/
53
+ r.refresh
54
+ r.exit_code.should == 0
55
+ end
56
+
57
+ end
58
+ end
59
+ end
60
+
61
+ describe 'server without defaults:' do
62
+ before :all do
63
+ puppet_apply(<<-EOS.unindent)
64
+ if($::operatingsystem =~ /Debian|Ubuntu/) {
65
+ # Need to make sure the correct utf8 locale is ready for our
66
+ # non-standard tests
67
+ file { '/etc/locale.gen':
68
+ content => "en_US ISO-8859-1\nen_NG UTF-8\nen_US UTF-8\n",
69
+ }~>
70
+ exec { '/usr/sbin/locale-gen':
71
+ logoutput => true,
72
+ refreshonly => true,
73
+ }
74
+ }
75
+ EOS
76
+ end
77
+
78
+ context 'test installing non-default version of postgresql' do
79
+ after :all do
80
+ psql('--command="drop database postgresql_test_db" postgres')
81
+ pp = <<-EOS.unindent
82
+ class { 'postgresql::globals':
83
+ ensure => absent,
84
+ manage_package_repo => true,
85
+ version => '9.3',
86
+ }
87
+ class { 'postgresql::server':
88
+ ensure => absent,
89
+ }
90
+ EOS
91
+ puppet_apply(pp) do |r|
92
+ r.exit_code.should_not == 1
93
+ end
94
+ end
95
+
96
+ it 'perform installation and create a db' do
97
+ pp = <<-EOS.unindent
98
+ class { "postgresql::globals":
99
+ version => "9.3",
100
+ manage_package_repo => true,
101
+ encoding => 'UTF8',
102
+ locale => 'en_US.UTF-8',
103
+ }
104
+ class { "postgresql::server": }
105
+ postgresql::server::db { "postgresql_test_db":
106
+ user => "foo1",
107
+ password => postgresql_password('foo1', 'foo1'),
108
+ }
109
+ postgresql::server::config_entry { 'port':
110
+ value => '5432',
111
+ }
112
+ EOS
113
+
114
+ puppet_apply(pp) do |r|
115
+ r.exit_code.should == 2
116
+ r.refresh
117
+ r.exit_code.should == 0
118
+ end
119
+
120
+ psql('postgresql_test_db --command="select datname from pg_database limit 1"') do |r|
121
+ r.exit_code.should == 0
122
+ end
123
+ end
124
+
125
+ describe port(5432) do
126
+ it { should be_listening }
127
+ end
128
+ end
129
+
130
+ unless ((node.facts['osfamily'] == 'RedHat' and node.facts['lsbmajdistrelease'] == '5') ||
131
+ node.facts['osfamily'] == 'Debian')
132
+
133
+ context 'override locale and encoding' do
134
+ after :each do
135
+ puppet_apply "class { 'postgresql::server': ensure => absent }" do |r|
136
+ r.exit_code.should_not == 1
137
+ end
138
+ end
139
+
140
+ it 'perform installation with different locale and encoding' do
141
+ pp = <<-EOS.unindent
142
+ class { 'postgresql::server':
143
+ locale => 'en_NG',
144
+ encoding => 'UTF8',
145
+ }
146
+ EOS
147
+
148
+ puppet_apply(pp) do |r|
149
+ r.exit_code.should == 2
150
+ r.refresh
151
+ r.exit_code.should == 0
152
+ end
153
+
154
+ # Remove db first, if it exists for some reason
155
+ shell('su postgres -c "dropdb test1"')
156
+ shell('su postgres -c "createdb test1"')
157
+ shell('su postgres -c \'psql -c "show lc_ctype" test1\'') do |r|
158
+ r.stdout.should =~ /en_NG/
159
+ end
160
+
161
+ shell('su postgres -c \'psql -c "show lc_collate" test1\'') do |r|
162
+ r.stdout.should =~ /en_NG/
163
+ end
164
+ end
165
+ end
166
+ end
167
+ end
168
+
169
+ describe 'server with firewall:' do
170
+ after :all do
171
+ puppet_apply("class { 'postgresql::server': ensure => absent }") do |r|
172
+ r.exit_code.should_not == 1
173
+ end
174
+ end
175
+
176
+ context 'test installing postgresql with firewall management on' do
177
+ it 'perform installation and make sure it is idempotent' do
178
+ pending('no support for firewall with fedora', :if => (node.facts['operatingsystem'] == 'Fedora'))
179
+ pp = <<-EOS.unindent
180
+ class { 'firewall': }
181
+ class { "postgresql::server":
182
+ manage_firewall => true,
183
+ }
184
+ EOS
185
+
186
+ puppet_apply(pp) do |r|
187
+ r.exit_code.should == 2
188
+ r.refresh
189
+ r.exit_code.should == 0
190
+ end
191
+ end
192
+ end
193
+ end
194
+
195
+ describe 'server without pg_hba.conf:' do
196
+ after :all do
197
+ puppet_apply("class { 'postgresql::server': ensure => absent }") do |r|
198
+ r.exit_code.should_not == 1
199
+ end
200
+ end
201
+
202
+ context 'test installing postgresql without pg_hba.conf management on' do
203
+ it 'perform installation and make sure it is idempotent' do
204
+ pp = <<-EOS.unindent
205
+ class { "postgresql::server":
206
+ manage_pg_hba_conf => false,
207
+ }
208
+ EOS
209
+
210
+ puppet_apply(pp) do |r|
211
+ r.exit_code.should == 2
212
+ r.refresh
213
+ r.exit_code.should == 0
214
+ end
215
+ end
216
+ end
217
+ end
@@ -0,0 +1,91 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'postgresql::validate_db_connection:' do
4
+ before :all do
5
+ # Setup postgresql server and a sample database for tests to use.
6
+ pp = <<-EOS.unindent
7
+ $db = 'foo'
8
+ class { 'postgresql::server': }
9
+
10
+ postgresql::server::db { $db:
11
+ user => $db,
12
+ password => postgresql_password($db, $db),
13
+ }
14
+ EOS
15
+
16
+ puppet_apply(pp) do |r|
17
+ r.exit_code.should_not == 1
18
+ end
19
+ end
20
+
21
+ after :all do
22
+ # Remove postgresql server after all tests have ran.
23
+ puppet_apply("class { 'postgresql::server': ensure => absent }") do |r|
24
+ r.exit_code.should_not == 1
25
+ end
26
+ end
27
+
28
+ it 'should run puppet with no changes declared if socket connectivity works' do
29
+ pp = <<-EOS.unindent
30
+ postgresql::validate_db_connection { 'foo':
31
+ database_name => 'foo',
32
+ run_as => 'postgres',
33
+ }
34
+ EOS
35
+
36
+ puppet_apply(pp) do |r|
37
+ r.exit_code.should == 0
38
+ end
39
+ end
40
+
41
+ it 'should keep retrying if database is down' do
42
+ # So first we shut the db down, then background a startup routine with a
43
+ # sleep 10 in front of it. That way rspec-system should continue while
44
+ # the pause and db startup happens in the background.
45
+ shell("/etc/init.d/postgresql* stop")
46
+ shell('nohup bash -c "sleep 10; /etc/init.d/postgresql* start" > /dev/null 2>&1 &')
47
+
48
+ pp = <<-EOS.unindent
49
+ postgresql::validate_db_connection { 'foo':
50
+ database_name => 'foo',
51
+ tries => 30,
52
+ sleep => 1,
53
+ run_as => 'postgres',
54
+ }
55
+ EOS
56
+
57
+ puppet_apply(pp) do |r|
58
+ r.exit_code.should == 0
59
+ end
60
+ end
61
+
62
+ it 'should run puppet with no changes declared if db ip connectivity works' do
63
+ pp = <<-EOS.unindent
64
+ postgresql::validate_db_connection { 'foo':
65
+ database_host => 'localhost',
66
+ database_name => 'foo',
67
+ database_username => 'foo',
68
+ database_password => 'foo',
69
+ }
70
+ EOS
71
+
72
+ puppet_apply(pp) do |r|
73
+ r.exit_code.should == 0
74
+ end
75
+ end
76
+
77
+ it 'should fail catalogue if database connectivity fails' do
78
+ pp = <<-EOS.unindent
79
+ postgresql::validate_db_connection { 'foobarbaz':
80
+ database_host => 'localhost',
81
+ database_name => 'foobarbaz',
82
+ database_username => 'foobarbaz',
83
+ database_password => 'foobarbaz',
84
+ }
85
+ EOS
86
+
87
+ puppet_apply(pp) do |r|
88
+ r.exit_code.should == 4
89
+ end
90
+ end
91
+ end
@@ -3,9 +3,34 @@ require 'spec_helper'
3
3
  describe 'postgresql::client', :type => :class do
4
4
  let :facts do
5
5
  {
6
- :postgres_default_version => '8.4',
7
6
  :osfamily => 'Debian',
7
+ :operatingsystem => 'Debian',
8
+ :operatingsystemrelease => '6.0',
8
9
  }
9
10
  end
10
- it { should include_class("postgresql::client") }
11
+
12
+ describe 'with parameters' do
13
+ let :params do
14
+ {
15
+ :package_ensure => 'absent',
16
+ :package_name => 'mypackage',
17
+ }
18
+ end
19
+
20
+ it 'should modify package' do
21
+ should contain_package("postgresql-client").with({
22
+ :ensure => 'absent',
23
+ :name => 'mypackage',
24
+ :tag => 'postgresql',
25
+ })
26
+ end
27
+ end
28
+
29
+ describe 'with no parameters' do
30
+ it 'should create package with postgresql tag' do
31
+ should contain_package('postgresql-client').with({
32
+ :tag => 'postgresql',
33
+ })
34
+ end
35
+ end
11
36
  end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'postgresql::globals', :type => :class do
4
+ let :facts do
5
+ {
6
+ :osfamily => 'Debian',
7
+ :operatingsystem => 'Debian',
8
+ :operatingsystemrelease => '6.0',
9
+ }
10
+ end
11
+
12
+ describe 'with no parameters' do
13
+ it 'should work' do
14
+ should include_class("postgresql::globals")
15
+ end
16
+ end
17
+
18
+ describe 'manage_package_repo => true' do
19
+ let(:params) do
20
+ {
21
+ :manage_package_repo => true,
22
+ }
23
+ end
24
+ it 'should pull in class postgresql::repo' do
25
+ should include_class("postgresql::repo")
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'postgresql::lib::devel', :type => :class do
4
+ let :facts do
5
+ {
6
+ :osfamily => 'Debian',
7
+ :operatingsystem => 'Debian',
8
+ :operatingsystemrelease => '6.0',
9
+ }
10
+ end
11
+ it { should include_class("postgresql::lib::devel") }
12
+ end
@@ -1,11 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'postgresql::java', :type => :class do
3
+ describe 'postgresql::lib::java', :type => :class do
4
4
 
5
5
  describe 'on a debian based os' do
6
6
  let :facts do {
7
- :osfamily => 'Debian',
8
- :postgres_default_version => 'foo',
7
+ :osfamily => 'Debian',
8
+ :operatingsystem => 'Debian',
9
+ :operatingsystemrelease => '6.0',
9
10
  }
10
11
  end
11
12
  it { should contain_package('postgresql-jdbc').with(
@@ -16,12 +17,13 @@ describe 'postgresql::java', :type => :class do
16
17
 
17
18
  describe 'on a redhat based os' do
18
19
  let :facts do {
19
- :osfamily => 'RedHat',
20
- :postgres_default_version => 'foo',
20
+ :osfamily => 'RedHat',
21
+ :operatingsystem => 'RedHat',
22
+ :operatingsystemrelease => '6.4',
21
23
  }
22
24
  end
23
25
  it { should contain_package('postgresql-jdbc').with(
24
- :name => 'postgresql-jdbc',
26
+ :name => 'postgresql-jdbc',
25
27
  :ensure => 'present'
26
28
  )}
27
29
  describe 'when parameters are supplied' do
@@ -29,22 +31,10 @@ describe 'postgresql::java', :type => :class do
29
31
  {:package_ensure => 'latest', :package_name => 'somepackage'}
30
32
  end
31
33
  it { should contain_package('postgresql-jdbc').with(
32
- :name => 'somepackage',
34
+ :name => 'somepackage',
33
35
  :ensure => 'latest'
34
36
  )}
35
37
  end
36
38
  end
37
39
 
38
- describe 'on any other os' do
39
- let :facts do {
40
- :osfamily => 'foo',
41
- :postgres_default_version => 'foo',
42
- }
43
- end
44
-
45
- it 'should fail without all the necessary parameters' do
46
- expect { subject }.to raise_error(/Module postgresql does not provide defaults for osfamily: foo/)
47
- end
48
- end
49
-
50
40
  end