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
data/lib/from-scratch.rb CHANGED
@@ -6,7 +6,11 @@ module FromScratch
6
6
  def self.run!
7
7
  app_name, host = ARGV
8
8
  ssh_pub_key = `cat ~/.ssh/id_rsa.pub`.strip
9
- postgresql_admin_password = `echo -n '#{SecureRandom.hex(64)}''postgres' | openssl md5 | sed -e 's/.* /md5/'`.strip
9
+ postgresql_admin_password = `echo -n '#{SecureRandom.base64(16)}''postgres' | openssl md5 | sed -e 's/.* /md5/'`.strip
10
+
11
+ puts "Your PG #{app_name} password is:"
12
+ puts postgresql_user_password = SecureRandom.base64(16)
13
+ puts
10
14
 
11
15
  { node: ['nodes', host], user: ['data_bags/users', 'deploy'] }.each do |from, to|
12
16
  FileUtils.mkdir_p File.expand_path("../../tmp/#{to[0]}", __FILE__)
@@ -16,8 +20,8 @@ module FromScratch
16
20
  end
17
21
 
18
22
  Dir.chdir(File.expand_path('../..', __FILE__)) do
19
- system "knife solo bootstrap root@#{host}"
20
- system "knife solo clean root@#{host}"
23
+ system "knife solo bootstrap root@#{host} -c ./.chef/knife.rb"
24
+ system "knife solo clean root@#{host} -c ./.chef/knife.rb"
21
25
  end
22
26
 
23
27
  FileUtils.rm_rf [File.expand_path('../../tmp', __FILE__)]
@@ -1,3 +1,3 @@
1
1
  module FromScratch
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -3,6 +3,8 @@
3
3
  "recipe[rvm::system]",
4
4
  "recipe[postgresql::server]",
5
5
  "recipe[postgresql::config_pgtune]",
6
+ "recipe[postgresql::setup_users]",
7
+ "recipe[postgresql::setup_databases]",
6
8
  "recipe[user::data_bag]",
7
9
  "recipe[scratchify]"
8
10
  ],
@@ -23,6 +25,37 @@
23
25
  "password": {
24
26
  "postgres": "<%= postgresql_admin_password %>"
25
27
  },
28
+ "users": [
29
+ {
30
+ "username": "<%= app_name %>",
31
+ "superuser": false,
32
+ "createdb": false,
33
+ "login": true,
34
+ "password": "<%= postgresql_user_password %>"
35
+ }
36
+ ],
37
+ "databases": [
38
+ {
39
+ "name": "<%= app_name %>",
40
+ "owner": "<%= app_name %>"
41
+ }
42
+ ],
43
+ "pg_hba": [
44
+ {
45
+ "type": "host",
46
+ "db": "all",
47
+ "user": "all",
48
+ "addr": "127.0.0.1/32",
49
+ "method": "md5"
50
+ },
51
+ {
52
+ "type": "host",
53
+ "db": "all",
54
+ "user": "all",
55
+ "addr": "::1/128",
56
+ "method": "md5"
57
+ }
58
+ ],
26
59
  "config_pgtune": {
27
60
  "db_type": "web"
28
61
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: from-scratch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Shaydurov
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 3.3.0
47
+ version: '3.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 3.3.0
54
+ version: '3.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '0.10'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '0.10'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: knife-solo
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -234,14 +234,30 @@ files:
234
234
  - cookbooks/openssl/CHANGELOG.md
235
235
  - cookbooks/openssl/README.md
236
236
  - cookbooks/openssl/attributes/default.rb
237
+ - cookbooks/openssl/libraries/helpers.rb
238
+ - cookbooks/openssl/libraries/matchers.rb
239
+ - cookbooks/openssl/libraries/random_password.rb
237
240
  - cookbooks/openssl/libraries/secure_password.rb
238
241
  - cookbooks/openssl/metadata.json
242
+ - cookbooks/openssl/providers/dhparam.rb
243
+ - cookbooks/openssl/providers/rsa_key.rb
239
244
  - cookbooks/openssl/providers/x509.rb
240
245
  - cookbooks/openssl/recipes/default.rb
241
246
  - cookbooks/openssl/recipes/upgrade.rb
247
+ - cookbooks/openssl/resources/dhparam.rb
248
+ - cookbooks/openssl/resources/rsa_key.rb
242
249
  - cookbooks/openssl/resources/x509.rb
250
+ - cookbooks/postgresql/.gitignore
251
+ - cookbooks/postgresql/.kitchen.yml
252
+ - cookbooks/postgresql/.rspec
243
253
  - cookbooks/postgresql/CHANGELOG.md
254
+ - cookbooks/postgresql/CONTRIBUTING.md
255
+ - cookbooks/postgresql/Cheffile
256
+ - cookbooks/postgresql/Gemfile
257
+ - cookbooks/postgresql/LICENSE
244
258
  - cookbooks/postgresql/README.md
259
+ - cookbooks/postgresql/Rakefile
260
+ - cookbooks/postgresql/TESTING.md
245
261
  - cookbooks/postgresql/attributes/default.rb
246
262
  - cookbooks/postgresql/files/default/tests/minitest/apt_pgdg_postgresql_test.rb
247
263
  - cookbooks/postgresql/files/default/tests/minitest/default_test.rb
@@ -250,6 +266,8 @@ files:
250
266
  - cookbooks/postgresql/files/default/tests/minitest/support/helpers.rb
251
267
  - cookbooks/postgresql/libraries/default.rb
252
268
  - cookbooks/postgresql/metadata.json
269
+ - cookbooks/postgresql/providers/database.rb
270
+ - cookbooks/postgresql/providers/user.rb
253
271
  - cookbooks/postgresql/recipes/apt_pgdg_postgresql.rb
254
272
  - cookbooks/postgresql/recipes/client.rb
255
273
  - cookbooks/postgresql/recipes/config_initdb.rb
@@ -261,10 +279,18 @@ files:
261
279
  - cookbooks/postgresql/recipes/server_conf.rb
262
280
  - cookbooks/postgresql/recipes/server_debian.rb
263
281
  - cookbooks/postgresql/recipes/server_redhat.rb
282
+ - cookbooks/postgresql/recipes/setup_databases.rb
283
+ - cookbooks/postgresql/recipes/setup_users.rb
264
284
  - cookbooks/postgresql/recipes/yum_pgdg_postgresql.rb
285
+ - cookbooks/postgresql/resources/database.rb
286
+ - cookbooks/postgresql/resources/user.rb
265
287
  - cookbooks/postgresql/templates/default/pg_hba.conf.erb
266
288
  - cookbooks/postgresql/templates/default/pgsql.sysconfig.erb
267
289
  - cookbooks/postgresql/templates/default/postgresql.conf.erb
290
+ - cookbooks/postgresql/test/unit/debian_server_spec.rb
291
+ - cookbooks/postgresql/test/unit/default_spec.rb
292
+ - cookbooks/postgresql/test/unit/server_spec.rb
293
+ - cookbooks/postgresql/test/unit/spec_helper.rb
268
294
  - cookbooks/rvm/.foodcritic
269
295
  - cookbooks/rvm/.gitignore
270
296
  - cookbooks/rvm/.kitchen.yml