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.
- checksums.yaml +4 -4
- data/.gitignore +19 -19
- data/.rspec +1 -1
- data/.travis.yml +18 -8
- data/.yardopts +7 -7
- data/CHANGELOG.md +98 -196
- data/Gemfile +28 -23
- data/LICENSE +201 -201
- data/README.md +147 -166
- data/Rakefile +98 -87
- data/TODO.md +5 -5
- data/lib/vagrant-omnibus.rb +31 -31
- data/lib/vagrant-omnibus/action/install_chef.rb +272 -258
- data/lib/vagrant-omnibus/config.rb +104 -128
- data/lib/vagrant-omnibus/plugin.rb +78 -55
- data/lib/vagrant-omnibus/version.rb +22 -22
- data/locales/en.yml +11 -8
- data/test/acceptance/aws/Vagrantfile +29 -29
- data/test/acceptance/digital_ocean/Vagrantfile +24 -24
- data/test/acceptance/rackspace/Vagrantfile +28 -28
- data/test/acceptance/virtualbox/Vagrantfile +93 -95
- data/test/acceptance/vmware_fusion/Vagrantfile +1 -95
- data/test/support/cookbooks/chef-inator/README.md +13 -13
- data/test/support/cookbooks/chef-inator/metadata.rb +7 -7
- data/test/support/cookbooks/chef-inator/recipes/default.rb +2 -2
- data/test/unit/spec_helper.rb +23 -25
- data/test/unit/vagrant-omnibus/config_spec.rb +121 -101
- data/test/unit/vagrant-omnibus/plugin_spec.rb +83 -0
- data/vagrant-omnibus.gemspec +27 -27
- metadata +28 -29
- data/.rubocop.yml +0 -10
- data/.ruby-version +0 -1
@@ -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
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
|
23
|
-
module VagrantPlugins
|
24
|
-
#
|
25
|
-
module Omnibus
|
26
|
-
# @author Seth Chisamore <schisamo@
|
27
|
-
class Config < Vagrant.plugin(
|
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(
|
37
|
-
end
|
38
|
-
|
39
|
-
def finalize!
|
40
|
-
if @chef_version == UNSET_VALUE
|
41
|
-
@chef_version = nil
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
#
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
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
|
-
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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 =
|
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
|
data/locales/en.yml
CHANGED
@@ -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
|
6
|
-
require
|
7
|
-
|
8
|
-
Vagrant.configure(
|
9
|
-
config.omnibus.chef_version =
|
10
|
-
|
11
|
-
config.vm.box =
|
12
|
-
config.vm.provider :aws do |aws, override|
|
13
|
-
aws.access_key_id = ENV[
|
14
|
-
aws.secret_access_key = ENV[
|
15
|
-
aws.keypair_name = ENV[
|
16
|
-
|
17
|
-
aws.instance_type =
|
18
|
-
aws.ami =
|
19
|
-
|
20
|
-
override.ssh.username =
|
21
|
-
override.ssh.private_key_path =
|
22
|
-
end
|
23
|
-
|
24
|
-
config.vm.provision :chef_solo do |chef|
|
25
|
-
chef.cookbooks_path =
|
26
|
-
File.expand_path(
|
27
|
-
chef.add_recipe
|
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
|