chef_instance 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7afd8dd840314bbff2c9d6dd53d9cf4d92ec8a01
4
+ data.tar.gz: 9e35d4d45f34dae440528872aabf49a77bf5bc10
5
+ SHA512:
6
+ metadata.gz: 318941d2427b7659b10a6e86d17ce4ca1cf7fb0de4e43f200cf53f3e60dfff0ffcf34c7036c412f6b398cb86e288a13765ad288c5caf4ed589916649e03f584e
7
+ data.tar.gz: 1e3bda52054a264a8f8e4136e23fba8c18c2cbdebc1fc6f4a34fbdeab5c4ba7a11e133d1ed649fb1491bc4d9ec46c3233c384df384640a66cfbf55cc1679faeb
Binary file
Binary file
@@ -0,0 +1,9 @@
1
+ .bundle
2
+ .gems
3
+ .idea
4
+ .inch
5
+ .yardoc
6
+ *.lock
7
+ coverage
8
+ doc
9
+ chef_instance-*.gem
@@ -0,0 +1,26 @@
1
+ ---
2
+ driver_plugin: vagrant
3
+
4
+ platforms:
5
+ - name: ubuntu-12.04
6
+ driver_config:
7
+ box: canonical-ubuntu-12.04
8
+ box_url: http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box
9
+ require_chef_omnibus: true
10
+ - name: ubuntu-10.04
11
+ driver_config:
12
+ box: opscode-ubuntu-10.04
13
+ box_url: http://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-10.04_chef-11.2.0.box
14
+ - name: centos-6.3
15
+ driver_config:
16
+ box: opscode-centos-6.3
17
+ box_url: http://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.3_chef-11.2.0.box
18
+ - name: centos-5.8
19
+ driver_config:
20
+ box: opscode-centos-5.8
21
+ box_url: http://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-5.8_chef-11.2.0.box
22
+
23
+ suites:
24
+ - name: default
25
+ run_list: []
26
+ attributes: {}
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ cache:
3
+ - bundler
4
+ - apt
5
+ rvm:
6
+ - 2.1.0
7
+ gemfile: Gemfile
8
+ script: bundle exec rake test:minitest
9
+ env:
10
+ global:
11
+ secure: cxyirL1d4jaHouHKZCNtu1OH/3GhM5yO86SQJfkudznua68sYrRTT92lv1eTfYo0rfzXuHvIFwn7o/RGraMlSgjz8muaxMyAZuyuc02o4f6JHG25JHD3ZNcsM+sWeUX+sU1fdrvjAW1VKqGY5gr88vhLY8i7W/B5kStE/+Jt4rc=
@@ -0,0 +1,6 @@
1
+ --readme README.md
2
+ --charset utf-8
3
+ --markup markdown
4
+ lib/**/*.rb
5
+ -
6
+ LICENSE
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2013 Miah Johnson
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,91 @@
1
+ # chef_instance
2
+
3
+ ## Why
4
+
5
+ What is our goal when we install a piece of daemonized software? Why does the
6
+ minutia of configuration concern us so greatly? Do we really want to emulate
7
+ shell scripts in a recipe and end up with hundreds of random resources on our node?
8
+ Why do I even care about resources on my node?
9
+
10
+ Before I answer those questions lets get back to our goal, which was?
11
+
12
+ Goal: A unique instance of a daemon with our supplied configuration.
13
+
14
+ ## Usage
15
+
16
+ ```
17
+ # In this hypothetical instance we have a 'pie' daemon named 'pumpkin' that stores
18
+ # pies recieved on port 314. We may want to run another instance called 'pecan' on
19
+ # a different port that receives different types of pies.
20
+ # htce::default.rb
21
+ pie_instance 'pumpkin' do
22
+ # File owner and group.
23
+ # Daemon user and group.
24
+ user 'pumpkin'
25
+ group 'pies'
26
+ # creates `/opt/pies/pumpkins` then stores all config and runtime data.
27
+ root_path '/opt/pies'
28
+ service_options({
29
+ port: 314,
30
+ store_pies: true,
31
+ daemon_args: %w(-Tsteaming -Sdelicious)
32
+ })
33
+ end
34
+ ```
35
+
36
+ ## How it works
37
+
38
+ Provides resource provider super classes for building instances of software.
39
+
40
+ ```
41
+ class Chef
42
+ class Resource
43
+ class Daemon < Chef::Resource::Instance
44
+ end
45
+ end
46
+ end
47
+ ```
48
+
49
+ Ignores system defaults (configuration, initscripts, etc).
50
+
51
+ ## Installation
52
+
53
+ Because of Ruby library load race conditions with Chef and Gems you need to ensure that `chef_instance` is
54
+ installed before you execute Chef.
55
+
56
+ This can be achieved by:
57
+
58
+ - Install the Chef (through the Omnibus, or however you do it).
59
+ - Install `chef_instance` into the Ruby system used by Chef. If you used Omnibus you'll need to use the `gem`
60
+ command provided in `/opt/chef/embedded/bin`
61
+
62
+ ## Code Style
63
+
64
+ This code follows the [Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide) and all contributions should as well.
65
+
66
+ The code style is checked by [Rubocop](http://batsov.com/rubocop/) and can be checked by executing `rake test:rubocop` or `rubocop`.
67
+
68
+ [![Build Status](https://travis-ci.org/miah/chef_instance.png?branch=master)](https://travis-ci.org/miah/chef_instance)
69
+ [![Code Climate](https://codeclimate.com/github/miah/chef_instance.png)](https://codeclimate.com/github/miah/chef_instance)
70
+ [![Code Climate Coverage](https://codeclimate.com/github/miah/chef_instance/coverage.png)](https://codeclimate.com/github/miah/chef_instance)
71
+ [![Dependency Status](https://gemnasium.com/miah/chef_instance.svg)](https://gemnasium.com/miah/chef_instance)
72
+
73
+ # Author
74
+
75
+ Author:: Miah Johnson (<miah@chia-pet.org>)
76
+
77
+ # License
78
+
79
+ Copyright 2013 Miah Johnson
80
+
81
+ Licensed under the Apache License, Version 2.0 (the "License");
82
+ you may not use this file except in compliance with the License.
83
+ You may obtain a copy of the License at
84
+
85
+ http://www.apache.org/licenses/LICENSE-2.0
86
+
87
+ Unless required by applicable law or agreed to in writing, software
88
+ distributed under the License is distributed on an "AS IS" BASIS,
89
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
90
+ See the License for the specific language governing permissions and
91
+ limitations under the License.
@@ -0,0 +1,19 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rubocop/rake_task'
4
+ task :default => 'test:quick'
5
+
6
+ namespace :test do
7
+ Rubocop::RakeTask.new
8
+
9
+ Rake::TestTask.new do |t|
10
+ t.name = :minitest
11
+ t.test_files = Dir.glob('test/spec/**/*_spec.rb')
12
+ end
13
+
14
+ desc 'Run all of the quick tests.'
15
+ task :quick do
16
+ Rake::Task['test:minitest'].invoke
17
+ Rake::Task['test:rubocop'].invoke
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDbDCCAlSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQ0wCwYDVQQDDARtaWFo
3
+ MRgwFgYKCZImiZPyLGQBGRYIY2hpYS1wZXQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
4
+ HhcNMTQwODA4MjM1OTA1WhcNMTUwODA4MjM1OTA1WjA+MQ0wCwYDVQQDDARtaWFo
5
+ MRgwFgYKCZImiZPyLGQBGRYIY2hpYS1wZXQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
6
+ ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDeeUAfEXaV/W0FlwfZtSPU
7
+ i7+ED6EzPPxPKbhOd4bvP/9OF9iVpK4KLBdSbUL0d4TQ4yxSe6+5ZDmqYxolsA0H
8
+ VWokWnSXxW3vuLKOMp57JDc6hSkymPZD0vsmUh7UsERaicgdt9FQYYAM2gTyQvDR
9
+ S/ZanDvZIrU+l1HXx3O+txYid8W8bCxDRWHUbJ8meDHHrHn8hmB6m39LXMJy1k3Y
10
+ fccDTNI7Ni7otY682ti8yuBJF4Xw9ojwhzXnH7l/E75AlCX/ggFXK3l6CppwDfys
11
+ KP8pPFAlVnuMThYaRvmnOI9IiF5qEsI7c4goZy+LrpZFdz2zlX6BN54MuFcpG/MD
12
+ AgMBAAGjdTBzMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBRN/hw/
13
+ 8vKHvJiYOxM1uRZ3eAfihjAcBgNVHREEFTATgRFtaWFoQGNoaWEtcGV0Lm9yZzAc
14
+ BgNVHRIEFTATgRFtaWFoQGNoaWEtcGV0Lm9yZzANBgkqhkiG9w0BAQUFAAOCAQEA
15
+ S/lmW6szMp0gb3rKtAM9j4XS0aHUCmEDiPFlkjvsKxj5aIU81rvePaJyxoulID4H
16
+ mnW4BuxKC1YaBo0R3CL7izJ9Jrw09L6NTOLiTXdLNctNLZbVc4APywspvNlijtGa
17
+ kDHXTC6ftbxcU6SGjVw70yirtFhJGj2nmA69k7vj0/XiMbj6wcg1degf4ln0+B7O
18
+ IN8npbJjudV+Gok+TaIBJF+mxUIWw0Q3X+ZbM5vku5GU41Fdyc5d8zJ38CwOGTbf
19
+ HceOUVz35kgamNj0WW4lNAHyZi7cS0MeI/0B/AGUkaG7gWvyGBAgr1gJ2+4kMmcY
20
+ vg9xNKI52TEvhr97dNRNTQ==
21
+ -----END CERTIFICATE-----
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ require_relative 'lib/chef_instance/version'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'chef_instance'
6
+ spec.version = ChefInstance::VERSION
7
+ spec.authors = ['Miah Johnson']
8
+ spec.email = %w(miah@chia-pet.org)
9
+ spec.description = IO.read(File.join(File.dirname(__FILE__), 'README.md'))
10
+ spec.summary = 'Chef Resource & Provider Super Classes for' \
11
+ 'building stand-alone instances of software.'
12
+ spec.homepage = 'https://gitlab.com/viscera/chef_instance'
13
+ spec.license = 'Apache-2.0'
14
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
15
+ spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(/^(test|spec|features)/)
17
+ spec.require_paths = %w(lib)
18
+ spec.cert_chain = ['certs/miah_johnson.pem']
19
+ spec.signing_key = '/Users/miah/.gem_certs/gem-private_key.pem'
20
+
21
+ spec.add_runtime_dependency 'chef', '>= 11.12.2'
22
+ spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.3.0'
23
+ spec.add_development_dependency 'minitest', '~> 5.3.1'
24
+ spec.add_development_dependency 'rake', '~> 10.3.0'
25
+ spec.add_development_dependency 'rubocop', '~> 0.20.1'
26
+ spec.add_development_dependency 'simplecov', '~> 0.8.2'
27
+ spec.add_development_dependency 'yard', '~> 0.8.7.3'
28
+ end
@@ -0,0 +1,30 @@
1
+ module ChefInstance
2
+ module Install
3
+ # A Superclass template for installing software.
4
+ class Template
5
+ # Construct a new ChefInstance::Install::Template.
6
+ # @param new_resource [Chef::Resource]
7
+ # @param run_context [Chef::RunContext]
8
+ def initialize(new_resource, run_context = nil)
9
+ @new_resource = new_resource
10
+ @run_context = run_context
11
+ end
12
+
13
+ def install
14
+ fail NotImplementedError,
15
+ 'You must override the install method in your sub-class.'
16
+ end
17
+
18
+ def uninstall
19
+ fail NotImplementedError,
20
+ 'You must override the uninstall method in your sub-class.'
21
+ end
22
+
23
+ private
24
+
25
+ def options
26
+ @options ||= @new_resource.install_options
27
+ end
28
+ end
29
+ end
30
+ end