from-scratch 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +7 -0
  2. data/.chef/knife.rb +6 -0
  3. data/.gitignore +9 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +4 -0
  6. data/Berksfile +17 -0
  7. data/Berksfile.lock +19 -0
  8. data/Gemfile +4 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +58 -0
  11. data/Rakefile +6 -0
  12. data/Thorfile +5 -0
  13. data/bin/scratchify +6 -0
  14. data/chefignore +101 -0
  15. data/cookbooks/chef_gem/CHANGELOG.md +24 -0
  16. data/cookbooks/chef_gem/README.md +38 -0
  17. data/cookbooks/chef_gem/libraries/chef_gem.rb +72 -0
  18. data/cookbooks/chef_gem/metadata.json +29 -0
  19. data/cookbooks/chef_gem/recipes/default.rb +0 -0
  20. data/cookbooks/java/.gitignore +21 -0
  21. data/cookbooks/java/.kitchen.docker.yml +15 -0
  22. data/cookbooks/java/.kitchen.yml +126 -0
  23. data/cookbooks/java/.travis.yml +6 -0
  24. data/cookbooks/java/Berksfile +10 -0
  25. data/cookbooks/java/CHANGELOG.md +398 -0
  26. data/cookbooks/java/CONTRIBUTING.md +12 -0
  27. data/cookbooks/java/Gemfile +15 -0
  28. data/cookbooks/java/ISSUES.md +43 -0
  29. data/cookbooks/java/LICENSE +201 -0
  30. data/cookbooks/java/README.md +402 -0
  31. data/cookbooks/java/Rakefile +60 -0
  32. data/cookbooks/java/TESTING.md +41 -0
  33. data/cookbooks/java/attributes/default.rb +146 -0
  34. data/cookbooks/java/libraries/helpers.rb +120 -0
  35. data/cookbooks/java/libraries/matchers.rb +5 -0
  36. data/cookbooks/java/metadata.json +69 -0
  37. data/cookbooks/java/providers/alternatives.rb +94 -0
  38. data/cookbooks/java/providers/ark.rb +255 -0
  39. data/cookbooks/java/recipes/default.rb +22 -0
  40. data/cookbooks/java/recipes/default_java_symlink.rb +19 -0
  41. data/cookbooks/java/recipes/homebrew.rb +3 -0
  42. data/cookbooks/java/recipes/ibm.rb +76 -0
  43. data/cookbooks/java/recipes/ibm_tar.rb +70 -0
  44. data/cookbooks/java/recipes/openjdk.rb +74 -0
  45. data/cookbooks/java/recipes/oracle.rb +74 -0
  46. data/cookbooks/java/recipes/oracle_i386.rb +73 -0
  47. data/cookbooks/java/recipes/oracle_jce.rb +75 -0
  48. data/cookbooks/java/recipes/oracle_rpm.rb +60 -0
  49. data/cookbooks/java/recipes/purge_packages.rb +20 -0
  50. data/cookbooks/java/recipes/set_attributes_from_version.rb +55 -0
  51. data/cookbooks/java/recipes/set_java_home.rb +44 -0
  52. data/cookbooks/java/recipes/windows.rb +82 -0
  53. data/cookbooks/java/resources/alternatives.rb +30 -0
  54. data/cookbooks/java/resources/ark.rb +58 -0
  55. data/cookbooks/java/templates/default/ibm_jdk.installer.properties.erb +3 -0
  56. data/cookbooks/java/templates/default/oracle.jinfo.erb +6 -0
  57. data/cookbooks/rvm/.foodcritic +1 -0
  58. data/cookbooks/rvm/.gitignore +7 -0
  59. data/cookbooks/rvm/.kitchen.yml +66 -0
  60. data/cookbooks/rvm/.travis.yml +9 -0
  61. data/cookbooks/rvm/Berksfile +10 -0
  62. data/cookbooks/rvm/CHANGELOG.md +253 -0
  63. data/cookbooks/rvm/CODE_OF_CONDUCT.md +12 -0
  64. data/cookbooks/rvm/CONTRIBUTING.md +26 -0
  65. data/cookbooks/rvm/Gemfile +20 -0
  66. data/cookbooks/rvm/Guardfile +12 -0
  67. data/cookbooks/rvm/README.md +1459 -0
  68. data/cookbooks/rvm/Rakefile +18 -0
  69. data/cookbooks/rvm/attributes/.gitkeep +0 -0
  70. data/cookbooks/rvm/attributes/default.rb +68 -0
  71. data/cookbooks/rvm/attributes/gem_package.rb +23 -0
  72. data/cookbooks/rvm/attributes/vagrant.rb +23 -0
  73. data/cookbooks/rvm/libraries/chef_rvm_environment_helpers.rb +55 -0
  74. data/cookbooks/rvm/libraries/chef_rvm_gemset_helpers.rb +67 -0
  75. data/cookbooks/rvm/libraries/chef_rvm_recipe_helpers.rb +80 -0
  76. data/cookbooks/rvm/libraries/chef_rvm_ruby_helpers.rb +95 -0
  77. data/cookbooks/rvm/libraries/chef_rvm_set_helpers.rb +16 -0
  78. data/cookbooks/rvm/libraries/chef_rvm_shell_helpers.rb +57 -0
  79. data/cookbooks/rvm/libraries/chef_rvm_string_cache.rb +104 -0
  80. data/cookbooks/rvm/libraries/chef_rvm_string_helpers.rb +61 -0
  81. data/cookbooks/rvm/libraries/chef_rvm_version_helpers.rb +45 -0
  82. data/cookbooks/rvm/libraries/gem_package_monkeypatch.rb +34 -0
  83. data/cookbooks/rvm/libraries/provider_rvm_installation.rb +185 -0
  84. data/cookbooks/rvm/libraries/resource_rvm_installation.rb +103 -0
  85. data/cookbooks/rvm/libraries/rvm_chef_user_environment.rb +55 -0
  86. data/cookbooks/rvm/libraries/rvm_rubygems_package.rb +189 -0
  87. data/cookbooks/rvm/libraries/rvm_shell_chef_wrapper.rb +99 -0
  88. data/cookbooks/rvm/metadata.json +51 -0
  89. data/cookbooks/rvm/providers/default_ruby.rb +63 -0
  90. data/cookbooks/rvm/providers/environment.rb +78 -0
  91. data/cookbooks/rvm/providers/gemset.rb +118 -0
  92. data/cookbooks/rvm/providers/global_gem.rb +97 -0
  93. data/cookbooks/rvm/providers/ruby.rb +178 -0
  94. data/cookbooks/rvm/providers/shell.rb +121 -0
  95. data/cookbooks/rvm/providers/wrapper.rb +73 -0
  96. data/cookbooks/rvm/recipes/.gitkeep +0 -0
  97. data/cookbooks/rvm/recipes/default.rb +40 -0
  98. data/cookbooks/rvm/recipes/gem_package.rb +33 -0
  99. data/cookbooks/rvm/recipes/system.rb +37 -0
  100. data/cookbooks/rvm/recipes/system_install.rb +42 -0
  101. data/cookbooks/rvm/recipes/user.rb +43 -0
  102. data/cookbooks/rvm/recipes/user_install.rb +58 -0
  103. data/cookbooks/rvm/recipes/vagrant.rb +37 -0
  104. data/cookbooks/rvm/resources/default_ruby.rb +31 -0
  105. data/cookbooks/rvm/resources/environment.rb +31 -0
  106. data/cookbooks/rvm/resources/gem.rb +37 -0
  107. data/cookbooks/rvm/resources/gemset.rb +32 -0
  108. data/cookbooks/rvm/resources/global_gem.rb +34 -0
  109. data/cookbooks/rvm/resources/ruby.rb +32 -0
  110. data/cookbooks/rvm/resources/shell.rb +41 -0
  111. data/cookbooks/rvm/resources/wrapper.rb +34 -0
  112. data/cookbooks/rvm/templates/default/rvmrc.erb +14 -0
  113. data/cookbooks/rvm/templates/default/vagrant-chef-client-wrapper.erb +23 -0
  114. data/cookbooks/rvm/templates/default/vagrant-chef-solo-wrapper.erb +23 -0
  115. data/cookbooks/rvm/test/integration/data_bags/users/virgil1.json +4 -0
  116. data/cookbooks/rvm/test/integration/data_bags/users/virgil2.json +4 -0
  117. data/cookbooks/rvm/test/integration/data_bags/users/wigglebottom.json +3 -0
  118. data/cookbooks/rvm/test/integration/installs/bats/version_pinning.bats +13 -0
  119. data/cookbooks/rvm/test/integration/rubies/bats/_common.bash +16 -0
  120. data/cookbooks/rvm/test/integration/rubies/bats/verify_1.9.3.bats +9 -0
  121. data/cookbooks/rvm/test/integration/rubies/bats/verify_jruby.bats +12 -0
  122. data/cookbooks/rvm/test/integration/rubies/bats/verify_patch_support.bats +19 -0
  123. data/cookbooks/rvm/test/integration/rubies/bats/verify_ree.bats +9 -0
  124. data/cookbooks/rvm/test/integration/rubies/bats/verify_rubygems_version_support.bats +15 -0
  125. data/cookbooks/rvm/test/integration/stock_system_and_user/bats/system.bats +45 -0
  126. data/cookbooks/rvm/test/unit/libraries/provider_rvm_installation_spec.rb +220 -0
  127. data/cookbooks/rvm/test/unit/libraries/resource_rvm_installation_spec.rb +139 -0
  128. data/cookbooks/rvm/test/unit/spec_helper.rb +23 -0
  129. data/cookbooks/scratchify/.chef/knife.rb +9 -0
  130. data/cookbooks/scratchify/Berksfile +16 -0
  131. data/cookbooks/scratchify/Berksfile.lock +19 -0
  132. data/cookbooks/scratchify/LICENSE.txt +21 -0
  133. data/cookbooks/scratchify/README.md +41 -0
  134. data/cookbooks/scratchify/Thorfile +5 -0
  135. data/cookbooks/scratchify/bin/console +14 -0
  136. data/cookbooks/scratchify/bin/scratchify +6 -0
  137. data/cookbooks/scratchify/bin/setup +7 -0
  138. data/cookbooks/scratchify/chefignore +101 -0
  139. data/cookbooks/scratchify/data_bags/users/deploy.json +6 -0
  140. data/cookbooks/scratchify/environments/.gitkeep +0 -0
  141. data/cookbooks/scratchify/from-scratch.gemspec +36 -0
  142. data/cookbooks/scratchify/lib/from/scratch.rb +31 -0
  143. data/cookbooks/scratchify/lib/from/scratch/interviewer.rb +35 -0
  144. data/cookbooks/scratchify/lib/from/scratch/version.rb +3 -0
  145. data/cookbooks/scratchify/metadata.json +36 -0
  146. data/cookbooks/scratchify/nodes/normfood.ru.json +75 -0
  147. data/cookbooks/scratchify/recipes/default.rb +0 -0
  148. data/cookbooks/scratchify/roles/.gitkeep +0 -0
  149. data/cookbooks/scratchify/spec/from/scratch_spec.rb +11 -0
  150. data/cookbooks/scratchify/spec/spec_helper.rb +2 -0
  151. data/cookbooks/user/.gitignore +5 -0
  152. data/cookbooks/user/.kitchen.yml +46 -0
  153. data/cookbooks/user/.travis.yml +4 -0
  154. data/cookbooks/user/Berksfile +7 -0
  155. data/cookbooks/user/CHANGELOG.md +101 -0
  156. data/cookbooks/user/Gemfile +14 -0
  157. data/cookbooks/user/README.md +447 -0
  158. data/cookbooks/user/Rakefile +21 -0
  159. data/cookbooks/user/attributes/default.rb +50 -0
  160. data/cookbooks/user/libraries/matchers.rb +26 -0
  161. data/cookbooks/user/metadata.json +46 -0
  162. data/cookbooks/user/providers/account.rb +212 -0
  163. data/cookbooks/user/recipes/data_bag.rb +59 -0
  164. data/cookbooks/user/recipes/default.rb +18 -0
  165. data/cookbooks/user/resources/account.rb +41 -0
  166. data/cookbooks/user/templates/default/authorized_keys.erb +7 -0
  167. data/from-scratch.gemspec +33 -0
  168. data/lib/from-scratch.rb +25 -0
  169. data/lib/from-scratch/version.rb +3 -0
  170. data/metadata.rb +15 -0
  171. data/recipes/default.rb +0 -0
  172. data/templates/node.json.erb +31 -0
  173. data/templates/user.json.erb +6 -0
  174. metadata +330 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5b496c570f495a440506371b464e4533fb5470bb
4
+ data.tar.gz: 33954a19f5906d5b5c8af4d27cc0f95793084488
5
+ SHA512:
6
+ metadata.gz: c7fdbec146ed46a5ddd7eb85ed9f6888400074903d09484959665a242331490704cf6a17d2e6b728b87de8e7876294b99a5e8a47cd0d7a6ba9a0bb637722a680
7
+ data.tar.gz: d390f3867386c55f06e2e4ad61c06acbe9c85c24529ac7125583b1fb2fb7b923fc673f6ef85ebd24fb5fd625cd634c18dfbf0c290ddd982647d5b70bd0afa2f4
@@ -0,0 +1,6 @@
1
+ cookbook_path "cookbooks"
2
+ node_path "tmp/nodes"
3
+ data_bag_path "tmp/data_bags"
4
+
5
+ knife[:berkshelf_path] = "cookbooks"
6
+ Chef::Config[:ssl_verify_mode] = :verify_peer if defined? ::Chef
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ #^syntax detection
3
+
4
+ source "https://supermarket.chef.io"
5
+
6
+ metadata
7
+
8
+ cookbook 'user'
9
+ cookbook 'rvm', github: 'fnichol/chef-rvm'
10
+ cookbook 'postgresql'
11
+
12
+ # cookbook 'dpkg_packages', git: "https://gitlab.acid.cl/acidlabs/chef-dpkg-packages.git"
13
+ # cookbook 'nginx', git: "https://gitlab.acid.cl/acidlabs/chef-nginx.git"
14
+ # cookbook 'postgresql', git: "https://github.com/phlipper/chef-postgresql.git"
15
+ # cookbook 'rvm'
16
+ # cookbook 'ssh-hardening'
17
+ # cookbook 'sudo'
@@ -0,0 +1,19 @@
1
+ DEPENDENCIES
2
+ rvm
3
+ git: git://github.com/fnichol/chef-rvm.git
4
+ revision: 08ec265f277e112a5a2e4b201bd32ddfe1bb968c
5
+ scratchify
6
+ path: .
7
+ metadata: true
8
+ user
9
+
10
+ GRAPH
11
+ chef_gem (0.1.0)
12
+ java (1.35.0)
13
+ rvm (0.10.1)
14
+ chef_gem (>= 0.0.0)
15
+ java (>= 0.0.0)
16
+ scratchify (0.1.0)
17
+ rvm (>= 0.0.0)
18
+ user (>= 0.0.0)
19
+ user (0.4.2)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in from-scratch.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Andrew Shaydurov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,58 @@
1
+ # FromScratch
2
+
3
+ I'm sick and tired of thousands of articles "How to setup Rails app server". Here is your last command to do that.
4
+
5
+ No configs, no questions. Just ~~one ring to rule them all~~ one command to get fully functional server with best security practices ready for first `cap production deploy`.
6
+
7
+ ## Usage
8
+
9
+ $ gem install from-scratch
10
+ $ scratchify your_app_name your.host.com
11
+
12
+ And everything is done. Then add following to your `config/deploy.rb` or `config/deploy/production.rb` for Capistrano:
13
+
14
+ ```ruby
15
+ server 'your.host.com', user: 'deploy', roles: %w(app db web)
16
+ set :deploy_to, "/home/deploy/your_app_name"
17
+ ```
18
+
19
+ ## Supports
20
+
21
+ OS:
22
+
23
+ - APT-based Linux (Ubuntu, Debian)
24
+ - YUM-based Linux (RedHat, CentOS)
25
+
26
+ ## It's a kind of magic!
27
+
28
+ Not actully. Just preconfigured [Chef](https://www.chef.io/). Here are the things done with the command:
29
+
30
+ - Install system-wide RVM with latest MRI (2.2.3)
31
+ - Install PostgreSQL, create database with user, pg_tune a little
32
+ - Add _deploy_ non-admin user to system specially for your app, upload your SSH pub key to it
33
+ - Install nginx and replace it's default site config with one prepared for rails app
34
+ - Generate app folder inside _deploy_'s home and generate `database.yml` and `secrets.yml`
35
+
36
+ ## Things you need to know
37
+
38
+ Nginx config is set up to connect to unix socket placed at `/home/deploy/your_app_name/shared/tmp/sockets/application.sock`. Change it manually or config your favorite app server (Puma, Unicorn, Thin etc) to place it's socket there.
39
+
40
+ You can just `ssh deploy@your.host.com` because your SSH pub key is already there.
41
+
42
+ Both `postgres` and `your_app_name` DB users get (different) randomly generated passwords. You can see app-user password inside `config/database.yml`, but `postgres` password is not saved anywhere. If you need admin access to your PostgreSQL, then you should SSH as root and:
43
+
44
+ # su - postgres
45
+ $ psql
46
+
47
+ ## Development
48
+
49
+ TODO
50
+
51
+ ## Contributing
52
+
53
+ TODO
54
+
55
+ ## License
56
+
57
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
58
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ require 'bundler'
4
+ require 'bundler/setup'
5
+ require 'berkshelf/thor'
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "from-scratch"
5
+
6
+ FromScratch.run!
@@ -0,0 +1,101 @@
1
+ # Put files/directories that should be ignored in this file when uploading
2
+ # or sharing to the community site.
3
+ # Lines that start with '# ' are comments.
4
+
5
+ # OS generated files #
6
+ ######################
7
+ .DS_Store
8
+ Icon?
9
+ nohup.out
10
+ ehthumbs.db
11
+ Thumbs.db
12
+
13
+ # SASS #
14
+ ########
15
+ .sass-cache
16
+
17
+ # EDITORS #
18
+ ###########
19
+ \#*
20
+ .#*
21
+ *~
22
+ *.sw[a-z]
23
+ *.bak
24
+ REVISION
25
+ TAGS*
26
+ tmtags
27
+ *_flymake.*
28
+ *_flymake
29
+ *.tmproj
30
+ .project
31
+ .settings
32
+ mkmf.log
33
+
34
+ ## COMPILED ##
35
+ ##############
36
+ a.out
37
+ *.o
38
+ *.pyc
39
+ *.so
40
+ *.com
41
+ *.class
42
+ *.dll
43
+ *.exe
44
+ */rdoc/
45
+
46
+ # Testing #
47
+ ###########
48
+ .watchr
49
+ .rspec
50
+ spec/*
51
+ spec/fixtures/*
52
+ test/*
53
+ features/*
54
+ Guardfile
55
+ Procfile
56
+
57
+ # SCM #
58
+ #######
59
+ .git
60
+ */.git
61
+ .gitignore
62
+ .gitmodules
63
+ .gitconfig
64
+ .gitattributes
65
+ .svn
66
+ */.bzr/*
67
+ */.hg/*
68
+ */.svn/*
69
+
70
+ # Berkshelf #
71
+ #############
72
+ cookbooks/*
73
+ tmp
74
+
75
+ # Cookbooks #
76
+ #############
77
+ CONTRIBUTING
78
+ CHANGELOG*
79
+
80
+ # Strainer #
81
+ ############
82
+ Colanderfile
83
+ Strainerfile
84
+ .colander
85
+ .strainer
86
+
87
+ # Vagrant #
88
+ ###########
89
+ .vagrant
90
+ Vagrantfile
91
+
92
+ # Travis #
93
+ ##########
94
+ .travis.yml
95
+
96
+ # Gem files #
97
+ Gemfile
98
+ Gemfile.lock
99
+ Rakefile
100
+ lib/*
101
+ bin/*
@@ -0,0 +1,24 @@
1
+ v0.1.0
2
+ ------
3
+ * Add name to metadata.rb (thanks [Eli Klein](https://github.com/eklein))
4
+
5
+ v0.0.5
6
+ ------
7
+ * Applies backport of CHEF-3164 to _all_ versions under 10.14.0 (thanks [cgriego](https://github.com/cgriego))
8
+
9
+ v0.0.4
10
+ ------
11
+ * Backports CHEF-3164 (thanks [cgriego](https://github.com/cgriego))
12
+
13
+ v0.0.3
14
+ ------
15
+ * Default node in overrides if it is unavailable
16
+
17
+ v0.0.2
18
+ ------
19
+ * Add omnibus fixes for installs < 0.10.12
20
+ * Add conditional patching based on chef version
21
+
22
+ v0.0.1
23
+ ------
24
+ * Initial release
@@ -0,0 +1,38 @@
1
+ ChefGem
2
+ =======
3
+
4
+ This cookbook is a transition cookbook aimed at helping move from the
5
+ pre-chef_gem era to the post chef_gem era. The chef_gem resource was
6
+ introducde in Chef 0.10.9, providing an easy mechanism for installing
7
+ and using gems required by Chef internally. When used within an omnibus
8
+ installation, chef_gems are installed within the embedded Ruby.
9
+
10
+ What this cookbook provides
11
+ ----------------------------
12
+
13
+ For pre 0.10.9 Chef installations, it provides a chef_gem compatible resouce
14
+ allowing cookbooks to be updated but not requiring full conversions. For installations
15
+ under 0.10.12, some patches are added to aid in proper omnibus functionality allowing
16
+ chef_gem to work as expected. For Chef installations of 0.10.12 and beyond, this
17
+ cookbook provides nothing. This means you will get consistent and expected behavior
18
+ across Chef versions.
19
+
20
+ Configuration
21
+ -------------
22
+
23
+ Notable attributes (note that these should only be required for special cases):
24
+
25
+ * `node[:gem_binary] = '/usr/local/bin/gem'`
26
+ * `node[:chef_gem_binary] = '/opt/opscode/embedded/bin/gem'`
27
+
28
+ Notes
29
+ -----
30
+
31
+ With the release of 0.10.12 this cookbook should be considered deprecated and used
32
+ only for compatibility with older installations.
33
+
34
+ Repository
35
+ ----------
36
+
37
+ * https://github.com/hw-cookbooks/chef_gem
38
+ * IRC: Freenode @ #heavywater
@@ -0,0 +1,72 @@
1
+ current_version = Gem::Version.new(Chef::VERSION)
2
+
3
+ if(current_version < Gem::Version.new('10.12.0'))
4
+
5
+ if(current_version < Gem::Version.new('0.10.9'))
6
+ Chef::Log.info '*** Adding ChefGem Resource ***'
7
+ else
8
+ Chef::Log.info '*** Adding fixes to ChefGem Resource ***'
9
+ end
10
+
11
+ require 'chef/resource/gem_package'
12
+
13
+ class Chef::Resource::GemPackage
14
+ def gem_binary(*args)
15
+ node ||= {}
16
+ node[:gem_binary] || 'gem'
17
+ end
18
+ end
19
+
20
+ class Chef::Resource::ChefGem < Chef::Resource::GemPackage
21
+
22
+ # provides :chef_gem, :on_platforms => :all
23
+
24
+ def initialize(name, run_context=nil)
25
+ super
26
+ @resource_name = :chef_gem
27
+ @provider = Chef::Provider::Package::Rubygems
28
+ after_created
29
+ end
30
+
31
+ def gem_binary(*args)
32
+ node ||= {}
33
+ node[:chef_gem_binary] || ::File.join(Gem.bindir, 'gem')
34
+ end
35
+
36
+ def after_created
37
+ Array(@action).flatten.compact.each do |action|
38
+ self.run_action(action)
39
+ end
40
+ Gem.clear_paths
41
+ end
42
+ end
43
+ end
44
+
45
+ if(Chef::VERSION.to_s.start_with?('0.10.10'))
46
+ Chef::Log.info '** Patching Chef::Provider::Package::Rubygems#is_omnibus? to properly find all omnibus installs **'
47
+ class Chef::Provider::Package::Rubygems
48
+ def is_omnibus?
49
+ if RbConfig::CONFIG['bindir'] =~ %r!/opt/(opscode|chef)/embedded/bin!
50
+ Chef::Log.debug("#{@new_resource} detected omnibus installation in #{RbConfig::CONFIG['bindir']}")
51
+ # Omnibus installs to a static path because of linking on unix, find it.
52
+ true
53
+ elsif RbConfig::CONFIG['bindir'].sub(/^[\w]:/, '') == "/opscode/chef/embedded/bin"
54
+ Chef::Log.debug("#{@new_resource} detected omnibus installation in #{RbConfig::CONFIG['bindir']}")
55
+ # windows, with the drive letter removed
56
+ true
57
+ else
58
+ false
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ if(current_version < Gem::Version.new('10.14.0'))
65
+ module Chef3164
66
+ def after_created(*)
67
+ Gem.clear_paths # NOTE: Related to CHEF-3164
68
+ super
69
+ end
70
+ end
71
+ Chef::Resource::ChefGem.send(:include, Chef3164)
72
+ end
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "chef_gem",
3
+ "description": "Provides proper chef_gem resource support for Chef versions < 0.10.12",
4
+ "long_description": "ChefGem\n=======\n\nThis cookbook is a transition cookbook aimed at helping move from the\npre-chef_gem era to the post chef_gem era. The chef_gem resource was\nintroducde in Chef 0.10.9, providing an easy mechanism for installing\nand using gems required by Chef internally. When used within an omnibus\ninstallation, chef_gems are installed within the embedded Ruby.\n\nWhat this cookbook provides\n----------------------------\n\nFor pre 0.10.9 Chef installations, it provides a chef_gem compatible resouce\nallowing cookbooks to be updated but not requiring full conversions. For installations\nunder 0.10.12, some patches are added to aid in proper omnibus functionality allowing\nchef_gem to work as expected. For Chef installations of 0.10.12 and beyond, this\ncookbook provides nothing. This means you will get consistent and expected behavior\nacross Chef versions.\n\nConfiguration\n-------------\n\nNotable attributes (note that these should only be required for special cases):\n\n* `node[:gem_binary] = '/usr/local/bin/gem'`\n* `node[:chef_gem_binary] = '/opt/opscode/embedded/bin/gem'`\n\nNotes\n-----\n\nWith the release of 0.10.12 this cookbook should be considered deprecated and used\nonly for compatibility with older installations.\n\nRepository\n----------\n\n* https://github.com/hw-cookbooks/chef_gem\n* IRC: Freenode @ #heavywater",
5
+ "maintainer": "Chris Roberts",
6
+ "maintainer_email": "chrisroberts.code@gmail.com",
7
+ "license": "Apache 2.0",
8
+ "platforms": {
9
+ },
10
+ "dependencies": {
11
+ },
12
+ "recommendations": {
13
+ },
14
+ "suggestions": {
15
+ },
16
+ "conflicting": {
17
+ },
18
+ "providing": {
19
+ },
20
+ "replacing": {
21
+ },
22
+ "attributes": {
23
+ },
24
+ "groupings": {
25
+ },
26
+ "recipes": {
27
+ },
28
+ "version": "0.1.0"
29
+ }