vagrant-omnibus 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,128 +1,104 @@
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
- require 'vagrant/errors'
21
- require 'vagrant/util/template_renderer'
22
-
23
- module VagrantPlugins
24
- #
25
- module Omnibus
26
- # @author Seth Chisamore <schisamo@opscode.com>
27
- class Config < Vagrant.plugin('2', :config)
28
- # @return [String]
29
- # The version of Chef to install.
30
- attr_accessor :chef_version, :install_url, :cache_packages
31
-
32
- def initialize
33
- @chef_version = UNSET_VALUE
34
- @install_url = UNSET_VALUE
35
- @cache_packages = UNSET_VALUE
36
- @logger = Log4r::Logger.new('vagrantplugins::omnibus::config')
37
- end
38
-
39
- def finalize!
40
- if @chef_version == UNSET_VALUE
41
- @chef_version = nil
42
- elsif @chef_version.to_s == 'latest'
43
- # resolve `latest` to a real version
44
- @chef_version = retrieve_latest_chef_version
45
- end
46
- # enable caching by default
47
- @cache_packages = true if @cache_packages == UNSET_VALUE
48
- # nil means default install.sh|msi
49
- @install_url = nil if @install_url == UNSET_VALUE
50
- end
51
-
52
- #
53
- # Performs validation and immediately raises an exception for any
54
- # detected errors.
55
- #
56
- # @raise [Vagrant::Errors::ConfigInvalid]
57
- # if validation fails
58
- #
59
- def validate!(machine)
60
- finalize!
61
- errors = []
62
-
63
- if !chef_version.nil? && !valid_chef_version?(chef_version)
64
- msg = <<-EOH
65
- '#{ chef_version }' is not a valid version of Chef.
66
-
67
- A list of valid versions can be found at: http://www.opscode.com/chef/install/
68
- EOH
69
- errors << msg
70
- end
71
-
72
- if errors.any?
73
- rendered_errors = Vagrant::Util::TemplateRenderer.render(
74
- 'config/validation_failed',
75
- errors: { 'vagrant-omnibus' => errors }
76
- )
77
- fail Vagrant::Errors::ConfigInvalid, errors: rendered_errors
78
- end
79
- end
80
-
81
- private
82
-
83
- # Query RubyGems.org's Ruby API and retrive the latest version of Chef.
84
- def retrieve_latest_chef_version
85
- available_gems =
86
- dependency_installer.find_gems_with_sources(chef_gem_dependency)
87
- spec, _source =
88
- if available_gems.respond_to?(:last)
89
- # DependencyInstaller sorts the results such that the last one is
90
- # always the one it considers best.
91
- spec_with_source = available_gems.last
92
- spec_with_source
93
- else
94
- # Rubygems 2.0 returns a Gem::Available set, which is a
95
- # collection of AvailableSet::Tuple structs
96
- available_gems.pick_best!
97
- best_gem = available_gems.set.first
98
- best_gem && [best_gem.spec, best_gem.source]
99
- end
100
-
101
- spec && spec.version.to_s
102
- end
103
-
104
- # Query RubyGems.org's Ruby API to see if the user-provided Chef version
105
- # is in fact a real Chef version!
106
- def valid_chef_version?(version)
107
- is_valid = false
108
- begin
109
- available = dependency_installer.find_gems_with_sources(
110
- chef_gem_dependency(version)
111
- )
112
- is_valid = true unless available.empty?
113
- rescue ArgumentError => e
114
- @logger.debug("#{version} is not a valid Chef version: #{e}")
115
- end
116
- is_valid
117
- end
118
-
119
- def dependency_installer
120
- @dependency_installer ||= Gem::DependencyInstaller.new
121
- end
122
-
123
- def chef_gem_dependency(version = nil)
124
- Gem::Dependency.new('chef', version)
125
- end
126
- end
127
- end
128
- end
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
+ require "vagrant/errors"
21
+ require "vagrant/util/template_renderer"
22
+
23
+ module VagrantPlugins
24
+ #
25
+ module Omnibus
26
+ # @author Seth Chisamore <schisamo@chef.io>
27
+ class Config < Vagrant.plugin("2", :config)
28
+ # @return [String]
29
+ # The version of Chef to install.
30
+ attr_accessor :chef_version, :install_url, :cache_packages
31
+
32
+ def initialize
33
+ @chef_version = UNSET_VALUE
34
+ @install_url = UNSET_VALUE
35
+ @cache_packages = UNSET_VALUE
36
+ @logger = Log4r::Logger.new("vagrantplugins::omnibus::config")
37
+ end
38
+
39
+ def finalize!
40
+ if @chef_version == UNSET_VALUE
41
+ @chef_version = nil
42
+ end
43
+ # enable caching by default
44
+ @cache_packages = true if @cache_packages == UNSET_VALUE
45
+ # nil means default install.sh|msi
46
+ @install_url = nil if @install_url == UNSET_VALUE
47
+ end
48
+
49
+ #
50
+ # Performs validation and immediately raises an exception for any
51
+ # detected errors.
52
+ #
53
+ # @raise [Vagrant::Errors::ConfigInvalid]
54
+ # if validation fails
55
+ #
56
+ def validate!(machine)
57
+ finalize!
58
+ errors = []
59
+
60
+ if !chef_version.nil? && !valid_chef_version?(chef_version)
61
+ msg = <<-EOH
62
+ '#{ chef_version }' is not a valid version of Chef.
63
+
64
+ A list of valid versions can be found at: https://downloads.chef.io/chef-client/
65
+ EOH
66
+ errors << msg
67
+ end
68
+
69
+ if errors.any?
70
+ rendered_errors = Vagrant::Util::TemplateRenderer.render(
71
+ "config/validation_failed",
72
+ errors: { "vagrant-omnibus" => errors }
73
+ )
74
+ raise Vagrant::Errors::ConfigInvalid, errors: rendered_errors
75
+ end
76
+ end
77
+
78
+ private
79
+
80
+ # Query RubyGems.org's Ruby API to see if the user-provided Chef version
81
+ # is in fact a real Chef version!
82
+ def valid_chef_version?(version)
83
+ return true if version.to_s == "latest"
84
+ begin
85
+ available = dependency_installer.find_gems_with_sources(
86
+ chef_gem_dependency(version)
87
+ )
88
+ rescue ArgumentError => e
89
+ @logger.debug("#{version} is not a valid Chef version: #{e}")
90
+ return false
91
+ end
92
+ return !available.empty?
93
+ end
94
+
95
+ def dependency_installer
96
+ @dependency_installer ||= Gem::DependencyInstaller.new
97
+ end
98
+
99
+ def chef_gem_dependency(version = nil)
100
+ Gem::Dependency.new("chef", version)
101
+ end
102
+ end
103
+ end
104
+ end
@@ -1,55 +1,78 @@
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
- # This is a sanity check to make sure no one is attempting to install
18
- # this into an early Vagrant version.
19
- if Vagrant::VERSION < '1.1.0'
20
- fail 'The Vagrant Omnibus plugin is only compatible with Vagrant 1.1+'
21
- end
22
-
23
- module VagrantPlugins
24
- #
25
- module Omnibus
26
- # @author Seth Chisamore <schisamo@opscode.com>
27
- class Plugin < Vagrant.plugin('2')
28
- name 'vagrant-omnibus'
29
- description <<-DESC
30
- This plugin ensures the desired version of Chef is installed
31
- via the platform-specific Omnibus packages.
32
- DESC
33
-
34
- action_hook(:install_chef, Plugin::ALL_ACTIONS) do |hook|
35
- require_relative 'action/install_chef'
36
- hook.after(Vagrant::Action::Builtin::Provision, Action::InstallChef)
37
-
38
- # The AWS provider < v0.4.0 uses a non-standard Provision action
39
- # on initial creation:
40
- #
41
- # mitchellh/vagrant-aws/blob/v0.3.0/lib/vagrant-aws/action.rb#L105
42
- #
43
- if defined? VagrantPlugins::AWS::Action::TimedProvision
44
- hook.after(VagrantPlugins::AWS::Action::TimedProvision,
45
- Action::InstallChef)
46
- end
47
- end
48
-
49
- config(:omnibus) do
50
- require_relative 'config'
51
- Config
52
- end
53
- end
54
- end
55
- end
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
+ #
19
+ module Omnibus
20
+ # @author Seth Chisamore <schisamo@chef.io>
21
+ class Plugin < Vagrant.plugin("2")
22
+ name "vagrant-omnibus"
23
+ description <<-DESC
24
+ This plugin ensures the desired version of Chef is installed
25
+ via the platform-specific Omnibus packages.
26
+ DESC
27
+
28
+ VAGRANT_VERSION_REQUIREMENT = ">= 1.1.0"
29
+
30
+ # Returns true if the Vagrant version fulfills the requirements
31
+ #
32
+ # @param requirements [String, Array<String>] the version requirement
33
+ # @return [Boolean]
34
+ def self.check_vagrant_version(*requirements)
35
+ Gem::Requirement.new(*requirements).satisfied_by?(
36
+ Gem::Version.new(Vagrant::VERSION)
37
+ )
38
+ end
39
+
40
+ # Verifies that the Vagrant version fulfills the requirements
41
+ #
42
+ # @raise [VagrantPlugins::Omnibus::VagrantVersionError] if this plugin
43
+ # is incompatible with the Vagrant version
44
+ def self.check_vagrant_version!
45
+ unless check_vagrant_version(VAGRANT_VERSION_REQUIREMENT)
46
+ msg = I18n.t(
47
+ "vagrant-omnibus.errors.vagrant_version",
48
+ requirement: VAGRANT_VERSION_REQUIREMENT.inspect
49
+ )
50
+ $stderr.puts(msg)
51
+ raise msg
52
+ end
53
+ end
54
+
55
+ action_hook(:install_chef, Plugin::ALL_ACTIONS) do |hook|
56
+ require_relative "action/install_chef"
57
+ hook.after(Vagrant::Action::Builtin::Provision, Action::InstallChef)
58
+
59
+ # The AWS provider < v0.4.0 uses a non-standard Provision action
60
+ # on initial creation:
61
+ #
62
+ # mitchellh/vagrant-aws/blob/v0.3.0/lib/vagrant-aws/action.rb#L105
63
+ #
64
+ if defined? VagrantPlugins::AWS::Action::TimedProvision
65
+ hook.after(
66
+ VagrantPlugins::AWS::Action::TimedProvision,
67
+ Action::InstallChef
68
+ )
69
+ end
70
+ end
71
+
72
+ config(:omnibus) do
73
+ require_relative "config"
74
+ Config
75
+ end
76
+ end
77
+ end
78
+ end
@@ -1,22 +1,22 @@
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
- #
19
- module Omnibus
20
- VERSION = '1.4.1'
21
- end
22
- end
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
+ #
19
+ module Omnibus
20
+ VERSION = "1.5.0"
21
+ end
22
+ end
@@ -1,8 +1,11 @@
1
- en:
2
- vagrant-omnibus:
3
- action:
4
- installed: "Chef %{version} Omnibus package is already installed."
5
- installing: "Installing Chef %{version} Omnibus package..."
6
- download:
7
- downloading: "Downloading or copying install.sh..."
8
- interrupted: "Install.sh download was interrupted. Exiting."
1
+ en:
2
+ vagrant-omnibus:
3
+ action:
4
+ installed: "Chef %{version} Omnibus package is already installed."
5
+ installing: "Installing Chef %{version} Omnibus package..."
6
+ download:
7
+ downloading: "Downloading or copying install.sh..."
8
+ interrupted: "Install.sh download was interrupted. Exiting."
9
+ errors:
10
+ vagrant_version: |-
11
+ vagrant-omnibus plugin requires Vagrant version %{requirement}
@@ -1,29 +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
-
20
- override.ssh.username = 'ubuntu'
21
- override.ssh.private_key_path = '~/.ssh/id_rsa'
22
- end
23
-
24
- config.vm.provision :chef_solo do |chef|
25
- chef.cookbooks_path =
26
- File.expand_path('../../../support/cookbooks', __FILE__)
27
- chef.add_recipe 'chef-inator'
28
- end
29
- end
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
+
20
+ override.ssh.username = "ubuntu"
21
+ override.ssh.private_key_path = "~/.ssh/id_rsa"
22
+ end
23
+
24
+ config.vm.provision :chef_solo do |chef|
25
+ chef.cookbooks_path =
26
+ File.expand_path("../../../support/cookbooks", __FILE__)
27
+ chef.add_recipe "chef-inator"
28
+ end
29
+ end