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,33 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'postgresql::server::contrib:' do
4
+ after :all do
5
+ # Cleanup after tests have ran, remove both contrib and server as contrib
6
+ # pulls in the server based packages.
7
+ pp = <<-EOS.unindent
8
+ class { 'postgresql::server':
9
+ ensure => absent,
10
+ }
11
+ class { 'postgresql::server::contrib':
12
+ package_ensure => purged,
13
+ }
14
+ EOS
15
+
16
+ puppet_apply(pp) do |r|
17
+ r.exit_code.should_not == 1
18
+ end
19
+ end
20
+
21
+ it 'test loading class with no parameters' do
22
+ pp = <<-EOS.unindent
23
+ class { 'postgresql::server': }
24
+ class { 'postgresql::server::contrib': }
25
+ EOS
26
+
27
+ puppet_apply(pp) do |r|
28
+ r.exit_code.should == 2
29
+ r.refresh
30
+ r.exit_code.should == 0
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'postgresql::lib::devel:' do
4
+ after :all do
5
+ # Cleanup after tests have ran
6
+ puppet_apply("class { 'postgresql::lib::devel': package_ensure => purged }") 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::lib::devel': }
14
+ EOS
15
+
16
+ puppet_apply(pp) do |r|
17
+ r.exit_code.should_not == 1
18
+ r.refresh
19
+ r.exit_code.should == 0
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'postgresql::lib::java:' do
4
+ after :all do
5
+ # Cleanup after tests have ran
6
+ puppet_apply("class { 'postgresql::lib::java': package_ensure => purged }") do |r|
7
+ r.exit_code.should_not == 1
8
+ end
9
+ end
10
+
11
+ it 'test loading class with no parameters' do
12
+ pending('libpostgresql-java-jdbc not available natively for Ubuntu 10.04 and Debian 6',
13
+ :if => (node.facts['osfamily'] == 'Debian' and ['6', '10'].include?(node.facts['lsbmajdistrelease'])))
14
+
15
+ pp = <<-EOS.unindent
16
+ class { 'postgresql::lib::java': }
17
+ EOS
18
+
19
+ puppet_apply(pp) do |r|
20
+ r.exit_code.should_not == 1
21
+ r.refresh
22
+ r.exit_code.should == 0
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'postgresql::lib::python:' do
4
+ after :all do
5
+ # Cleanup after tests have ran
6
+ puppet_apply("class { 'postgresql::lib::python': package_ensure => purged }") do |r|
7
+ r.exit_code.should_not == 1
8
+ end
9
+ end
10
+
11
+ it 'test loading class with no parameters' do
12
+ pending('psycopg2 not available natively for centos 5', :if => (node.facts['osfamily'] == 'RedHat' and node.facts['lsbmajdistrelease'] == '5'))
13
+
14
+ pp = <<-EOS.unindent
15
+ class { 'postgresql::lib::python': }
16
+ EOS
17
+
18
+ puppet_apply(pp) do |r|
19
+ r.exit_code.should_not == 1
20
+ r.refresh
21
+ r.exit_code.should == 0
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'postgresql_psql:' 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 run some SQL when the unless query returns no rows' do
12
+ pp = <<-EOS.unindent
13
+ class { 'postgresql::server': }
14
+
15
+ postgresql_psql { 'foobar':
16
+ db => 'postgres',
17
+ psql_user => 'postgres',
18
+ command => 'select 1',
19
+ unless => 'select 1 where 1=2',
20
+ require => Class['postgresql::server'],
21
+ }
22
+ EOS
23
+
24
+ puppet_apply(pp) do |r|
25
+ r.exit_code.should_not == 1
26
+ r.refresh
27
+ r.exit_code.should == 2
28
+ end
29
+ end
30
+
31
+ it 'should not run SQL when the unless query returns rows' do
32
+ pp = <<-EOS.unindent
33
+ class { 'postgresql::server': }
34
+
35
+ postgresql_psql { 'foobar':
36
+ db => 'postgres',
37
+ psql_user => 'postgres',
38
+ command => 'select * from pg_database limit 1',
39
+ unless => 'select 1 where 1=1',
40
+ require => Class['postgresql::server'],
41
+ }
42
+ EOS
43
+
44
+ puppet_apply(pp) do |r|
45
+ r.exit_code.should_not == 1
46
+ r.refresh
47
+ r.exit_code.should == 0
48
+ end
49
+ end
50
+
51
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'postgresql::server::config_entry:' 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 change setting and reflect it in show all' do
12
+ pp = <<-EOS.unindent
13
+ class { 'postgresql::server': }
14
+
15
+ postgresql::server::config_entry { 'check_function_bodies':
16
+ value => 'off',
17
+ }
18
+ EOS
19
+
20
+ puppet_apply(pp) do |r|
21
+ r.exit_code.should_not == 1
22
+ r.refresh
23
+ r.exit_code.should == 0
24
+ end
25
+
26
+ psql('--command="show all" postgres') do |r|
27
+ r.stdout.should =~ /check_function_bodies.+off/
28
+ r.stderr.should be_empty
29
+ r.exit_code.should == 0
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,54 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'postgresql::server::database_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 create objects in a database' do
12
+ begin
13
+ pp = <<-EOS.unindent
14
+ $db = 'postgres'
15
+ $user = 'psql_grant_tester'
16
+ $password = 'psql_grant_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
+ postgresql::server::database_grant { 'grant create test':
32
+ privilege => 'CREATE',
33
+ db => $db,
34
+ role => $user,
35
+ }
36
+ EOS
37
+
38
+ puppet_apply(pp) do |r|
39
+ r.exit_code.should_not == 1
40
+ r.refresh
41
+ r.exit_code.should == 0
42
+ end
43
+
44
+ # Check that the user can create a table in the database
45
+ psql('--command="create table foo (foo int)" postgres', 'psql_grant_tester') do |r|
46
+ r.stdout.should =~ /CREATE TABLE/
47
+ r.stderr.should == ''
48
+ r.exit_code.should == 0
49
+ end
50
+ ensure
51
+ psql('--command="drop table foo" postgres', 'psql_grant_tester')
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'postgresql::server::database:' 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 db that we can connect to' do
12
+ begin
13
+ pp = <<-EOS.unindent
14
+ $db = 'postgresql_test_db'
15
+ class { 'postgresql::server': }
16
+
17
+ postgresql::server::database { $db: }
18
+ EOS
19
+
20
+ puppet_apply(pp) do |r|
21
+ r.exit_code.should_not == 1
22
+ r.refresh
23
+ r.exit_code.should == 0
24
+ end
25
+
26
+ psql('--command="select datname from pg_database" postgresql_test_db') do |r|
27
+ r.stdout.should =~ /postgresql_test_db/
28
+ r.stderr.should be_empty
29
+ r.exit_code.should == 0
30
+ end
31
+ ensure
32
+ psql('--command="drop database postgresql_test_db" postgres')
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,143 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'postgresql::server::db' 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 db that we can connect to' do
12
+ begin
13
+ pp = <<-EOS.unindent
14
+ $db = 'postgresql_test_db'
15
+ class { 'postgresql::server': }
16
+
17
+ postgresql::server::db { $db:
18
+ user => $db,
19
+ password => postgresql_password($db, $db),
20
+ }
21
+ EOS
22
+
23
+ puppet_apply(pp) do |r|
24
+ r.exit_code.should_not == 1
25
+ r.refresh
26
+ r.exit_code.should == 0
27
+ end
28
+
29
+ psql('--command="select datname from pg_database" postgresql_test_db') do |r|
30
+ r.stdout.should =~ /postgresql_test_db/
31
+ r.stderr.should be_empty
32
+ r.exit_code.should == 0
33
+ end
34
+ ensure
35
+ psql('--command="drop database postgresql_test_db" postgres')
36
+ end
37
+ end
38
+
39
+ it 'should take a locale parameter' do
40
+ pending('no support for locale parameter with centos 5', :if => (node.facts['osfamily'] == 'RedHat' and node.facts['lsbmajdistrelease'] == '5'))
41
+ begin
42
+ pp = <<-EOS.unindent
43
+ class { 'postgresql::server': }
44
+ if($::operatingsystem == 'Debian') {
45
+ # Need to make sure the correct locale is installed first
46
+ file { '/etc/locale.gen':
47
+ content => "en_US ISO-8859-1\nen_NG UTF-8\n",
48
+ }~>
49
+ exec { '/usr/sbin/locale-gen':
50
+ logoutput => true,
51
+ refreshonly => true,
52
+ }
53
+ }
54
+ postgresql::server::db { 'test1':
55
+ user => 'test1',
56
+ password => postgresql_password('test1', 'test1'),
57
+ encoding => 'UTF8',
58
+ locale => 'en_NG',
59
+ }
60
+ EOS
61
+
62
+ puppet_apply(pp) do |r|
63
+ r.exit_code.should_not == 1
64
+ r.refresh
65
+ r.exit_code.should == 0
66
+ end
67
+
68
+ psql('-c "show lc_ctype" test1') do |r|
69
+ r.stdout.should =~ /en_NG/
70
+ end
71
+
72
+ psql('-c "show lc_collate" test1') do |r|
73
+ r.stdout.should =~ /en_NG/
74
+ end
75
+ ensure
76
+ psql('--command="drop database test1" postgres')
77
+ end
78
+ end
79
+
80
+ it 'should take an istemplate parameter' do
81
+ begin
82
+ pp = <<-EOS.unindent
83
+ $db = 'template2'
84
+ class { 'postgresql::server': }
85
+
86
+ postgresql::server::db { $db:
87
+ user => $db,
88
+ password => postgresql_password($db, $db),
89
+ istemplate => true,
90
+ }
91
+ EOS
92
+
93
+ puppet_apply(pp) do |r|
94
+ r.exit_code.should_not == 1
95
+ r.refresh
96
+ r.exit_code.should == 0
97
+ end
98
+
99
+ psql('--command="select datname from pg_database" template2') do |r|
100
+ r.stdout.should =~ /template2/
101
+ r.stderr.should be_empty
102
+ r.exit_code.should == 0
103
+ end
104
+ ensure
105
+ psql('--command="drop database template2" postgres') do |r|
106
+ r.stdout.should be_empty
107
+ r.stderr.should =~ /cannot drop a template database/
108
+ r.exit_code.should_not == 0
109
+ end
110
+ end
111
+ end
112
+
113
+ it 'should update istemplate parameter' do
114
+ begin
115
+ pp = <<-EOS.unindent
116
+ $db = 'template2'
117
+ class { 'postgresql::server': }
118
+
119
+ postgresql::server::db { $db:
120
+ user => $db,
121
+ password => postgresql_password($db, $db),
122
+ istemplate => false,
123
+ }
124
+ EOS
125
+
126
+ puppet_apply(pp) do |r|
127
+ r.exit_code.should_not == 1
128
+ r.refresh
129
+ r.exit_code.should == 0
130
+ end
131
+
132
+ psql('--command="select datname from pg_database" template2') do |r|
133
+ r.stdout.should =~ /template2/
134
+ r.stderr.should be_empty
135
+ r.exit_code.should == 0
136
+ end
137
+ ensure
138
+ psql('--command="drop database template2" postgres') do |r|
139
+ r.exit_code.should == 0
140
+ end
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'postgresql::server::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 create in a database' do
12
+ begin
13
+ pp = <<-EOS.unindent
14
+ $db = 'postgres'
15
+ $user = 'psql_grant_tester'
16
+ $password = 'psql_grant_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
+ postgresql::server::grant { 'grant create test':
32
+ object_type => 'database',
33
+ privilege => 'CREATE',
34
+ db => $db,
35
+ role => $user,
36
+ }
37
+ EOS
38
+
39
+ puppet_apply(pp) do |r|
40
+ r.exit_code.should_not == 1
41
+ r.refresh
42
+ r.exit_code.should == 0
43
+ end
44
+
45
+ # Check that the user can create a table in the database
46
+ psql('--command="create table foo (foo int)" postgres', 'psql_grant_tester') do |r|
47
+ r.stdout.should =~ /CREATE TABLE/
48
+ r.stderr.should == ''
49
+ r.exit_code.should == 0
50
+ end
51
+ ensure
52
+ psql('--command="drop table foo" postgres', 'psql_grant_tester')
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,85 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'postgresql::server::pg_hba_rule:' 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 create a ruleset in pg_hba.conf' do
12
+ pp = <<-EOS.unindent
13
+ class { 'postgresql::server': }
14
+ postgresql::server::pg_hba_rule { "allow application network to access app database":
15
+ type => "host",
16
+ database => "app",
17
+ user => "app",
18
+ address => "200.1.2.0/24",
19
+ auth_method => md5,
20
+ }
21
+ EOS
22
+
23
+ puppet_apply(pp) do |r|
24
+ r.exit_code.should_not == 1
25
+ end
26
+
27
+ puppet_apply(pp) do |r|
28
+ r.exit_code.should be_zero
29
+ end
30
+
31
+ shell("grep '200.1.2.0/24' /etc/postgresql/*/*/pg_hba.conf || grep '200.1.2.0/24' /var/lib/pgsql/data/pg_hba.conf") do |r|
32
+ r.exit_code.should be_zero
33
+ end
34
+ end
35
+
36
+ it 'should create a ruleset in pg_hba.conf that denies db access to db test1' do
37
+ pp = <<-EOS.unindent
38
+ class { 'postgresql::server': }
39
+
40
+ postgresql::server::db { "test1":
41
+ user => "test1",
42
+ password => postgresql_password('test1', 'test1'),
43
+ grant => "all",
44
+ }
45
+
46
+ postgresql::server::pg_hba_rule { "allow anyone to have access to db test1":
47
+ type => "local",
48
+ database => "test1",
49
+ user => "test1",
50
+ auth_method => reject,
51
+ order => '001',
52
+ }
53
+
54
+ user { "test1":
55
+ shell => "/bin/bash",
56
+ managehome => true,
57
+ }
58
+ EOS
59
+ puppet_apply(pp) do |r|
60
+ r.exit_code.should_not == 1
61
+ end
62
+
63
+ shell('su - test1 -c \'psql -U test1 -c "\q" test1\'') do |r|
64
+ r.exit_code.should == 2
65
+ end
66
+ end
67
+
68
+ it 'should fail catalogue if postgresql::server::manage_pga_conf is disabled' do
69
+ pp = <<-EOS.unindent
70
+ class { 'postgresql::server':
71
+ manage_pg_hba_conf => false,
72
+ }
73
+ postgresql::server::pg_hba_rule { 'foo':
74
+ type => "local",
75
+ database => "test1",
76
+ user => "test1",
77
+ auth_method => reject,
78
+ order => '001',
79
+ }
80
+ EOS
81
+ puppet_apply(pp) do |r|
82
+ r.exit_code.should == 1
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper_system'
2
+
3
+ describe 'server plperl:' do
4
+ after :all do
5
+ # Cleanup after tests have ran
6
+ pp = <<-EOS.unindent
7
+ class { 'postgresql::server': ensure => absent }
8
+ class { 'postgresql::server::plperl': package_ensure => purged }
9
+ EOS
10
+ puppet_apply(pp) do |r|
11
+ r.exit_code.should_not == 1
12
+ end
13
+ end
14
+
15
+ it 'test loading class with no parameters' do
16
+ pending('no support for plperl with default version on centos 5',
17
+ :if => (node.facts['osfamily'] == 'RedHat' and node.facts['lsbmajdistrelease'] == '5'))
18
+ pp = <<-EOS.unindent
19
+ class { 'postgresql::server': }
20
+ class { 'postgresql::server::plperl': }
21
+ EOS
22
+
23
+ puppet_apply(pp) do |r|
24
+ r.exit_code.should_not == 1
25
+ r.refresh
26
+ r.exit_code.should == 0
27
+ end
28
+ end
29
+ end