vagrant-puppet-install 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ bin/
19
+ .vagrant/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --default_path test/unit
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ script: rake test:unit
@@ -0,0 +1,7 @@
1
+ --markup=markdown
2
+ --markup-provider=redcarpet
3
+ --readme=README.md
4
+ -
5
+ CHANGELOG.md
6
+ LICENSE
7
+ TODO.md
@@ -0,0 +1,3 @@
1
+ ## 1.0.0 (unreleased)
2
+
3
+ * The initial release.
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ # We depend on Vagrant for development, but we don't add it as a
7
+ # gem dependency because we expect to be installed within the
8
+ # Vagrant environment itself using `vagrant plugin`.
9
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => "v1.2.1"
10
+ end
11
+
12
+ group :test do
13
+ gem "vagrant-aws", "~> 0.2.2"
14
+ gem "vagrant-rackspace", "~> 0.1.1"
15
+ end
16
+
17
+ group :docs do
18
+ gem "yard", "~> 0.8.5"
19
+ gem "redcarpet", "~> 2.2.2"
20
+ gem "github-markup", "~> 0.7.5"
21
+ end
data/LICENSE ADDED
@@ -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,104 @@
1
+ # vagrant-puppet-install
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/vagrant-omnibus.png)](https://badge.fury.io/rb/vagrant-omnibus.png)
4
+ [![Build Status](https://travis-ci.org/schisamo/vagrant-omnibus.png?branch=master)](https://travis-ci.org/schisamo/vagrant-omnibus)
5
+ [![Dependency Status](https://gemnasium.com/schisamo/vagrant-omnibus.png)](https://gemnasium.com/schisamo/vagrant-omnibus)
6
+ [![Code Climate](https://codeclimate.com/github/schisamo/vagrant-omnibus.png)](https://codeclimate.com/github/schisamo/vagrant-omnibus)
7
+
8
+ A Vagrant plugin that ensures the desired version of Puppet is installed via the
9
+ Puppet Labs package repo. This proves very useful when using Vagrant
10
+ with provisioner-less baseboxes OR cloud images.
11
+
12
+ This plugin has been verified to work with the following
13
+ [Vagrant providers](http://docs.vagrantup.com/v2/providers/index.html):
14
+
15
+ * VirtualBox (part of core)
16
+ * AWS (ships in [vagrant-aws](https://github.com/mitchellh/vagrant-aws) plugin)
17
+ * Rackspace (ships in [vagrant-rackspace](https://github.com/mitchellh/vagrant-rackspace)
18
+ plugin)
19
+
20
+ It may work with other Vagrant providers but is not guaranteed to!
21
+
22
+ ## Installation
23
+
24
+ Ensure you have downloaded and installed Vagrant 1.1.x from the
25
+ [Vagrant downloads page](http://downloads.vagrantup.com/).
26
+
27
+ Installation is performed in the prescribed manner for Vagrant 1.1 plugins.
28
+
29
+ ```
30
+ $ vagrant plugin install vagrant-puppet-install
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ The Puppet Install Vagrant plugin automatically hooks into the Vagrant provisioning
36
+ middleware. You specify the version of the `puppet-common` package you want
37
+ installed using the `puppet_install.version` config key. The version string
38
+ should be a valid Puppet release (ie. `2.7.11`, `3.0.*`, etc.).
39
+
40
+ Install the latest version of Puppet:
41
+
42
+ ```ruby
43
+ Vagrant.configure("2") do |config|
44
+
45
+ config.puppet_install.version = "*"
46
+
47
+ ...
48
+
49
+ end
50
+ ```
51
+
52
+ Install a specific version of Puppet:
53
+
54
+ ```ruby
55
+ Vagrant.configure("2") do |config|
56
+
57
+ config.puppet_install.version = "2.7.11"
58
+
59
+ ...
60
+
61
+ end
62
+ ```
63
+
64
+ ## Tests
65
+
66
+ ### Unit
67
+
68
+ The unit tests can be run with:
69
+
70
+ ```
71
+ rake test:unit
72
+ ```
73
+
74
+ The test are also executed by Travis CI every time code is pushed to GitHub.
75
+
76
+ ### Acceptance
77
+
78
+ Currently this repo ships with a set of basic acceptance tests that will:
79
+
80
+ * Provision a Vagrant instance.
81
+ * Attempt to install Chef 11.4.0 using this plugin.
82
+ * Perform a very basic chef-solo run to ensure Chef is in fact installed.
83
+
84
+ The acceptance tests are run against the Vagrant providers mentioned above. The
85
+ acceptance tests can be run with:
86
+
87
+ ```
88
+ rake test:acceptance
89
+ ```
90
+
91
+ And as expected, all acceptance tests only uses provisioner-less baseboxes and
92
+ cloud images!
93
+
94
+ ## Contributing
95
+
96
+ 1. Fork it
97
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
98
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
99
+ 4. Push to the branch (`git push origin my-new-feature`)
100
+ 5. Create new Pull Request
101
+
102
+ ## Authors
103
+
104
+ Seth Chisamore (schisamo@opscode.com)
@@ -0,0 +1,46 @@
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+ require 'yard'
5
+
6
+ YARD::Rake::YardocTask.new
7
+
8
+ namespace :test do
9
+
10
+ RSpec::Core::RakeTask.new(:unit) do |t|
11
+ t.pattern = "test/unit/**/*_spec.rb"
12
+ end
13
+
14
+ desc "Run acceptance tests..these actually launch Vagrant sessions."
15
+ task :acceptance, :provider do |t, args|
16
+
17
+ # ensure all required dummy boxen are installed
18
+ %w{ aws rackspace }.each do |provider|
19
+ unless system("vagrant box list | grep 'dummy\s*(#{provider})' &>/dev/null")
20
+ system("vagrant box add dummy https://github.com/mitchellh/vagrant-#{provider}/raw/master/dummy.box")
21
+ end
22
+ end
23
+
24
+ all_providers = Dir["test/acceptance/*"].map{|dir| File.basename(File.expand_path(dir))}
25
+
26
+ # If a provider wasn't passed to the task run acceptance tests against
27
+ # ALL THE PROVIDERS!
28
+ providers = if args[:provider] && all_providers.include?(args[:provider])
29
+ [args[:provider]]
30
+ else
31
+ all_providers
32
+ end
33
+
34
+ providers.each do |provider|
35
+ puts "=================================================================="
36
+ puts "Running acceptance tests against '#{provider}' provider..."
37
+ puts "=================================================================="
38
+
39
+ Dir.chdir("test/acceptance/#{provider}") do
40
+ system("vagrant destroy -f")
41
+ system("vagrant up --provider=#{provider}")
42
+ system("vagrant destroy -f")
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,25 @@
1
+ #
2
+ # Copyright (c) 2013, Seth Chisamore
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require "pathname"
18
+ require "vagrant-puppet-install/plugin"
19
+
20
+ module VagrantPlugins
21
+ module PuppetInstall
22
+ autoload :Action, 'vagrant-puppet-install/action'
23
+ autoload :Config, 'vagrant-puppet-install/config'
24
+ end
25
+ end
@@ -0,0 +1,45 @@
1
+ #
2
+ # Copyright (c) 2013, Seth Chisamore
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require "vagrant/action/builder"
18
+
19
+ module VagrantPlugins
20
+ module PuppetInstall
21
+ module Action
22
+ autoload :InstallPuppet, File.expand_path("../action/install_puppet", __FILE__)
23
+ autoload :IsRunningOrActive, File.expand_path("../action/is_running_or_active", __FILE__)
24
+ autoload :ReadPuppetVersion, File.expand_path("../action/read_puppet_version", __FILE__)
25
+
26
+ # Include the built-in modules so that we can use them as top-level
27
+ # things.
28
+ include Vagrant::Action::Builtin
29
+
30
+ # @return [::Vagrant::Action::Builder]
31
+ def self.install_puppet
32
+ @install_puppet ||= ::Vagrant::Action::Builder.new.tap do |b|
33
+ b.use ConfigValidate
34
+ b.use Call, IsRunningOrActive do |env1, b2|
35
+ if env1[:result]
36
+ b2.use ReadPuppetVersion
37
+ b2.use InstallPuppet
38
+ b2.use SSHRun
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,72 @@
1
+ #
2
+ # Copyright (c) 2013, Seth Chisamore
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module VagrantPlugins
18
+ module PuppetInstall
19
+ module Action
20
+ # @author Seth Chisamore <schisamo@opscode.com>
21
+ #
22
+ # This action installs Puppet packages at the desired version.
23
+ class InstallPuppet
24
+
25
+ ubuntu_codename = %x[lsb_release --codename | awk '{ print $2 }'].chomp
26
+ APT_PACKAGE_FILE = "puppetlabs-release-lucid.deb"
27
+ APT_PACKAGE_FILE_URL = "http://apt.puppetlabs.com/#{APT_PACKAGE_FILE}".freeze
28
+
29
+ def initialize(app, env)
30
+ @app = app
31
+ # Config#finalize! SHOULD be called automatically
32
+ env[:global_config].puppet_install.finalize!
33
+ end
34
+
35
+ def call(env)
36
+ desired_puppet_version = env[:global_config].puppet_install.version
37
+
38
+ unless desired_puppet_version.nil?
39
+ env[:ui].info("Ensuring Puppet is installed at requested version of #{desired_puppet_version}.")
40
+ if env[:installed_puppet_version] == desired_puppet_version
41
+ env[:ui].info("Puppet #{desired_puppet_version} package is already installed...skipping installation.")
42
+ else
43
+ env[:ui].info("Puppet #{desired_puppet_version} package is not installed...installing now.")
44
+ env[:ssh_run_command] = install_puppet_command(desired_puppet_version)
45
+ end
46
+ end
47
+
48
+ @app.call(env)
49
+ end
50
+
51
+ private
52
+
53
+ def install_puppet_command(version='*')
54
+ <<-INSTALL_PUPPET
55
+ cd /tmp
56
+ if command -v wget &>/dev/null; then
57
+ wget --quiet #{APT_PACKAGE_FILE_URL}
58
+ elif command -v curl &>/dev/null; then
59
+ curl --location --remote-name #{APT_PACKAGE_FILE_URL}
60
+ else
61
+ echo "Neither wget nor curl found. Please install one and try again." >&2
62
+ exit 1
63
+ fi
64
+ sudo dpkg --install #{APT_PACKAGE_FILE}
65
+ sudo apt-get update --quiet
66
+ sudo apt-get install puppet-common=#{version}*
67
+ INSTALL_PUPPET
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,47 @@
1
+ #
2
+ # Copyright (c) 2013, Seth Chisamore
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module VagrantPlugins
18
+ module PuppetInstall
19
+ module Action
20
+ # @author Seth Chisamore <schisamo@opscode.com>
21
+ #
22
+ # This action checks if the machine is running (virtualbox) or active
23
+ # (aws, rackspace).
24
+ #
25
+ class IsRunningOrActive
26
+ def initialize(app, env)
27
+ @app = app
28
+ end
29
+
30
+ def call(env)
31
+ # Set the result to be true if the machine is :running or :active.
32
+ if (env[:machine].state.id == :running) ||
33
+ (env[:machine].state.id == :active)
34
+
35
+ env[:result] = true
36
+ else
37
+ env[:result] = false
38
+ end
39
+
40
+ # Call the next if we have one (but we shouldn't, since this
41
+ # middleware is built to run with the Call-type middlewares)
42
+ @app.call(env)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,53 @@
1
+ #
2
+ # Copyright (c) 2013, Seth Chisamore
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module VagrantPlugins
18
+ module PuppetInstall
19
+ module Action
20
+ # @author Seth Chisamore <schisamo@opscode.com>
21
+ #
22
+ # This action will extract the installed version of Puppet installed on the
23
+ # guest. The resulting version will exist in the `:installed_puppet_version`
24
+ # key in the environment.
25
+ class ReadPuppetVersion
26
+ def initialize(app, env)
27
+ @app = app
28
+ end
29
+
30
+ def call(env)
31
+ env[:installed_puppet_version] = nil
32
+ env[:machine].communicate.tap do |comm|
33
+ # Execute it with sudo
34
+ comm.sudo(puppet_version_command) do |type, data|
35
+ if [:stderr, :stdout].include?(type)
36
+ env[:installed_puppet_version] = data.chomp
37
+ end
38
+ end
39
+ end
40
+ @app.call(env)
41
+ end
42
+
43
+ private
44
+
45
+ def puppet_version_command
46
+ <<-PUPPET_VERSION
47
+ echo $(puppet --version || "")
48
+ PUPPET_VERSION
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,97 @@
1
+ #
2
+ # Copyright (c) 2013, Seth Chisamore
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'rubygems/dependency'
18
+ require 'rubygems/dependency_installer'
19
+ require 'vagrant'
20
+
21
+ module VagrantPlugins
22
+ module PuppetInstall
23
+ # @author Seth Chisamore <schisamo@opscode.com>
24
+ class Config < Vagrant.plugin("2", :config)
25
+
26
+ # @return [String]
27
+ # The version of Chef to install.
28
+ attr_accessor :version
29
+
30
+ def initialize
31
+ @version = UNSET_VALUE
32
+ end
33
+
34
+ def finalize!
35
+ if @version == UNSET_VALUE
36
+ @version = nil
37
+ elsif @version.to_s == 'latest'
38
+ # resolve `latest` to a real version
39
+ @version = retrieve_latest_puppet_version
40
+ end
41
+ end
42
+
43
+ def validate(machine)
44
+ errors = []
45
+
46
+ unless valid_chef_version?(chef_version)
47
+ msg = "'#{chef_version}' is not a valid version of Chef."
48
+ msg << "\n\n A list of valid versions can be found at: http://www.opscode.com/chef/install/"
49
+ errors << msg
50
+ end
51
+
52
+ { "Omnibus Plugin" => errors }
53
+ end
54
+
55
+ private
56
+
57
+ # Query RubyGems.org's Ruby API and retrive the latest version of Chef.
58
+ def retrieve_latest_chef_version
59
+ available_gems = dependency_installer.find_gems_with_sources(chef_gem_dependency)
60
+ spec, source = if available_gems.respond_to?(:last)
61
+ # DependencyInstaller sorts the results such that the last one is
62
+ # always the one it considers best.
63
+ spec_with_source = available_gems.last
64
+ spec_with_source
65
+ else
66
+ # Rubygems 2.0 returns a Gem::Available set, which is a
67
+ # collection of AvailableSet::Tuple structs
68
+ available_gems.pick_best!
69
+ best_gem = available_gems.set.first
70
+ best_gem && [best_gem.spec, best_gem.source]
71
+ end
72
+
73
+ spec && spec.version.to_s
74
+ end
75
+
76
+ # Query RubyGems.org's Ruby API to see if the user-provided Chef version
77
+ # is in fact a real Chef version!
78
+ def valid_chef_version?(version)
79
+ is_valid = false
80
+ begin
81
+ available = dependency_installer.find_gems_with_sources(chef_gem_dependency(version))
82
+ is_valid = true unless available.empty?
83
+ rescue
84
+ end
85
+ is_valid
86
+ end
87
+
88
+ def dependency_installer
89
+ @dependency_installer ||= Gem::DependencyInstaller.new
90
+ end
91
+
92
+ def chef_gem_dependency(version=nil)
93
+ Gem::Dependency.new('chef', version)
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,76 @@
1
+ #
2
+ # Copyright (c) 2013, Seth Chisamore
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ begin
18
+ require "vagrant"
19
+ rescue LoadError
20
+ raise "The vagrant-puppet-install plugin must be run within Vagrant."
21
+ end
22
+
23
+ # This is a sanity check to make sure no one is attempting to install
24
+ # this into an early Vagrant version.
25
+ if Vagrant::VERSION < "1.1.0"
26
+ raise "The vagrant-puppet-install plugin is only compatible with Vagrant 1.1+"
27
+ end
28
+
29
+ module VagrantPlugins
30
+ module PuppetInstall
31
+ # @author Seth Chisamore <schisamo@opscode.com>
32
+ class Plugin < Vagrant.plugin("2")
33
+ name "Puppet Install"
34
+ description <<-DESC
35
+ This plugin ensures the desired version of Puppet is installed
36
+ via the Puppet Labs package repos.
37
+ DESC
38
+
39
+ def self.provision(hook)
40
+
41
+ hook.after(Vagrant::Action::Builtin::Provision, Action.install_puppet)
42
+
43
+ # BEGIN workaround
44
+ #
45
+ # Currently hooks attached to {Vagrant::Action::Builtin::Provision} are
46
+ # not wired into the middleware return path. My current workaround is to
47
+ # fire after anything boot related which wedges in right before the
48
+ # actual real run of the provisioner.
49
+
50
+ hook.after(VagrantPlugins::ProviderVirtualBox::Action::Boot, Action.install_puppet)
51
+
52
+ if VagrantPlugins.const_defined?("AWS")
53
+ hook.after(VagrantPlugins::AWS::Action::RunInstance, Action.install_puppet)
54
+ end
55
+
56
+ if VagrantPlugins.const_defined?("Rackspace")
57
+ # The `VagrantPlugins::Rackspace` module is missing the autoload for
58
+ # `VagrantPlugins::Rackspace::Action` so we need to ensure it is
59
+ # loaded before accessing the module in the after hook below.
60
+ require 'vagrant-rackspace/action'
61
+ hook.after(VagrantPlugins::Rackspace::Action::CreateServer, Action.install_puppet)
62
+ end
63
+
64
+ # END workaround
65
+ end
66
+
67
+ action_hook(:install_puppet, :machine_action_up, &method(:provision))
68
+ action_hook(:install_puppet, :machine_action_provision, &method(:provision))
69
+
70
+ config(:puppet_install) do
71
+ require_relative "config"
72
+ Config
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,21 @@
1
+ #
2
+ # Copyright (c) 2013, Seth Chisamore
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module VagrantPlugins
18
+ module PuppetInstall
19
+ VERSION = "1.0.0"
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # plugins don't seem to be auto-loaded from the bundle
5
+ require 'vagrant-omnibus'
6
+ require 'vagrant-aws'
7
+
8
+ Vagrant.configure("2") do |config|
9
+ config.omnibus.chef_version = '11.4.0'
10
+
11
+ config.vm.box = "dummy"
12
+ config.vm.provider :aws do |aws, override|
13
+ aws.access_key_id = ENV['DEV_AWS_ACCESS_KEY_ID']
14
+ aws.secret_access_key = ENV['DEV_AWS_SECRET_ACCESS_KEY']
15
+ aws.keypair_name = ENV['USER']
16
+
17
+ aws.instance_type = "m1.large"
18
+ aws.ami = "ami-2efa9d47" # Ubuntu 12.04 LTS 64-bit instance root store
19
+ aws.ssh_username = "ubuntu"
20
+
21
+ override.ssh.username = "ubuntu"
22
+ override.ssh.private_key_path = "~/.ssh/id_rsa"
23
+ end
24
+
25
+ config.vm.provision :chef_solo do |chef|
26
+ chef.cookbooks_path = File.expand_path("../../../support/cookbooks", __FILE__)
27
+ chef.add_recipe "chef-inator"
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # plugins don't seem to be auto-loaded from the bundle
5
+ require 'vagrant-omnibus'
6
+ require 'vagrant-rackspace'
7
+
8
+ Vagrant.configure("2") do |config|
9
+ config.omnibus.chef_version = '11.4.0'
10
+
11
+ config.vm.box = "dummy"
12
+ config.vm.provider :rackspace do |rackspace|
13
+ rackspace.username = ENV['DEV_RACKSPACE_USERNAME']
14
+ rackspace.api_key = ENV['DEV_RACKSPACE_API_KEY']
15
+ rackspace.flavor = /512MB/
16
+ rackspace.image = /Ubuntu 12.04/
17
+ rackspace.public_key_path = "~/.ssh/id_rsa.pub"
18
+ # TODO - switch this to the `override.ssh.private_key_path` syntax once
19
+ # `vagrant-rackspace` is updated.
20
+ config.ssh.private_key_path = "~/.ssh/id_rsa"
21
+ end
22
+
23
+ config.vm.provision :chef_solo do |chef|
24
+ chef.cookbooks_path = File.expand_path("../../../support/cookbooks", __FILE__)
25
+ chef.add_recipe "chef-inator"
26
+ end
27
+ end
@@ -0,0 +1,17 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # plugins don't seem to be auto-loaded from the bundle
5
+ require 'vagrant-omnibus'
6
+
7
+ Vagrant.configure("2") do |config|
8
+ config.omnibus.chef_version = :latest
9
+
10
+ config.vm.box = "canonical-ubuntu-12.04"
11
+ config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box"
12
+
13
+ config.vm.provision :chef_solo do |chef|
14
+ chef.cookbooks_path = File.expand_path("../../../support/cookbooks", __FILE__)
15
+ chef.add_recipe "chef-inator"
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ # super-tester cookbook
2
+
3
+ # Requirements
4
+
5
+ # Usage
6
+
7
+ # Attributes
8
+
9
+ # Recipes
10
+
11
+ # Author
12
+
13
+ Author:: YOUR_NAME (<YOUR_EMAIL>)
@@ -0,0 +1,7 @@
1
+ name "chef-inator"
2
+ maintainer "Dr. Heinz Doofenshmirtz"
3
+ maintainer_email "heinz@doofenshmirtz-evil-inc.com"
4
+ license "All rights reserved"
5
+ description "Uses Chef to take over the Tri-State Area!"
6
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7
+ version "0.1.0"
@@ -0,0 +1,2 @@
1
+
2
+ Chef::Log.info "CURSE YOU...Perry the Platypus!!!!"
@@ -0,0 +1,25 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
2
+
3
+ require 'rspec/core'
4
+ require 'vagrant-omnibus'
5
+
6
+ RSpec.configure do |config|
7
+ config.formatter = :documentation
8
+
9
+ # a little syntactic sugar
10
+ config.alias_it_should_behave_like_to :it_has_behavior, 'has behavior:'
11
+
12
+ # Use color in STDOUT
13
+ config.color_enabled = true
14
+
15
+ # Use color not only in STDOUT but also in pagers and files
16
+ config.tty = true
17
+
18
+ # run the examples in random order
19
+ config.order = :rand
20
+
21
+ # specify metadata with symobls only (ie no '=> true' required)
22
+ config.treat_symbols_as_metadata_keys_with_true_values = true
23
+ config.filter_run :focus => true
24
+ config.run_all_when_everything_filtered = true
25
+ end
@@ -0,0 +1,71 @@
1
+ # We have to use `require_relative` until RSpec 2.14.0. As non-standard RSpec
2
+ # default paths are not on the $LOAD_PATH.
3
+ #
4
+ # More info here:
5
+ # https://github.com/rspec/rspec-core/pull/831
6
+ #
7
+ require_relative '../spec_helper'
8
+
9
+ describe VagrantPlugins::Omnibus::Config do
10
+ let(:instance){ described_class.new }
11
+
12
+ subject(:config) do
13
+ instance.tap do |o|
14
+ o.chef_version = chef_version if defined?(chef_version)
15
+ o.finalize!
16
+ end
17
+ end
18
+
19
+ describe "defaults" do
20
+ its(:chef_version){ should be_nil }
21
+ end
22
+
23
+ describe "resolving `:latest` to a real Chef version" do
24
+ let(:chef_version) { :latest }
25
+ its(:chef_version){ should be_a(String) }
26
+ its(:chef_version){ should match(/\d*\.\d*\.\d*/) }
27
+ end
28
+
29
+ describe "#validate" do
30
+ let(:machine) { double('machine') }
31
+ let(:error_hash_key) { "Omnibus Plugin" }
32
+ let(:result) { subject.validate(machine) }
33
+ let(:errors) { result[error_hash_key] }
34
+
35
+ it "returns a Hash with an 'Omnibus Plugin' key" do
36
+ result.should be_a(Hash)
37
+ result.should have_key(error_hash_key)
38
+ end
39
+
40
+ describe "chef_version validation" do
41
+ {
42
+ "11.4.0" => {
43
+ :description => "valid Chef version string",
44
+ :valid => true
45
+ },
46
+ "10.99.99" => {
47
+ :description => "invalid Chef version string",
48
+ :valid => false
49
+ },
50
+ "FUFUFU" => {
51
+ :description => "invalid RubyGems version string",
52
+ :valid => false
53
+ }
54
+ }.each_pair do |version_string, opts|
55
+ context "#{opts[:description]}: #{version_string}" do
56
+ let(:chef_version) { version_string }
57
+ if opts[:valid]
58
+ it "passes" do
59
+ errors.should be_empty
60
+ end
61
+ else
62
+ it "fails" do
63
+ errors.should_not be_empty
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end # describe chef_version
69
+ end # describe #validate
70
+
71
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-puppet-install/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-puppet-install"
8
+ spec.version = VagrantPlugins::PuppetInstall::VERSION
9
+ spec.authors = ["Seth Chisamore", "Patrick Connolly"]
10
+ spec.email = ["schisamo@opscode.com", "patrick@myplanetdigital.com"]
11
+ spec.description = %q{A Vagrant plugin that ensures the desired version of Puppet is installed via the Puppet Labs package repos.}
12
+ spec.summary = spec.description
13
+ spec.homepage = "https://github.com/patcon/vagrant-puppet-install"
14
+ spec.license = "Apache 2.0"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-puppet-install
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Seth Chisamore
9
+ - Patrick Connolly
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-09-28 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bundler
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '1.3'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '1.3'
31
+ - !ruby/object:Gem::Dependency
32
+ name: rake
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ description: A Vagrant plugin that ensures the desired version of Puppet is installed
64
+ via the Puppet Labs package repos.
65
+ email:
66
+ - schisamo@opscode.com
67
+ - patrick@myplanetdigital.com
68
+ executables: []
69
+ extensions: []
70
+ extra_rdoc_files: []
71
+ files:
72
+ - .gitignore
73
+ - .rspec
74
+ - .travis.yml
75
+ - .yardopts
76
+ - CHANGELOG.md
77
+ - Gemfile
78
+ - LICENSE
79
+ - README.md
80
+ - Rakefile
81
+ - lib/vagrant-puppet-install.rb
82
+ - lib/vagrant-puppet-install/action.rb
83
+ - lib/vagrant-puppet-install/action/install_puppet.rb
84
+ - lib/vagrant-puppet-install/action/is_running_or_active.rb
85
+ - lib/vagrant-puppet-install/action/read_puppet_version.rb
86
+ - lib/vagrant-puppet-install/config.rb
87
+ - lib/vagrant-puppet-install/plugin.rb
88
+ - lib/vagrant-puppet-install/version.rb
89
+ - test/acceptance/aws/Vagrantfile
90
+ - test/acceptance/rackspace/Vagrantfile
91
+ - test/acceptance/virtualbox/Vagrantfile
92
+ - test/support/cookbooks/chef-inator/README.md
93
+ - test/support/cookbooks/chef-inator/metadata.rb
94
+ - test/support/cookbooks/chef-inator/recipes/default.rb
95
+ - test/unit/spec_helper.rb
96
+ - test/unit/vagrant-omnibus/config_spec.rb
97
+ - vagrant-puppet-install.gemspec
98
+ homepage: https://github.com/patcon/vagrant-puppet-install
99
+ licenses:
100
+ - Apache 2.0
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ segments:
112
+ - 0
113
+ hash: 169783769753168333
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ segments:
121
+ - 0
122
+ hash: 169783769753168333
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 1.8.23
126
+ signing_key:
127
+ specification_version: 3
128
+ summary: A Vagrant plugin that ensures the desired version of Puppet is installed
129
+ via the Puppet Labs package repos.
130
+ test_files:
131
+ - test/acceptance/aws/Vagrantfile
132
+ - test/acceptance/rackspace/Vagrantfile
133
+ - test/acceptance/virtualbox/Vagrantfile
134
+ - test/support/cookbooks/chef-inator/README.md
135
+ - test/support/cookbooks/chef-inator/metadata.rb
136
+ - test/support/cookbooks/chef-inator/recipes/default.rb
137
+ - test/unit/spec_helper.rb
138
+ - test/unit/vagrant-omnibus/config_spec.rb
139
+ has_rdoc: