from-scratch 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/Berksfile +1 -7
  3. data/Berksfile.lock +6 -0
  4. data/README.md +8 -3
  5. data/bin/scratchify +1 -1
  6. data/cookbooks/ruby_build/CHANGELOG.md +72 -0
  7. data/cookbooks/ruby_build/README.md +338 -0
  8. data/cookbooks/ruby_build/attributes/default.rb +67 -0
  9. data/cookbooks/ruby_build/libraries/ruby_build_recipe_helpers.rb +40 -0
  10. data/cookbooks/ruby_build/metadata.json +39 -0
  11. data/cookbooks/ruby_build/providers/ruby.rb +88 -0
  12. data/cookbooks/ruby_build/recipes/default.rb +69 -0
  13. data/cookbooks/ruby_build/resources/ruby.rb +33 -0
  14. data/cookbooks/ruby_rbenv/CHANGELOG.md +221 -0
  15. data/cookbooks/ruby_rbenv/README.md +1059 -0
  16. data/cookbooks/ruby_rbenv/attributes/default.rb +73 -0
  17. data/cookbooks/ruby_rbenv/libraries/chef_provider_package_rbenvrubygems.rb +94 -0
  18. data/cookbooks/ruby_rbenv/libraries/chef_rbenv_mixin.rb +49 -0
  19. data/cookbooks/ruby_rbenv/libraries/chef_rbenv_recipe_helpers.rb +118 -0
  20. data/cookbooks/ruby_rbenv/libraries/chef_rbenv_script_helpers.rb +79 -0
  21. data/cookbooks/ruby_rbenv/libraries/matchers.rb +25 -0
  22. data/cookbooks/ruby_rbenv/metadata.json +1 -0
  23. data/cookbooks/ruby_rbenv/providers/global.rb +53 -0
  24. data/cookbooks/ruby_rbenv/providers/plugin.rb +55 -0
  25. data/cookbooks/ruby_rbenv/providers/rehash.rb +45 -0
  26. data/cookbooks/ruby_rbenv/providers/ruby.rb +123 -0
  27. data/cookbooks/ruby_rbenv/providers/script.rb +81 -0
  28. data/cookbooks/ruby_rbenv/recipes/default.rb +23 -0
  29. data/cookbooks/ruby_rbenv/recipes/system.rb +52 -0
  30. data/cookbooks/ruby_rbenv/recipes/system_install.rb +45 -0
  31. data/cookbooks/ruby_rbenv/recipes/user.rb +76 -0
  32. data/cookbooks/ruby_rbenv/recipes/user_install.rb +48 -0
  33. data/cookbooks/ruby_rbenv/resources/gem.rb +44 -0
  34. data/cookbooks/ruby_rbenv/resources/global.rb +33 -0
  35. data/cookbooks/ruby_rbenv/resources/plugin.rb +15 -0
  36. data/cookbooks/ruby_rbenv/resources/rehash.rb +29 -0
  37. data/cookbooks/ruby_rbenv/resources/ruby.rb +43 -0
  38. data/cookbooks/ruby_rbenv/resources/script.rb +39 -0
  39. data/cookbooks/ruby_rbenv/templates/default/rbenv.sh.erb +15 -0
  40. data/cookbooks/scratchify/Berksfile +1 -7
  41. data/cookbooks/scratchify/Berksfile.lock +6 -0
  42. data/cookbooks/scratchify/README.md +8 -3
  43. data/cookbooks/scratchify/bin/scratchify +1 -1
  44. data/cookbooks/scratchify/from-scratch.gemspec +1 -0
  45. data/cookbooks/scratchify/lib/from-scratch.rb +51 -9
  46. data/cookbooks/scratchify/lib/from-scratch/version.rb +2 -2
  47. data/cookbooks/scratchify/metadata.json +2 -1
  48. data/cookbooks/scratchify/spec/from/scratch_spec.rb +62 -5
  49. data/cookbooks/scratchify/spec/spec_helper.rb +8 -1
  50. data/cookbooks/scratchify/templates/node.json.erb +28 -7
  51. data/cookbooks/scratchify/templates/user.json.erb +1 -1
  52. data/from-scratch.gemspec +1 -0
  53. data/lib/from-scratch.rb +51 -9
  54. data/lib/from-scratch/version.rb +2 -2
  55. data/metadata.rb +1 -0
  56. data/templates/node.json.erb +28 -7
  57. data/templates/user.json.erb +1 -1
  58. metadata +50 -3
@@ -0,0 +1,76 @@
1
+ #
2
+ # Cookbook Name:: ruby_rbenv
3
+ # Recipe:: user
4
+ #
5
+ # Copyright 2010, 2011 Fletcher Nichol
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ include_recipe 'ruby_rbenv::user_install'
21
+
22
+ Array(node['rbenv']['user_installs']).each do |rbenv_user|
23
+ plugins = rbenv_user['plugins'] || node['rbenv']['user_plugins']
24
+ rubies = rbenv_user['rubies'] || node['rbenv']['user_rubies']
25
+ gem_hash = rbenv_user['gems'] || node['rbenv']['user_gems']
26
+
27
+ plugins.each do |plugin|
28
+ rbenv_plugin plugin['name'] do
29
+ git_url plugin['git_url']
30
+ git_ref plugin['git_ref'] if plugin['git_ref']
31
+ user rbenv_user['user']
32
+ root_path rbenv_user['root_path'] if rbenv_user['root_path']
33
+ end
34
+ end
35
+
36
+ rubies.each do |rubie|
37
+ if rubie.is_a?(Hash)
38
+ rbenv_ruby "#{rubie['name']} (#{rbenv_user['user']})" do
39
+ definition rubie['name']
40
+ user rbenv_user['user']
41
+ root_path rbenv_user['root_path'] if rbenv_user['root_path']
42
+ environment rubie['environment'] if rubie['environment']
43
+ patch_url rubie['patch_url'] if rubie['patch_url']
44
+ patch_file rubie['patch_file'] if rubie['patch_file']
45
+ end
46
+ else
47
+ rbenv_ruby "#{rubie} (#{rbenv_user['user']})" do
48
+ definition rubie
49
+ user rbenv_user['user']
50
+ root_path rbenv_user['root_path'] if rbenv_user['root_path']
51
+ end
52
+ end
53
+ end
54
+
55
+ rbenv_global "#{rbenv_user['global']} (#{rbenv_user['user']})" do
56
+ rbenv_version rbenv_user['global']
57
+ user rbenv_user['user']
58
+ root_path rbenv_user['root_path'] if rbenv_user['root_path']
59
+ only_if { rbenv_user['global'] }
60
+ end
61
+
62
+ gem_hash.each_pair do |rubie, gems|
63
+ Array(gems).each do |gem|
64
+ rbenv_gem "#{gem['name']} (#{rbenv_user['user']})" do
65
+ package_name gem['name']
66
+ user rbenv_user['user']
67
+ root_path rbenv_user['root_path'] if rbenv_user['root_path']
68
+ rbenv_version rubie
69
+
70
+ %w(version action options source).each do |attr|
71
+ send(attr, gem[attr]) if gem[attr]
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,48 @@
1
+ #
2
+ # Cookbook Name:: ruby_rbenv
3
+ # Recipe:: user_install
4
+ #
5
+ # Copyright 2011, Fletcher Nichol
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ include_recipe 'ruby_rbenv'
21
+
22
+ install_rbenv_pkg_prereqs
23
+
24
+ template '/etc/profile.d/rbenv.sh' do
25
+ source 'rbenv.sh.erb'
26
+ owner 'root'
27
+ mode '0755'
28
+ only_if { node['rbenv']['create_profiled'] }
29
+ end
30
+
31
+ Array(node['rbenv']['user_installs']).each do |rb_user|
32
+ upgrade_strategy = build_upgrade_strategy(rb_user['upgrade'])
33
+ git_url = rb_user['git_url'] || node['rbenv']['git_url']
34
+ git_ref = rb_user['git_ref'] || node['rbenv']['git_ref']
35
+ home_dir = rb_user['home'] || ::File.join(
36
+ node['rbenv']['user_home_root'], rb_user['user'])
37
+ rbenv_prefix = rb_user['root_path'] || ::File.join(home_dir, '.rbenv')
38
+ rbenv_plugins = rb_user['plugins'] || []
39
+
40
+ install_or_upgrade_rbenv rbenv_prefix: rbenv_prefix,
41
+ home_dir: home_dir,
42
+ git_url: git_url,
43
+ git_ref: git_ref,
44
+ upgrade_strategy: upgrade_strategy,
45
+ user: rb_user['user'],
46
+ group: rb_user['group'],
47
+ rbenv_plugins: rbenv_plugins
48
+ end
@@ -0,0 +1,44 @@
1
+ #
2
+ # Cookbook Name:: ruby_rbenv
3
+ # Resource:: gem
4
+ #
5
+ # Author:: Fletcher Nichol <fnichol@nichol.ca>
6
+ #
7
+ # Copyright 2011, Fletcher Nichol
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ actions :install, :upgrade, :remove, :purge
23
+ default_action :install
24
+
25
+ provides :rbenv_gem
26
+
27
+ attribute :package_name, kind_of: String, name_attribute: true
28
+ attribute :rbenv_version, kind_of: String, default: 'global'
29
+ attribute :version, kind_of: String
30
+ attribute :response_file, kind_of: String
31
+ attribute :source, kind_of: String
32
+ attribute :options, kind_of: [String, Hash]
33
+ attribute :gem_binary, kind_of: String
34
+ attribute :user, kind_of: String
35
+ attribute :root_path, kind_of: String
36
+ attribute :clear_sources, kind_of: [TrueClass, FalseClass]
37
+ attribute :timeout, kind_of: Integer, default: 300
38
+
39
+ include Chef::Rbenv::Mixin::ResourceString
40
+
41
+ def initialize(*args)
42
+ super
43
+ @provider = Chef::Provider::Package::RbenvRubygems
44
+ end
@@ -0,0 +1,33 @@
1
+ #
2
+ # Cookbook Name:: ruby_rbenv
3
+ # Resource:: global
4
+ #
5
+ # Author:: Fletcher Nichol <fnichol@nichol.ca>
6
+ #
7
+ # Copyright 2011, Fletcher Nichol
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ actions :create
23
+ default_action :create
24
+
25
+ provides :rbenv_global
26
+
27
+ attribute :rbenv_version, kind_of: String, name_attribute: true
28
+ attribute :user, kind_of: String
29
+ attribute :root_path, kind_of: String
30
+
31
+ def to_s
32
+ "#{super} (#{@user || 'system'})"
33
+ end
@@ -0,0 +1,15 @@
1
+ actions :install
2
+
3
+ default_action :install
4
+
5
+ provides :rbenv_plugin
6
+
7
+ attribute :name, kind_of: String, name_attribute: true
8
+ attribute :git_url, kind_of: String
9
+ attribute :git_ref, kind_of: String
10
+ attribute :user, kind_of: String
11
+ attribute :root_path, kind_of: String
12
+
13
+ def to_s
14
+ "#{super} (#{@user || 'system'})"
15
+ end
@@ -0,0 +1,29 @@
1
+ #
2
+ # Cookbook Name:: ruby_rbenv
3
+ # Resource:: rehash
4
+ #
5
+ # Author:: Fletcher Nichol <fnichol@nichol.ca>
6
+ #
7
+ # Copyright 2011, Fletcher Nichol
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ actions :run
23
+ default_action :run
24
+
25
+ provides :rbenv_rehash
26
+
27
+ attribute :name, kind_of: String, name_attribute: true
28
+ attribute :user, kind_of: String
29
+ attribute :root_path, kind_of: String
@@ -0,0 +1,43 @@
1
+ #
2
+ # Cookbook Name:: ruby_rbenv
3
+ # Resource:: ruby
4
+ #
5
+ # Author:: Fletcher Nichol <fnichol@nichol.ca>
6
+ #
7
+ # Copyright 2011, Fletcher Nichol
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ actions :install, :reinstall
23
+ default_action :install
24
+
25
+ provides :rbenv_ruby
26
+
27
+ attribute :definition, kind_of: String, name_attribute: true
28
+ attribute :definition_file, kind_of: String
29
+ attribute :root_path, kind_of: String
30
+ attribute :user, kind_of: String
31
+ attribute :environment, kind_of: Hash
32
+ attribute :patch_url, kind_of: String
33
+ attribute :patch_file, kind_of: String
34
+ attribute :rbenv_action, kind_of: String, default: 'install'
35
+
36
+ def initialize(*args)
37
+ super
38
+ @rbenv_version = @definition
39
+ end
40
+
41
+ def to_s
42
+ "#{super} (#{@user || 'system'})"
43
+ end
@@ -0,0 +1,39 @@
1
+ #
2
+ # Cookbook Name:: ruby_rbenv
3
+ # Resource:: script
4
+ #
5
+ # Author:: Fletcher Nichol <fnichol@nichol.ca>
6
+ #
7
+ # Copyright 2011, Fletcher Nichol
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ actions :run
23
+ default_action :run
24
+
25
+ provides :rbenv_script
26
+
27
+ attribute :name, kind_of: String, name_attribute: true
28
+ attribute :rbenv_version, kind_of: String
29
+ attribute :root_path, kind_of: String
30
+ attribute :code, kind_of: String
31
+ attribute :creates, kind_of: String
32
+ attribute :cwd, kind_of: String
33
+ attribute :environment, kind_of: Hash
34
+ attribute :group, kind_of: String
35
+ attribute :path, kind_of: Array
36
+ attribute :returns, kind_of: Array, default: [0]
37
+ attribute :timeout, kind_of: Integer
38
+ attribute :user, kind_of: String
39
+ attribute :umask, kind_of: [String, Integer]
@@ -0,0 +1,15 @@
1
+ # Generated by Chef for <%= node['fqdn'] %>
2
+ # Local modifications will be overridden
3
+
4
+ # prefer a user rbenv over a system wide install
5
+ if [ -s "${HOME}/.rbenv/bin" ]; then
6
+ rbenv_root="${HOME}/.rbenv"
7
+ elif [ -s "<%= node['rbenv']['root_path'] %>" ]; then
8
+ rbenv_root="<%= node['rbenv']['root_path'] %>"
9
+ export RBENV_ROOT="$rbenv_root"
10
+ fi
11
+
12
+ if [ -n "$rbenv_root" ]; then
13
+ export PATH="${rbenv_root}/bin:$PATH"
14
+ eval "$(rbenv init -)"
15
+ fi
@@ -9,10 +9,4 @@ cookbook 'user'
9
9
  cookbook 'rvm', github: 'martinisoft/chef-rvm'
10
10
  cookbook 'postgresql', github: 'sandrew/postgresql', branch: 'develop'
11
11
  cookbook 'nginx'
12
-
13
- # cookbook 'dpkg_packages', git: "https://gitlab.acid.cl/acidlabs/chef-dpkg-packages.git"
14
- # cookbook 'nginx', git: "https://gitlab.acid.cl/acidlabs/chef-nginx.git"
15
- # cookbook 'postgresql', git: "https://github.com/phlipper/chef-postgresql.git"
16
- # cookbook 'rvm'
17
- # cookbook 'ssh-hardening'
18
- # cookbook 'sudo'
12
+ cookbook 'ruby_rbenv'
@@ -4,6 +4,7 @@ DEPENDENCIES
4
4
  git: git://github.com/sandrew/postgresql.git
5
5
  revision: a1f3ce3e2e22515bc175011a3e3faa0af98dd8db
6
6
  branch: develop
7
+ ruby_rbenv
7
8
  rvm
8
9
  git: git://github.com/martinisoft/chef-rvm.git
9
10
  revision: 08ec265f277e112a5a2e4b201bd32ddfe1bb968c
@@ -36,6 +37,10 @@ GRAPH
36
37
  build-essential (>= 0.0.0)
37
38
  openssl (~> 4.0)
38
39
  rsyslog (2.2.0)
40
+ ruby_build (0.8.0)
41
+ ruby_rbenv (1.0.1)
42
+ java (> 1.4.0)
43
+ ruby_build (>= 0.0.0)
39
44
  runit (1.7.4)
40
45
  packagecloud (>= 0.0.0)
41
46
  rvm (0.10.1)
@@ -44,6 +49,7 @@ GRAPH
44
49
  scratchify (0.1.0)
45
50
  nginx (>= 0.0.0)
46
51
  postgresql (>= 0.0.0)
52
+ ruby_rbenv (>= 0.0.0)
47
53
  rvm (>= 0.0.0)
48
54
  user (>= 0.0.0)
49
55
  user (0.4.2)
@@ -23,11 +23,16 @@ OS:
23
23
  - APT-based Linux (Ubuntu, Debian)
24
24
  - YUM-based Linux (RedHat, CentOS)
25
25
 
26
+ Ruby installers:
27
+
28
+ - RVM (default)
29
+ - rbenv: `scratchify your_app_name your.host.com --rbenv`
30
+
26
31
  ## It's a kind of magic!
27
32
 
28
33
  Not actully. Just preconfigured [Chef](https://www.chef.io/). Here are the things done with the command:
29
34
 
30
- - Install system-wide RVM with latest MRI (2.2.3)
35
+ - Install user-wide RVM with latest MRI (2.2.3)
31
36
  - Install PostgreSQL, create database with user, pg_tune a little
32
37
  - Add _deploy_ non-admin user to system specially for your app, upload your SSH pub key to it
33
38
  - Install nginx and replace it's default site config with one prepared for rails app
@@ -46,11 +51,11 @@ Both `postgres` and `your_app_name` DB users get (different) randomly generated
46
51
 
47
52
  ## Development
48
53
 
49
- TODO
54
+ Feel free to create bug-reports and feature-requests here on [Issues page](https://github.com/sandrew/from-scratch/issues)
50
55
 
51
56
  ## Contributing
52
57
 
53
- TODO
58
+ All help is highly appreciated. I'll be thankful for recipes fixes and advices as well as new features implementations. Just fork and pull-request when you have some proposals.
54
59
 
55
60
  ## License
56
61
 
@@ -3,4 +3,4 @@
3
3
  require "bundler/setup"
4
4
  require "from-scratch"
5
5
 
6
- FromScratch.run!
6
+ FromScratch.new.run!
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.10"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency 'rspec', "~> 3.3"
24
+ spec.add_development_dependency 'rspec-its'
24
25
  spec.add_development_dependency 'pry', "~> 0.10"
25
26
 
26
27
  spec.add_dependency 'knife-solo'