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,707 +0,0 @@
1
- require 'spec_helper_system'
2
-
3
- describe 'install:' 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 postgresql::server' do
12
- pp = <<-EOS
13
- class { 'postgresql::server': }
14
- EOS
15
-
16
- puppet_apply(pp) do |r|
17
- r.exit_code.should_not == 1
18
- end
19
-
20
- puppet_apply(pp) do |r|
21
- r.exit_code.should be_zero
22
- end
23
- end
24
-
25
- describe 'postgresql::db' do
26
- it 'should idempotently create a db that we can connect to' do
27
- begin
28
- pp = <<-EOS
29
- $db = 'postgresql_test_db'
30
- include postgresql::server
31
-
32
- postgresql::db { $db:
33
- user => $db,
34
- password => postgresql_password($db, $db),
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
- psql('--command="select datname from pg_database" postgresql_test_db') do |r|
45
- r.stdout.should =~ /postgresql_test_db/
46
- r.stderr.should be_empty
47
- r.exit_code.should == 0
48
- end
49
- ensure
50
- psql('--command="drop database postgresql_test_db" postgres')
51
- end
52
- end
53
-
54
- it 'should take a locale parameter' do
55
- pending('no support for locale parameter with centos 5', :if => (node.facts['osfamily'] == 'RedHat' and node.facts['lsbmajdistrelease'] == '5'))
56
- begin
57
- pp = <<-EOS
58
- class { 'postgresql::server': }
59
- if($::operatingsystem == 'Debian') {
60
- # Need to make sure the correct locale is installed first
61
- file { '/etc/locale.gen':
62
- content => "en_US ISO-8859-1\nen_NG UTF-8\n",
63
- }~>
64
- exec { '/usr/sbin/locale-gen':
65
- logoutput => true,
66
- refreshonly => true,
67
- }
68
- }
69
- postgresql::db { 'test1':
70
- user => 'test1',
71
- password => postgresql_password('test1', 'test1'),
72
- charset => 'UTF8',
73
- locale => 'en_NG',
74
- }
75
- EOS
76
-
77
- puppet_apply(pp) do |r|
78
- r.exit_code.should_not == 1
79
- r.refresh
80
- r.exit_code.should == 0
81
- end
82
-
83
- psql('-c "show lc_ctype" test1') do |r|
84
- r.stdout.should =~ /en_NG/
85
- end
86
-
87
- psql('-c "show lc_collate" test1') do |r|
88
- r.stdout.should =~ /en_NG/
89
- end
90
- ensure
91
- psql('--command="drop database test1" postgres')
92
- end
93
- end
94
-
95
- it 'should take an istemplate parameter' do
96
- begin
97
- pp = <<-EOS
98
- $db = 'template2'
99
- include postgresql::server
100
-
101
- postgresql::db { $db:
102
- user => $db,
103
- password => postgresql_password($db, $db),
104
- istemplate => true,
105
- }
106
- EOS
107
-
108
- puppet_apply(pp) do |r|
109
- r.exit_code.should_not == 1
110
- r.refresh
111
- r.exit_code.should == 0
112
- end
113
-
114
- psql('--command="select datname from pg_database" template2') do |r|
115
- r.stdout.should =~ /template2/
116
- r.stderr.should be_empty
117
- r.exit_code.should == 0
118
- end
119
- ensure
120
- psql('--command="drop database template2" postgres') do |r|
121
- r.stdout.should be_empty
122
- r.stderr.should =~ /cannot drop a template database/
123
- r.exit_code.should_not == 0
124
- end
125
- end
126
- end
127
-
128
- it 'should update istemplate parameter' do
129
- begin
130
- pp = <<-EOS
131
- $db = 'template2'
132
- include postgresql::server
133
-
134
- postgresql::db { $db:
135
- user => $db,
136
- password => postgresql_password($db, $db),
137
- istemplate => false,
138
- }
139
- EOS
140
-
141
- puppet_apply(pp) do |r|
142
- r.exit_code.should_not == 1
143
- r.refresh
144
- r.exit_code.should == 0
145
- end
146
-
147
- psql('--command="select datname from pg_database" template2') do |r|
148
- r.stdout.should =~ /template2/
149
- r.stderr.should be_empty
150
- r.exit_code.should == 0
151
- end
152
- ensure
153
- psql('--command="drop database template2" postgres') do |r|
154
- r.exit_code.should == 0
155
- end
156
- end
157
- end
158
- end
159
-
160
- describe 'custom postgres password' do
161
- it 'should install and successfully adjust the password' do
162
- pp = <<-EOS
163
- class { "postgresql::server":
164
- config_hash => {
165
- 'postgres_password' => 'TPSReports!',
166
- 'ip_mask_deny_postgres_user' => '0.0.0.0/32',
167
- },
168
- }
169
- EOS
170
-
171
- puppet_apply(pp) do |r|
172
- [0,2].should include(r.exit_code)
173
- r.stdout.should =~ /\[set_postgres_postgrespw\]\/returns: executed successfully/
174
- end
175
- puppet_apply(pp) do |r|
176
- r.exit_code.should == 0
177
- end
178
-
179
- pp = <<-EOS
180
- class { "postgresql::server":
181
- config_hash => {
182
- 'postgres_password' => 'TPSR$$eports!',
183
- 'ip_mask_deny_postgres_user' => '0.0.0.0/32',
184
- },
185
- }
186
- EOS
187
-
188
- puppet_apply(pp) do |r|
189
- [0,2].should include(r.exit_code)
190
- r.stdout.should =~ /\[set_postgres_postgrespw\]\/returns: executed successfully/
191
- end
192
- puppet_apply(pp) do |r|
193
- r.exit_code.should == 0
194
- end
195
-
196
- end
197
- end
198
-
199
- describe 'postgresql::psql' do
200
- it 'should work but emit a deprecation warning' do
201
- pp = <<-EOS
202
- include postgresql::server
203
-
204
- postgresql::psql { 'foobar':
205
- db => 'postgres',
206
- user => 'postgres',
207
- command => 'select * from pg_database limit 1',
208
- unless => 'select 1 where 1=1',
209
- require => Class['postgresql::server'],
210
- }
211
- EOS
212
-
213
- puppet_apply(pp) do |r|
214
- r.exit_code.should_not == 1
215
- r.stdout.should =~ /postgresql::psql is deprecated/
216
- r.refresh
217
- r.exit_code.should == 2
218
- r.stdout.should =~ /postgresql::psql is deprecated/
219
- end
220
- end
221
- end
222
-
223
- describe 'postgresql_psql' do
224
- it 'should run some SQL when the unless query returns no rows' do
225
- pp = <<-EOS
226
- include postgresql::server
227
-
228
- postgresql_psql { 'foobar':
229
- db => 'postgres',
230
- psql_user => 'postgres',
231
- command => 'select 1',
232
- unless => 'select 1 where 1=2',
233
- require => Class['postgresql::server'],
234
- }
235
- EOS
236
-
237
- puppet_apply(pp) do |r|
238
- r.exit_code.should_not == 1
239
- r.refresh
240
- r.exit_code.should == 2
241
- end
242
- end
243
-
244
- it 'should not run SQL when the unless query returns rows' do
245
- pp = <<-EOS
246
- include postgresql::server
247
-
248
- postgresql_psql { 'foobar':
249
- db => 'postgres',
250
- psql_user => 'postgres',
251
- command => 'select * from pg_database limit 1',
252
- unless => 'select 1 where 1=1',
253
- require => Class['postgresql::server'],
254
- }
255
- EOS
256
-
257
- puppet_apply(pp) do |r|
258
- r.exit_code.should_not == 1
259
- r.refresh
260
- r.exit_code.should == 0
261
- end
262
- end
263
- end
264
-
265
- describe 'postgresql::database_user' do
266
- it 'should idempotently create a user who can log in' do
267
- pp = <<-EOS
268
- $user = "postgresql_test_user"
269
- $password = "postgresql_test_password"
270
-
271
- include postgresql::server
272
-
273
- # Since we are not testing pg_hba or any of that, make a local user for ident auth
274
- user { $user:
275
- ensure => present,
276
- }
277
-
278
- postgresql::database_user { $user:
279
- password_hash => postgresql_password($user, $password),
280
- require => [ Class['postgresql::server'],
281
- User[$user] ],
282
- }
283
- EOS
284
-
285
- puppet_apply(pp) do |r|
286
- r.exit_code.should_not == 1
287
- r.refresh
288
- r.exit_code.should == 0
289
- end
290
-
291
- # Check that the user can log in
292
- psql('--command="select datname from pg_database" postgres', 'postgresql_test_user') do |r|
293
- r.stdout.should =~ /template1/
294
- r.stderr.should == ''
295
- r.exit_code.should == 0
296
- end
297
- end
298
-
299
- it 'should idempotently alter a user who can log in' do
300
- pp = <<-EOS
301
- $user = "postgresql_test_user"
302
- $password = "postgresql_test_password2"
303
-
304
- include postgresql::server
305
-
306
- # Since we are not testing pg_hba or any of that, make a local user for ident auth
307
- user { $user:
308
- ensure => present,
309
- }
310
-
311
- postgresql::database_user { $user:
312
- password_hash => postgresql_password($user, $password),
313
- require => [ Class['postgresql::server'],
314
- User[$user] ],
315
- }
316
- EOS
317
-
318
- puppet_apply(pp) do |r|
319
- r.exit_code.should_not == 1
320
- r.refresh
321
- r.exit_code.should == 0
322
- end
323
-
324
- # Check that the user can log in
325
- psql('--command="select datname from pg_database" postgres', 'postgresql_test_user') do |r|
326
- r.stdout.should =~ /template1/
327
- r.stderr.should == ''
328
- r.exit_code.should == 0
329
- end
330
- end
331
-
332
- it 'should idempotently create a user with a cleartext password' do
333
- pp = <<-EOS
334
- $user = "postgresql_test_user2"
335
- $password = "postgresql_test_password2"
336
-
337
- include postgresql::server
338
-
339
- # Since we are not testing pg_hba or any of that, make a local user for ident auth
340
- user { $user:
341
- ensure => present,
342
- }
343
-
344
- postgresql::database_user { $user:
345
- password_hash => $password,
346
- require => [ Class['postgresql::server'],
347
- User[$user] ],
348
- }
349
- EOS
350
-
351
- puppet_apply(pp) do |r|
352
- r.exit_code.should_not == 1
353
- r.refresh
354
- r.exit_code.should == 0
355
- end
356
-
357
- # Check that the user can log in
358
- psql('--command="select datname from pg_database" postgres', 'postgresql_test_user2') do |r|
359
- r.stdout.should =~ /template1/
360
- r.stderr.should == ''
361
- r.exit_code.should == 0
362
- end
363
- end
364
- end
365
-
366
- describe 'postgresql::database_grant' do
367
- it 'should grant access so a user can create in a database' do
368
- begin
369
- pp = <<-EOS
370
- $db = 'postgres'
371
- $user = 'psql_grant_tester'
372
- $password = 'psql_grant_pw'
373
-
374
- include postgresql::server
375
-
376
- # Since we are not testing pg_hba or any of that, make a local user for ident auth
377
- user { $user:
378
- ensure => present,
379
- }
380
-
381
- postgresql::database_user { $user:
382
- password_hash => postgresql_password($user, $password),
383
- require => [
384
- Class['postgresql::server'],
385
- User[$user],
386
- ],
387
- }
388
-
389
- postgresql::database { $db:
390
- require => Class['postgresql::server'],
391
- }
392
-
393
- postgresql::database_grant { 'grant create test':
394
- privilege => 'CREATE',
395
- db => $db,
396
- role => $user,
397
- require => [
398
- Postgresql::Database[$db],
399
- Postgresql::Database_user[$user],
400
- ],
401
- }
402
- EOS
403
-
404
- puppet_apply(pp) do |r|
405
- r.exit_code.should_not == 1
406
- r.refresh
407
- r.exit_code.should == 0
408
- end
409
-
410
- # Check that the user can create a table in the database
411
- psql('--command="create table foo (foo int)" postgres', 'psql_grant_tester') do |r|
412
- r.stdout.should =~ /CREATE TABLE/
413
- r.stderr.should == ''
414
- r.exit_code.should == 0
415
- end
416
- ensure
417
- psql('--command="drop table foo" postgres', 'psql_grant_tester')
418
- end
419
- end
420
- end
421
-
422
- describe 'postgresql::table_grant' do
423
- it 'should grant access so a user can insert in a table' do
424
- begin
425
- pp = <<-EOS
426
- $db = 'table_grant'
427
- $user = 'psql_table_tester'
428
- $password = 'psql_table_pw'
429
-
430
- include postgresql::server
431
-
432
- # Since we are not testing pg_hba or any of that, make a local user for ident auth
433
- user { $user:
434
- ensure => present,
435
- }
436
-
437
- postgresql::database_user { $user:
438
- password_hash => postgresql_password($user, $password),
439
- require => [
440
- Class['postgresql::server'],
441
- User[$user],
442
- ],
443
- }
444
-
445
- postgresql::database { $db:
446
- require => Class['postgresql::server'],
447
- }
448
-
449
- postgresql_psql { 'Create testing table':
450
- command => 'CREATE TABLE "test_table" (field integer NOT NULL)',
451
- db => $db,
452
- unless => "SELECT * FROM pg_tables WHERE tablename = 'test_table'",
453
- require => Postgresql::Database[$db],
454
- }
455
-
456
- postgresql::table_grant { 'grant insert test':
457
- privilege => 'INSERT',
458
- table => 'test_table',
459
- db => $db,
460
- role => $user,
461
- require => [
462
- Postgresql::Database[$db],
463
- Postgresql::Database_user[$user],
464
- Postgresql_psql['Create testing table'],
465
- ],
466
- }
467
- EOS
468
-
469
- puppet_apply(pp) do |r|
470
- r.exit_code.should_not == 1
471
- r.refresh
472
- r.exit_code.should == 0
473
- end
474
-
475
- ## Check that the user can create a table in the database
476
- #psql('--command="create table foo (foo int)" postgres', 'psql_grant_tester') do |r|
477
- # r.stdout.should =~ /CREATE TABLE/
478
- # r.stderr.should be_empty
479
- # r.exit_code.should == 0
480
- #end
481
- ensure
482
- #psql('--command="drop table foo" postgres', 'psql_grant_tester')
483
- end
484
- end
485
- end
486
-
487
- describe 'postgresql::validate_db_connections' do
488
- it 'should run puppet with no changes declared if database connectivity works' do
489
- pp = <<-EOS
490
- $db = 'foo'
491
- include postgresql::server
492
-
493
- postgresql::db { $db:
494
- user => $db,
495
- password => postgresql_password($db, $db),
496
- }
497
- EOS
498
-
499
- puppet_apply(pp) do |r|
500
- r.exit_code.should_not == 1
501
- r.refresh
502
- r.exit_code.should == 0
503
- end
504
-
505
- pp = <<-EOS
506
- postgresql::validate_db_connection { 'foo':
507
- database_host => 'localhost',
508
- database_name => 'foo',
509
- database_username => 'foo',
510
- database_password => 'foo',
511
- }
512
- EOS
513
-
514
- puppet_apply(pp) do |r|
515
- r.exit_code.should == 0
516
- end
517
- end
518
-
519
- it 'should fail catalogue if database connectivity fails' do
520
- pp = <<-EOS
521
- postgresql::validate_db_connection { 'foobarbaz':
522
- database_host => 'localhost',
523
- database_name => 'foobarbaz',
524
- database_username => 'foobarbaz',
525
- database_password => 'foobarbaz',
526
- }
527
- EOS
528
-
529
- puppet_apply(pp) do |r|
530
- r.exit_code.should == 4
531
- end
532
- end
533
- end
534
-
535
- describe 'postgresql::tablespace' do
536
- it 'should idempotently create tablespaces and databases that are using them' do
537
- pp = <<-EOS
538
- include postgresql::server
539
-
540
- file { '/tmp/pg_tablespaces':
541
- ensure => 'directory',
542
- owner => 'postgres',
543
- group => 'postgres',
544
- mode => '0700',
545
- }~>
546
- # This works around rubies that lack Selinux support, I'm looking at you RHEL5
547
- exec { "chcon -u system_u -r object_r -t postgresql_db_t /tmp/pg_tablespaces":
548
- refreshonly => true,
549
- path => "/bin:/usr/bin",
550
- onlyif => "which chcon",
551
- before => File["/tmp/pg_tablespaces/space1", "/tmp/pg_tablespaces/space2"]
552
- }
553
-
554
- postgresql::tablespace{ 'tablespace1':
555
- location => '/tmp/pg_tablespaces/space1',
556
- require => [Class['postgresql::server'], File['/tmp/pg_tablespaces']],
557
- }
558
- postgresql::database{ 'tablespacedb1':
559
- charset => 'utf8',
560
- tablespace => 'tablespace1',
561
- require => Postgresql::Tablespace['tablespace1'],
562
- }
563
- postgresql::db{ 'tablespacedb2':
564
- user => 'dbuser2',
565
- password => postgresql_password('dbuser2', 'dbuser2'),
566
- tablespace => 'tablespace1',
567
- require => Postgresql::Tablespace['tablespace1'],
568
- }
569
-
570
- postgresql::database_user{ 'spcuser':
571
- password_hash => postgresql_password('spcuser', 'spcuser'),
572
- require => Class['postgresql::server'],
573
- }
574
- postgresql::tablespace{ 'tablespace2':
575
- location => '/tmp/pg_tablespaces/space2',
576
- owner => 'spcuser',
577
- require => [Postgresql::Database_user['spcuser'], File['/tmp/pg_tablespaces']],
578
- }
579
- postgresql::database{ 'tablespacedb3':
580
- charset => 'utf8',
581
- tablespace => 'tablespace2',
582
- require => Postgresql::Tablespace['tablespace2'],
583
- }
584
- EOS
585
-
586
- puppet_apply(pp) do |r|
587
- r.exit_code.should_not == 1
588
- r.refresh
589
- r.exit_code.should == 0
590
- end
591
-
592
- # Check that databases use correct tablespaces
593
- psql('--command="select ts.spcname from pg_database db, pg_tablespace ts where db.dattablespace = ts.oid and db.datname = \'"\'tablespacedb1\'"\'"') do |r|
594
- r.stdout.should =~ /tablespace1/
595
- r.stderr.should == ''
596
- r.exit_code.should == 0
597
- end
598
-
599
- psql('--command="select ts.spcname from pg_database db, pg_tablespace ts where db.dattablespace = ts.oid and db.datname = \'"\'tablespacedb3\'"\'"') do |r|
600
- r.stdout.should =~ /tablespace2/
601
- r.stderr.should == ''
602
- r.exit_code.should == 0
603
- end
604
- end
605
- end
606
-
607
- describe 'postgresql::pg_hba_rule' do
608
- it 'should create a ruleset in pg_hba.conf' do
609
- pp = <<-EOS
610
- include postgresql::server
611
- postgresql::pg_hba_rule { "allow application network to access app database":
612
- type => "host",
613
- database => "app",
614
- user => "app",
615
- address => "200.1.2.0/24",
616
- auth_method => md5,
617
- }
618
- EOS
619
-
620
- puppet_apply(pp) do |r|
621
- r.exit_code.should_not == 1
622
- end
623
-
624
- puppet_apply(pp) do |r|
625
- r.exit_code.should be_zero
626
- end
627
-
628
- 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|
629
- r.exit_code.should be_zero
630
- end
631
- end
632
-
633
- it 'should create a ruleset in pg_hba.conf that denies db access to db test1' do
634
- pp = <<-EOS
635
- include postgresql::server
636
- postgresql::db { "test1":
637
- user => "test1",
638
- password => postgresql_password('test1', 'test1'),
639
- grant => "all",
640
- }
641
- postgresql::pg_hba_rule { "allow anyone to have access to db test1":
642
- type => "local",
643
- database => "test1",
644
- user => "test1",
645
- auth_method => reject,
646
- order => '001',
647
- }
648
- user { "test1":
649
- shell => "/bin/bash",
650
- managehome => true,
651
- }
652
- EOS
653
- puppet_apply(pp) do |r|
654
- r.exit_code.should_not == 1
655
- end
656
-
657
- shell('su - test1 -c \'psql -U test1 -c "\q" test1\'') do |r|
658
- r.exit_code.should == 2
659
- end
660
- end
661
- end
662
-
663
- describe 'postgresql.conf include' do
664
- it "should support an 'include' directive at the end of postgresql.conf" do
665
- pending('no support for include directive with centos 5/postgresql 8.1', :if => (node.facts['osfamily'] == 'RedHat' and node.facts['lsbmajdistrelease'] == '5'))
666
- pp = <<-EOS
667
- class pg_test {
668
- class { 'postgresql::server': }
669
-
670
- $pg_conf_include_file = "${postgresql::params::confdir}/postgresql_puppet_extras.conf"
671
-
672
- file { $pg_conf_include_file :
673
- content => 'max_connections = 123',
674
- notify => Service['postgresqld'],
675
- }
676
- }
677
- class { 'pg_test': }
678
- EOS
679
-
680
- puppet_apply(pp) do |r|
681
- r.exit_code.should_not == 1
682
- r.refresh
683
- r.exit_code.should be_zero
684
- end
685
-
686
- psql('--command="show max_connections" -t') do |r|
687
- r.stdout.should =~ /123/
688
- r.stderr.should == ''
689
- r.exit_code.should == 0
690
- end
691
-
692
- pp = <<-EOS
693
- class cleanup {
694
- require postgresql::params
695
-
696
- $pg_conf_include_file = "${postgresql::params::confdir}/postgresql_puppet_extras.conf"
697
-
698
- file { $pg_conf_include_file :
699
- ensure => absent
700
- }
701
- }
702
- class { 'cleanup': }
703
- EOS
704
- puppet_apply(pp)
705
- end
706
- end
707
- end