from-scratch 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/Berksfile +1 -1
  3. data/Berksfile.lock +7 -4
  4. data/cookbooks/openssl/CHANGELOG.md +43 -2
  5. data/cookbooks/openssl/README.md +149 -55
  6. data/cookbooks/openssl/libraries/helpers.rb +60 -0
  7. data/cookbooks/openssl/libraries/matchers.rb +13 -0
  8. data/cookbooks/openssl/libraries/random_password.rb +82 -0
  9. data/cookbooks/openssl/libraries/secure_password.rb +3 -2
  10. data/cookbooks/openssl/metadata.json +1 -31
  11. data/cookbooks/openssl/providers/dhparam.rb +33 -0
  12. data/cookbooks/openssl/providers/rsa_key.rb +39 -0
  13. data/cookbooks/openssl/providers/x509.rb +44 -34
  14. data/cookbooks/openssl/recipes/upgrade.rb +13 -11
  15. data/cookbooks/openssl/resources/dhparam.rb +10 -0
  16. data/cookbooks/openssl/resources/rsa_key.rb +10 -0
  17. data/cookbooks/openssl/resources/x509.rb +11 -11
  18. data/cookbooks/postgresql/.gitignore +18 -0
  19. data/cookbooks/postgresql/.kitchen.yml +175 -0
  20. data/cookbooks/postgresql/.rspec +3 -0
  21. data/cookbooks/postgresql/CHANGELOG.md +1 -1
  22. data/cookbooks/postgresql/CONTRIBUTING.md +6 -0
  23. data/cookbooks/postgresql/Cheffile +6 -0
  24. data/cookbooks/postgresql/Gemfile +12 -0
  25. data/cookbooks/postgresql/LICENSE +201 -0
  26. data/cookbooks/postgresql/Rakefile +22 -0
  27. data/cookbooks/postgresql/TESTING.md +22 -0
  28. data/cookbooks/postgresql/attributes/default.rb +72 -1
  29. data/cookbooks/postgresql/metadata.json +7 -12
  30. data/cookbooks/postgresql/providers/database.rb +73 -0
  31. data/cookbooks/postgresql/providers/user.rb +82 -0
  32. data/cookbooks/postgresql/recipes/setup_databases.rb +36 -0
  33. data/cookbooks/postgresql/recipes/setup_users.rb +17 -0
  34. data/cookbooks/postgresql/resources/database.rb +20 -0
  35. data/cookbooks/postgresql/resources/user.rb +20 -0
  36. data/cookbooks/postgresql/test/unit/debian_server_spec.rb +72 -0
  37. data/cookbooks/postgresql/test/unit/default_spec.rb +37 -0
  38. data/cookbooks/postgresql/test/unit/server_spec.rb +41 -0
  39. data/cookbooks/postgresql/test/unit/spec_helper.rb +20 -0
  40. data/cookbooks/scratchify/Berksfile +1 -1
  41. data/cookbooks/scratchify/Berksfile.lock +5 -4
  42. data/cookbooks/scratchify/lib/from-scratch.rb +1 -0
  43. data/cookbooks/scratchify/lib/from-scratch/version.rb +1 -1
  44. data/cookbooks/scratchify/templates/node.json.erb +17 -0
  45. data/from-scratch.gemspec +2 -2
  46. data/lib/from-scratch.rb +7 -3
  47. data/lib/from-scratch/version.rb +1 -1
  48. data/templates/node.json.erb +33 -0
  49. metadata +33 -7
@@ -0,0 +1,3 @@
1
+ --default-path test/unit
2
+ --color
3
+ --format documentation
@@ -6,7 +6,7 @@ v3.4.20
6
6
  -------
7
7
  - Revert [#251](https://github.com/hw-cookbooks/postgresql/pull/251), a change which caused the postgresql service to restart every Chef run.
8
8
 
9
- v3.4.19 [YANKED]
9
+ v3.4.19
10
10
  -------
11
11
  - node.save could better not be run on every chef run since it causes node.default attributes stored to the node objects to differ during a chef run and when
12
12
  - Missing attribute in docs for yum_pgdg_postgresql
@@ -0,0 +1,6 @@
1
+ 1. Fork the repository using Github.
2
+ 1. Checkout a named feature branch created from the `develop` branch.
3
+ 1. Write tests using chefspec or serverspec as appropriate.
4
+ 1. Complete modifications or corrections.
5
+ 1. Run the tests, ensuring they all pass.
6
+ 1. Submit a Pull Request to the `develop` branch using Github.
@@ -0,0 +1,6 @@
1
+ site "https://supermarket.getchef.com/api/v1"
2
+
3
+ cookbook 'postgresql', :path => '.'
4
+
5
+ cookbook 'build-essential'
6
+ cookbook 'minitest-handler'
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'emeril', :group => :release
4
+ gem 'rake'
5
+
6
+ group :integration do
7
+ gem 'test-kitchen'
8
+ gem 'kitchen-vagrant'
9
+ gem 'kitchen-docker'
10
+ end
11
+ gem 'chefspec', '~> 4.2.0'
12
+ gem 'librarian-chef'
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env rake
2
+
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec) do |t|
6
+ t.pattern = [ 'test/unit/**{,/*/**}/*_spec.rb' ]
7
+ end
8
+ rescue LoadError
9
+ end
10
+
11
+ begin
12
+ require 'kitchen/rake_tasks'
13
+ Kitchen::RakeTasks.new
14
+ rescue LoadError
15
+ puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI']
16
+ end
17
+
18
+ begin
19
+ require 'emeril/rake'
20
+ rescue LoadError
21
+ puts ">>>>> Emeril gem not loaded, omitting tasks" unless ENV['CI']
22
+ end
@@ -0,0 +1,22 @@
1
+ This cookbook includes support for running unit tests under ChefSpec and integration tests under Test Kitchen.
2
+
3
+ Before you can run these tests:
4
+
5
+ 1. You must be using the Git repository, rather than the downloaded cookbook from the Chef Community Site.
6
+ 2. You must have Vagrant 1.1 installed.
7
+ 3. You must have a "sane" Ruby 1.9.3 environment with `bundler`
8
+
9
+ Once the above requirements are met, install the gem dependenies:
10
+
11
+ bundle install
12
+
13
+ With the bundle installed, you should be able to run Test Kitchen:
14
+
15
+ bundle exec kitchen list
16
+ bundle exec kitchen test
17
+
18
+ You can use the tasks defined in the Rakefile for running tests. For example, the following commands will run
19
+ the ChefSpec unit tests and all of the configured Test Kitchen platform/suite permuations:
20
+
21
+ bundle exec rake spec
22
+ bundle exec rake kitchen:all
@@ -224,7 +224,7 @@ default['postgresql']['initdb_locale'] = nil
224
224
  # access to the PGDG yum repositories. Links to RPMs for installation
225
225
  # on the supported version/platform combinations are listed at
226
226
  # http://yum.postgresql.org/repopackages.php, and the links for
227
- # PostgreSQL 8.4, 9.0, 9.1, 9.2 and 9.3 are captured below.
227
+ # PostgreSQL 8.4, 9.0, 9.1, 9.2, 9.3 and 9.4 are captured below.
228
228
  #
229
229
  # The correct RPM for installing /etc/yum.repos.d is based on:
230
230
  # * the attribute configuring the desired Postgres Software:
@@ -238,6 +238,68 @@ default['postgresql']['pgdg']['repo_rpm_url'] = {
238
238
  "redhat" => {
239
239
  "7" => {
240
240
  "x86_64" => "http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-redhat94-9.4-1.noarch.rpm"
241
+ },
242
+ "6" => {
243
+ "i386" => "http://yum.postgresql.org/9.4/redhat/rhel-6-i386/pgdg-redhat94-9.4-1.noarch.rpm",
244
+ "x86_64" => "http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-redhat94-9.4-1.noarch.rpm"
245
+ },
246
+ "5" => {
247
+ "i386" => "http://yum.postgresql.org/9.4/redhat/rhel-5-i386/pgdg-redhat94-9.4-1.noarch.rpm",
248
+ "x86_64" => "http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/pgdg-redhat94-9.4-1.noarch.rpm"
249
+ }
250
+ },
251
+ "centos" => {
252
+ "7" => {
253
+ "x86_64" => "http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm"
254
+ },
255
+ "6" => {
256
+ "i386" => "http://yum.postgresql.org/9.4/redhat/rhel-6-i386/pgdg-centos94-9.4-1.noarch.rpm",
257
+ "x86_64" => "http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm"
258
+ },
259
+ "5" => {
260
+ "x86_64" => "http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/pgdg-centos94-9.4-1.noarch.rpm",
261
+ "i386" => "http://yum.postgresql.org/9.4/redhat/rhel-5-i386/pgdg-centos94-9.4-1.noarch.rpm"
262
+ }
263
+ },
264
+ "fedora" => {
265
+ "22" => {
266
+ "x86_64" => "http://yum.postgresql.org/9.4/fedora/fedora-22-x86_64/pgdg-fedora94-9.4-3.noarch.rpm"
267
+ },
268
+ "21" => {
269
+ "x86_64" => "http://yum.postgresql.org/9.4/fedora/fedora-21-x86_64/pgdg-fedora94-9.4-2.noarch.rpm",
270
+ "i386" => "http://yum.postgresql.org/9.4/fedora/fedora-21-i686/pgdg-fedora94-9.4-2.noarch.rpm"
271
+ },
272
+ "20" => {
273
+ "x86_64" => "http://yum.postgresql.org/9.4/fedora/fedora-20-x86_64/pgdg-fedora94-9.4-1.noarch.rpm",
274
+ "i386" => "http://yum.postgresql.org/9.4/fedora/fedora-20-i686/pgdg-fedora94-9.4-1.noarch.rpm"
275
+ }
276
+ },
277
+ "amazon" => {
278
+ "2015" => {
279
+ "i386" => "http://yum.postgresql.org/9.4/redhat/rhel-6-i386/pgdg-ami201503-94-9.4-1.noarch.rpm",
280
+ "x86_64" => "http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-ami201503-94-9.4-1.noarch.rpm"
281
+ }
282
+ },
283
+ "scientific" => {
284
+ "7" => {
285
+ "x86_64" => "http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-sl94-9.4-1.noarch.rpm"
286
+ },
287
+ "6" => {
288
+ "i386" => "http://yum.postgresql.org/9.4/redhat/rhel-6-i386/pgdg-sl94-9.4-1.noarch.rpm",
289
+ "x86_64" => "http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-sl94-9.4-1.noarch.rpm"
290
+ },
291
+ "5" => {
292
+ "i386" => "http://yum.postgresql.org/9.4/redhat/rhel-5-i386/pgdg-sl94-9.4-1.noarch.rpm",
293
+ "x86_64" => "http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/pgdg-sl94-9.4-1.noarch.rpm"
294
+ }
295
+ },
296
+ "oracle" => {
297
+ "7" => {
298
+ "x86_64" => "http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-oraclelinux94-9.4-1.noarch.rpm"
299
+ },
300
+ "6" => {
301
+ "i386" => "http://yum.postgresql.org/9.4/redhat/rhel-6-i386/pgdg-oraclelinux94-9.4-1.noarch.rpm",
302
+ "x86_64" => "http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-oraclelinux94-9.4-1.noarch.rpm"
241
303
  }
242
304
  }
243
305
  },
@@ -547,3 +609,12 @@ default['postgresql']['pgdg']['repo_rpm_url'] = {
547
609
  },
548
610
  };
549
611
 
612
+
613
+ #------------------------------------------------------------------------------
614
+ # USERS AND DATABASES
615
+ #------------------------------------------------------------------------------
616
+
617
+ default["postgresql"]["users"] = []
618
+ default["postgresql"]["databases"] = []
619
+ default["postgresql"]["extensions"] = []
620
+ default["postgresql"]["languages"] = []
@@ -6,7 +6,7 @@
6
6
  "maintainer_email": "support@hw-ops.com",
7
7
  "license": "Apache 2.0",
8
8
  "platforms": {
9
- "ubuntu": "< 14.10",
9
+ "ubuntu": "< 14.10.0",
10
10
  "debian": ">= 0.0.0",
11
11
  "fedora": ">= 0.0.0",
12
12
  "suse": ">= 0.0.0",
@@ -19,28 +19,21 @@
19
19
  "dependencies": {
20
20
  "apt": ">= 1.9.0",
21
21
  "build-essential": ">= 0.0.0",
22
- "openssl": "~> 4.0.0"
22
+ "openssl": "~> 4.0"
23
23
  },
24
24
  "recommendations": {
25
-
26
25
  },
27
26
  "suggestions": {
28
-
29
27
  },
30
28
  "conflicting": {
31
-
32
29
  },
33
30
  "providing": {
34
-
35
31
  },
36
32
  "replacing": {
37
-
38
33
  },
39
34
  "attributes": {
40
-
41
35
  },
42
36
  "groupings": {
43
-
44
37
  },
45
38
  "recipes": {
46
39
  "postgresql": "Includes postgresql::client",
@@ -48,9 +41,11 @@
48
41
  "postgresql::client": "Installs postgresql client package(s)",
49
42
  "postgresql::server": "Installs postgresql server packages, templates",
50
43
  "postgresql::server_redhat": "Installs postgresql server packages, redhat family style",
51
- "postgresql::server_debian": "Installs postgresql server packages, debian family style"
44
+ "postgresql::server_debian": "Installs postgresql server packages, debian family style",
45
+ "postgresql::setup_users": "Operates with DB users",
46
+ "postgresql::setup_databases": "Operates with DB schemas"
52
47
  },
53
- "version": "3.4.20",
48
+ "version": "3.4.21",
54
49
  "source_url": "",
55
50
  "issues_url": ""
56
- }
51
+ }
@@ -0,0 +1,73 @@
1
+ #
2
+ # Cookbook Name:: postgresql
3
+ # Provider:: database
4
+ #
5
+
6
+ # Support whyrun
7
+ def whyrun_supported?
8
+ true
9
+ end
10
+
11
+ action :create do
12
+ unless @current_resource.exists
13
+ converge_by "Create PostgreSQL Database #{new_resource.name}" do
14
+ createdb = "createdb"
15
+ createdb << " -U #{new_resource.username}" if new_resource.username
16
+ createdb << " -E #{new_resource.encoding}" if new_resource.encoding
17
+ createdb << " -l #{new_resource.locale}" if new_resource.locale
18
+ createdb << " -T #{new_resource.template}" if new_resource.template
19
+ createdb << " -h #{new_resource.host}" if new_resource.host
20
+ createdb << " -p #{new_resource.port}" if new_resource.port
21
+ createdb << " -O #{new_resource.owner}" if new_resource.owner
22
+ createdb << " #{new_resource.name}"
23
+
24
+ execute %(create postgresql database #{new_resource.name}) do # ~FC009
25
+ user "postgres"
26
+ command createdb
27
+ sensitive true
28
+ end
29
+
30
+ new_resource.updated_by_last_action(true)
31
+ end
32
+ end
33
+ end
34
+
35
+ action :drop do
36
+ if @current_resource.exists
37
+ converge_by "Drop PostgreSQL Database #{new_resource.name}" do
38
+ dropdb = "dropdb"
39
+ dropdb << " -U #{new_resource.username}" if new_resource.username
40
+ dropdb << " --host #{new_resource.host}" if new_resource.host
41
+ dropdb << " --port #{new_resource.port}" if new_resource.port
42
+ dropdb << " #{new_resource.name}"
43
+
44
+ execute %(drop postgresql database #{new_resource.name}) do
45
+ user "postgres"
46
+ command dropdb
47
+ sensitive true
48
+ end
49
+
50
+ new_resource.updated_by_last_action(true)
51
+ end
52
+ end
53
+ end
54
+
55
+ def load_current_resource
56
+ @current_resource = Chef::Resource::PostgresqlDatabase.new(new_resource.name)
57
+ @current_resource.name(new_resource.name)
58
+
59
+ @current_resource.exists = database_exists?
60
+ end
61
+
62
+ def database_exists? # rubocop:disable AbcSize
63
+ sql = %(SELECT datname from pg_database WHERE datname='#{new_resource.name}')
64
+
65
+ exists = %(psql -c "#{sql}" postgres)
66
+ exists << " --host #{new_resource.host}" if new_resource.host
67
+ exists << " --port #{new_resource.port}" if new_resource.port
68
+ exists << " | grep #{new_resource.name}"
69
+
70
+ cmd = Mixlib::ShellOut.new(exists, user: "postgres")
71
+ cmd.run_command
72
+ cmd.exitstatus.zero?
73
+ end