vagrant 0.7.0.beta → 0.7.0.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/CHANGELOG.md +26 -0
- data/Gemfile +0 -8
- data/config/default.rb +1 -2
- data/contrib/README.md +12 -0
- data/contrib/emacs/vagrant.el +8 -0
- data/contrib/vim/vagrantfile.vim +9 -0
- data/lib/vagrant.rb +14 -18
- data/lib/vagrant/action.rb +12 -0
- data/lib/vagrant/action/box.rb +11 -0
- data/lib/vagrant/action/box/download.rb +0 -1
- data/lib/vagrant/action/env.rb +7 -0
- data/lib/vagrant/action/general.rb +8 -0
- data/lib/vagrant/action/vm.rb +30 -0
- data/lib/vagrant/action/vm/boot.rb +3 -2
- data/lib/vagrant/action/vm/check_box.rb +1 -0
- data/lib/vagrant/action/vm/network.rb +1 -1
- data/lib/vagrant/action/vm/nfs.rb +3 -1
- data/lib/vagrant/action/vm/provision.rb +14 -25
- data/lib/vagrant/action/vm/share_folders.rb +11 -4
- data/lib/vagrant/command.rb +25 -0
- data/lib/vagrant/config.rb +78 -128
- data/lib/vagrant/config/base.rb +17 -3
- data/lib/vagrant/config/ssh.rb +1 -0
- data/lib/vagrant/config/top.rb +61 -0
- data/lib/vagrant/config/vagrant.rb +1 -6
- data/lib/vagrant/config/vm.rb +34 -20
- data/lib/vagrant/config/vm/provisioner.rb +56 -0
- data/lib/vagrant/config/vm/sub_vm.rb +17 -0
- data/lib/vagrant/downloaders.rb +7 -0
- data/lib/vagrant/downloaders/file.rb +1 -0
- data/lib/vagrant/downloaders/http.rb +9 -0
- data/lib/vagrant/environment.rb +25 -13
- data/lib/vagrant/errors.rb +0 -15
- data/lib/vagrant/hosts.rb +7 -0
- data/lib/vagrant/provisioners.rb +8 -0
- data/lib/vagrant/provisioners/base.rb +19 -1
- data/lib/vagrant/provisioners/chef.rb +31 -52
- data/lib/vagrant/provisioners/chef_server.rb +34 -10
- data/lib/vagrant/provisioners/chef_solo.rb +31 -9
- data/lib/vagrant/provisioners/puppet.rb +70 -60
- data/lib/vagrant/provisioners/puppet_server.rb +57 -0
- data/lib/vagrant/ssh.rb +3 -72
- data/lib/vagrant/ssh/session.rb +81 -0
- data/lib/vagrant/systems.rb +9 -0
- data/lib/vagrant/systems/base.rb +16 -1
- data/lib/vagrant/systems/debian.rb +26 -0
- data/lib/vagrant/systems/gentoo.rb +27 -0
- data/lib/vagrant/systems/linux.rb +14 -56
- data/lib/vagrant/systems/linux/config.rb +21 -0
- data/lib/vagrant/systems/linux/error.rb +9 -0
- data/lib/vagrant/systems/redhat.rb +31 -0
- data/lib/vagrant/test_helpers.rb +1 -1
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +25 -5
- data/templates/chef_solo_solo.erb +11 -3
- data/templates/locales/en.yml +65 -25
- data/templates/{network_entry.erb → network_entry_debian.erb} +0 -0
- data/templates/network_entry_gentoo.erb +7 -0
- data/templates/network_entry_redhat.erb +8 -0
- data/test/vagrant/action/vm/check_box_test.rb +1 -0
- data/test/vagrant/action/vm/nfs_test.rb +7 -1
- data/test/vagrant/action/vm/provision_test.rb +24 -79
- data/test/vagrant/action/vm/share_folders_test.rb +6 -1
- data/test/vagrant/command/helpers_test.rb +2 -2
- data/test/vagrant/config/base_test.rb +0 -6
- data/test/vagrant/config/vagrant_test.rb +0 -8
- data/test/vagrant/config/vm/provisioner_test.rb +92 -0
- data/test/vagrant/config/vm_test.rb +8 -0
- data/test/vagrant/config_test.rb +49 -89
- data/test/vagrant/downloaders/file_test.rb +18 -4
- data/test/vagrant/environment_test.rb +36 -12
- data/test/vagrant/provisioners/base_test.rb +28 -1
- data/test/vagrant/provisioners/chef_server_test.rb +50 -41
- data/test/vagrant/provisioners/chef_solo_test.rb +39 -16
- data/test/vagrant/provisioners/chef_test.rb +11 -81
- data/test/vagrant/provisioners/puppet_server_test.rb +69 -0
- data/test/vagrant/provisioners/puppet_test.rb +69 -54
- data/test/vagrant/{ssh_session_test.rb → ssh/session_test.rb} +0 -0
- data/test/vagrant/ssh_test.rb +12 -1
- data/test/vagrant/systems/base_test.rb +18 -0
- data/test/vagrant/systems/linux_test.rb +2 -2
- data/test/vagrant/vm_test.rb +33 -5
- data/vagrant.gemspec +6 -5
- metadata +42 -16
- data/lib/vagrant/util/glob_loader.rb +0 -24
@@ -0,0 +1,8 @@
|
|
1
|
+
# These aren't autoloaded because they have to register things such
|
2
|
+
# as configuration classes right away with Vagrant.
|
3
|
+
require 'vagrant/provisioners/base'
|
4
|
+
require 'vagrant/provisioners/chef'
|
5
|
+
require 'vagrant/provisioners/chef_server'
|
6
|
+
require 'vagrant/provisioners/chef_solo'
|
7
|
+
require 'vagrant/provisioners/puppet'
|
8
|
+
require 'vagrant/provisioners/puppet_server'
|
@@ -11,8 +11,26 @@ module Vagrant
|
|
11
11
|
# {Vagrant::Action::Environment}
|
12
12
|
attr_reader :action_env
|
13
13
|
|
14
|
-
|
14
|
+
# The configuration for this provisioner. This will be an instance of
|
15
|
+
# the `Config` class which is part of the provisioner.
|
16
|
+
attr_reader :config
|
17
|
+
|
18
|
+
# Registers a provisioner with a given shortcut. This allows that provisioner
|
19
|
+
# to be referenced with the shortcut.
|
20
|
+
#
|
21
|
+
# @param [Symbol] shortcut
|
22
|
+
def self.register(shortcut)
|
23
|
+
registered[shortcut] = self
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the provisioner associated with the given shortcut.
|
27
|
+
def self.registered
|
28
|
+
@@registered ||= {}
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(env, config)
|
15
32
|
@action_env = env
|
33
|
+
@config = config
|
16
34
|
end
|
17
35
|
|
18
36
|
# Returns the actual {Vagrant::Environment} which this provisioner
|
@@ -12,23 +12,30 @@ module Vagrant
|
|
12
12
|
vm.ssh.execute do |ssh|
|
13
13
|
# Checks for the existence of chef binary and error if it
|
14
14
|
# doesn't exist.
|
15
|
-
ssh.exec!("which #{binary}", :error_class => ChefError, :_key => :chef_not_detected, :binary => binary)
|
15
|
+
ssh.exec!("sudo -i which #{binary}", :error_class => ChefError, :_key => :chef_not_detected, :binary => binary)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
def chown_provisioning_folder
|
20
20
|
vm.ssh.execute do |ssh|
|
21
|
-
ssh.exec!("sudo mkdir -p #{
|
22
|
-
ssh.exec!("sudo chown #{env.config.ssh.username} #{
|
21
|
+
ssh.exec!("sudo mkdir -p #{config.provisioning_path}")
|
22
|
+
ssh.exec!("sudo chown #{env.config.ssh.username} #{config.provisioning_path}")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
def setup_config(template, filename, template_vars)
|
27
27
|
config_file = TemplateRenderer.render(template, {
|
28
|
-
:log_level =>
|
28
|
+
:log_level => config.log_level.to_sym,
|
29
|
+
:http_proxy => config.http_proxy,
|
30
|
+
:http_proxy_user => config.http_proxy_user,
|
31
|
+
:http_proxy_pass => config.http_proxy_pass,
|
32
|
+
:https_proxy => config.https_proxy,
|
33
|
+
:https_proxy_user => config.https_proxy_user,
|
34
|
+
:https_proxy_pass => config.https_proxy_pass,
|
35
|
+
:no_proxy => config.no_proxy
|
29
36
|
}.merge(template_vars))
|
30
37
|
|
31
|
-
vm.ssh.upload!(StringIO.new(config_file), File.join(
|
38
|
+
vm.ssh.upload!(StringIO.new(config_file), File.join(config.provisioning_path, filename))
|
32
39
|
end
|
33
40
|
|
34
41
|
def setup_json
|
@@ -45,11 +52,11 @@ module Vagrant
|
|
45
52
|
|
46
53
|
# Merge with the "extra data" which isn't put under the
|
47
54
|
# vagrant namespace by default
|
48
|
-
data.merge!(
|
55
|
+
data.merge!(config.json)
|
49
56
|
|
50
57
|
json = data.to_json
|
51
58
|
|
52
|
-
vm.ssh.upload!(StringIO.new(json), File.join(
|
59
|
+
vm.ssh.upload!(StringIO.new(json), File.join(config.provisioning_path, "dna.json"))
|
53
60
|
end
|
54
61
|
end
|
55
62
|
|
@@ -61,37 +68,31 @@ module Vagrant
|
|
61
68
|
|
62
69
|
class Chef < Base
|
63
70
|
# This is the configuration which is available through `config.chef`
|
64
|
-
class
|
65
|
-
configures :chef
|
66
|
-
|
67
|
-
# Chef server specific config
|
68
|
-
attr_accessor :chef_server_url
|
69
|
-
attr_accessor :validation_key_path
|
70
|
-
attr_accessor :validation_client_name
|
71
|
-
attr_accessor :client_key_path
|
72
|
-
attr_accessor :node_name
|
73
|
-
|
74
|
-
# Chef solo specific config
|
75
|
-
attr_accessor :cookbooks_path
|
76
|
-
attr_accessor :roles_path
|
77
|
-
attr_accessor :recipe_url
|
78
|
-
|
71
|
+
class Config < Vagrant::Config::Base
|
79
72
|
# Shared config
|
73
|
+
attr_accessor :node_name
|
80
74
|
attr_accessor :provisioning_path
|
81
75
|
attr_accessor :log_level
|
82
76
|
attr_accessor :json
|
77
|
+
attr_accessor :http_proxy
|
78
|
+
attr_accessor :http_proxy_user
|
79
|
+
attr_accessor :http_proxy_pass
|
80
|
+
attr_accessor :https_proxy
|
81
|
+
attr_accessor :https_proxy_user
|
82
|
+
attr_accessor :https_proxy_pass
|
83
|
+
attr_accessor :no_proxy
|
83
84
|
|
84
85
|
def initialize
|
85
|
-
@validation_client_name = "chef-validator"
|
86
|
-
@client_key_path = "/etc/chef/client.pem"
|
87
|
-
|
88
|
-
@cookbooks_path = ["cookbooks", [:vm, "cookbooks"]]
|
89
|
-
@roles_path = []
|
90
86
|
@provisioning_path = "/tmp/vagrant-chef"
|
91
87
|
@log_level = :info
|
92
|
-
@json = {
|
93
|
-
|
94
|
-
|
88
|
+
@json = { :instance_role => "vagrant" }
|
89
|
+
@http_proxy = nil
|
90
|
+
@http_proxy_user = nil
|
91
|
+
@http_proxy_pass = nil
|
92
|
+
@https_proxy = nil
|
93
|
+
@https_proxy_user = nil
|
94
|
+
@https_proxy_pass = nil
|
95
|
+
@no_proxy = nil
|
95
96
|
end
|
96
97
|
|
97
98
|
# Returns the run list for the provisioning
|
@@ -123,28 +124,6 @@ module Vagrant
|
|
123
124
|
result.delete("json")
|
124
125
|
result
|
125
126
|
end
|
126
|
-
|
127
|
-
def validate(errors)
|
128
|
-
if top.vm.provisioner == :chef_solo
|
129
|
-
# Validate chef solo settings
|
130
|
-
errors.add(I18n.t("vagrant.config.chef.cookbooks_path_empty")) if !cookbooks_path || [cookbooks_path].flatten.empty?
|
131
|
-
end
|
132
|
-
|
133
|
-
if top.vm.provisioner == :chef_server
|
134
|
-
# Validate chef server settings
|
135
|
-
errors.add(I18n.t("vagrant.config.chef.server_url_empty")) if !chef_server_url || chef_server_url.strip == ""
|
136
|
-
errors.add(I18n.t("vagrant.config.chef.validation_key_path")) if !validation_key_path
|
137
|
-
end
|
138
|
-
|
139
|
-
if top.vm.provisioner == :chef_solo
|
140
|
-
# On chef solo, a run list MUST be specified
|
141
|
-
errors.add(I18n.t("vagrant.config.chef.run_list_empty")) if !json[:run_list] || run_list.empty?
|
142
|
-
elsif top.vm.provisioner == :chef_server
|
143
|
-
# On chef server, the run list is allowed to be nil, which causes it
|
144
|
-
# to sync with the chef server.
|
145
|
-
errors.add(I18n.t("vagrant.config.chef.run_list_empty")) if json[:run_list] && run_list.empty?
|
146
|
-
end
|
147
|
-
end
|
148
127
|
end
|
149
128
|
end
|
150
129
|
end
|
@@ -5,10 +5,34 @@ module Vagrant
|
|
5
5
|
# This class implements provisioning via chef-client, allowing provisioning
|
6
6
|
# with a chef server.
|
7
7
|
class ChefServer < Chef
|
8
|
+
register :chef_server
|
9
|
+
|
10
|
+
class Config < Chef::Config
|
11
|
+
attr_accessor :chef_server_url
|
12
|
+
attr_accessor :validation_key_path
|
13
|
+
attr_accessor :validation_client_name
|
14
|
+
attr_accessor :client_key_path
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
super
|
18
|
+
|
19
|
+
@validation_client_name = "chef-validator"
|
20
|
+
@client_key_path = "/etc/chef/client.pem"
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate(errors)
|
24
|
+
super
|
25
|
+
|
26
|
+
errors.add(I18n.t("vagrant.config.chef.server_url_empty")) if !chef_server_url || chef_server_url.strip == ""
|
27
|
+
errors.add(I18n.t("vagrant.config.chef.validation_key_path")) if !validation_key_path
|
28
|
+
errors.add(I18n.t("vagrant.config.chef.run_list_empty")) if json[:run_list] && run_list.empty?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
8
32
|
def prepare
|
9
|
-
raise ChefError, :server_validation_key_required if
|
33
|
+
raise ChefError, :server_validation_key_required if config.validation_key_path.nil?
|
10
34
|
raise ChefError, :server_validation_key_doesnt_exist if !File.file?(validation_key_path)
|
11
|
-
raise ChefError, :server_url_required if
|
35
|
+
raise ChefError, :server_url_required if config.chef_server_url.nil?
|
12
36
|
end
|
13
37
|
|
14
38
|
def provision!
|
@@ -23,7 +47,7 @@ module Vagrant
|
|
23
47
|
|
24
48
|
def create_client_key_folder
|
25
49
|
env.ui.info I18n.t("vagrant.provisioners.chef.client_key_folder")
|
26
|
-
path = Pathname.new(
|
50
|
+
path = Pathname.new(config.client_key_path)
|
27
51
|
|
28
52
|
vm.ssh.execute do |ssh|
|
29
53
|
ssh.exec!("sudo mkdir -p #{path.dirname}")
|
@@ -37,16 +61,16 @@ module Vagrant
|
|
37
61
|
|
38
62
|
def setup_server_config
|
39
63
|
setup_config("chef_server_client", "client.rb", {
|
40
|
-
:node_name =>
|
41
|
-
:chef_server_url =>
|
42
|
-
:validation_client_name =>
|
64
|
+
:node_name => config.node_name,
|
65
|
+
:chef_server_url => config.chef_server_url,
|
66
|
+
:validation_client_name => config.validation_client_name,
|
43
67
|
:validation_key => guest_validation_key_path,
|
44
|
-
:client_key =>
|
68
|
+
:client_key => config.client_key_path
|
45
69
|
})
|
46
70
|
end
|
47
71
|
|
48
72
|
def run_chef_client
|
49
|
-
command = "cd #{
|
73
|
+
command = "sudo -i 'cd #{config.provisioning_path} && chef-client -c client.rb -j dna.json'"
|
50
74
|
|
51
75
|
env.ui.info I18n.t("vagrant.provisioners.chef.running_client")
|
52
76
|
vm.ssh.execute do |ssh|
|
@@ -61,11 +85,11 @@ module Vagrant
|
|
61
85
|
end
|
62
86
|
|
63
87
|
def validation_key_path
|
64
|
-
File.expand_path(
|
88
|
+
File.expand_path(config.validation_key_path, env.root_path)
|
65
89
|
end
|
66
90
|
|
67
91
|
def guest_validation_key_path
|
68
|
-
File.join(
|
92
|
+
File.join(config.provisioning_path, "validation.pem")
|
69
93
|
end
|
70
94
|
end
|
71
95
|
end
|
@@ -2,6 +2,28 @@ module Vagrant
|
|
2
2
|
module Provisioners
|
3
3
|
# This class implements provisioning via chef-solo.
|
4
4
|
class ChefSolo < Chef
|
5
|
+
register :chef_solo
|
6
|
+
|
7
|
+
class Config < Chef::Config
|
8
|
+
attr_accessor :cookbooks_path
|
9
|
+
attr_accessor :roles_path
|
10
|
+
attr_accessor :recipe_url
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
super
|
14
|
+
|
15
|
+
@cookbooks_path = ["cookbooks", [:vm, "cookbooks"]]
|
16
|
+
@roles_path = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def validate(errors)
|
20
|
+
super
|
21
|
+
|
22
|
+
errors.add(I18n.t("vagrant.config.chef.cookbooks_path_empty")) if !cookbooks_path || [cookbooks_path].flatten.empty?
|
23
|
+
errors.add(I18n.t("vagrant.config.chef.run_list_empty")) if !json[:run_list] || run_list.empty?
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
5
27
|
def prepare
|
6
28
|
share_cookbook_folders
|
7
29
|
share_role_folders
|
@@ -29,16 +51,16 @@ module Vagrant
|
|
29
51
|
|
30
52
|
def setup_solo_config
|
31
53
|
setup_config("chef_solo_solo", "solo.rb", {
|
32
|
-
:node_name =>
|
33
|
-
:provisioning_path =>
|
54
|
+
:node_name => config.node_name,
|
55
|
+
:provisioning_path => config.provisioning_path,
|
34
56
|
:cookbooks_path => cookbooks_path,
|
35
|
-
:recipe_url =>
|
57
|
+
:recipe_url => config.recipe_url,
|
36
58
|
:roles_path => roles_path,
|
37
59
|
})
|
38
60
|
end
|
39
61
|
|
40
62
|
def run_chef_solo
|
41
|
-
command = "cd #{
|
63
|
+
command = "sudo -i 'cd #{config.provisioning_path} && chef-solo -c solo.rb -j dna.json'"
|
42
64
|
|
43
65
|
env.ui.info I18n.t("vagrant.provisioners.chef.running_solo")
|
44
66
|
vm.ssh.execute do |ssh|
|
@@ -64,7 +86,7 @@ module Vagrant
|
|
64
86
|
end
|
65
87
|
|
66
88
|
def folder_path(*args)
|
67
|
-
File.join(
|
89
|
+
File.join(config.provisioning_path, args.join("-"))
|
68
90
|
end
|
69
91
|
|
70
92
|
def folders_path(folders, folder)
|
@@ -90,11 +112,11 @@ module Vagrant
|
|
90
112
|
end
|
91
113
|
|
92
114
|
def host_cookbook_paths
|
93
|
-
host_folder_paths(
|
115
|
+
host_folder_paths(config.cookbooks_path)
|
94
116
|
end
|
95
117
|
|
96
118
|
def host_role_paths
|
97
|
-
host_folder_paths(
|
119
|
+
host_folder_paths(config.roles_path)
|
98
120
|
end
|
99
121
|
|
100
122
|
def cookbook_path(i)
|
@@ -106,11 +128,11 @@ module Vagrant
|
|
106
128
|
end
|
107
129
|
|
108
130
|
def cookbooks_path
|
109
|
-
folders_path(
|
131
|
+
folders_path(config.cookbooks_path, "cookbooks").to_json
|
110
132
|
end
|
111
133
|
|
112
134
|
def roles_path
|
113
|
-
folders_path(
|
135
|
+
folders_path(config.roles_path, "roles").to_json
|
114
136
|
end
|
115
137
|
end
|
116
138
|
end
|
@@ -1,85 +1,95 @@
|
|
1
1
|
module Vagrant
|
2
2
|
module Provisioners
|
3
|
+
class PuppetError < Vagrant::Errors::VagrantError
|
4
|
+
error_namespace("vagrant.provisioners.puppet")
|
5
|
+
end
|
3
6
|
|
4
|
-
|
5
|
-
|
6
|
-
end
|
7
|
+
class Puppet < Base
|
8
|
+
register :puppet
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
+
class Config < Vagrant::Config::Base
|
11
|
+
attr_accessor :manifest_file
|
12
|
+
attr_accessor :manifests_path
|
13
|
+
attr_accessor :pp_path
|
14
|
+
attr_accessor :options
|
10
15
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
def initialize
|
17
|
+
@manifest_file = nil
|
18
|
+
@manifests_path = "manifests"
|
19
|
+
@pp_path = "/tmp/vagrant-puppet"
|
20
|
+
@options = []
|
21
|
+
end
|
15
22
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
|
+
# Returns the manifests path expanded relative to the root path of the
|
24
|
+
# environment.
|
25
|
+
def expanded_manifests_path
|
26
|
+
Pathname.new(manifests_path).expand_path(env.root_path)
|
27
|
+
end
|
23
28
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
# Returns the manifest file if set otherwise returns the box name pp file
|
30
|
+
# which may or may not exist.
|
31
|
+
def computed_manifest_file
|
32
|
+
manifest_file || "#{top.vm.box}.pp"
|
33
|
+
end
|
29
34
|
|
30
|
-
|
31
|
-
|
32
|
-
create_pp_path
|
33
|
-
set_manifest
|
34
|
-
run_puppet_client
|
35
|
-
end
|
35
|
+
def validate(errors)
|
36
|
+
super
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
if !expanded_manifests_path.directory?
|
39
|
+
errors.add(I18n.t("vagrant.provisioners.puppet.manifests_path_missing", :path => expanded_manifests_path))
|
40
|
+
return
|
41
|
+
end
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
43
|
+
errors.add(I18n.t("vagrant.provisioners.puppet.manifest_missing", :manifest => computed_manifest_file)) if !expanded_manifests_path.join(computed_manifest_file).file?
|
44
|
+
end
|
45
|
+
end
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
ssh.exec!("which #{binary}", :error_class => PuppetError, :_key => :puppet_not_detected, :binary => binary)
|
47
|
+
def prepare
|
48
|
+
share_manifests
|
48
49
|
end
|
49
|
-
end
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
def provision!
|
52
|
+
verify_binary("puppet")
|
53
|
+
create_pp_path
|
54
|
+
run_puppet_client
|
55
55
|
end
|
56
|
-
end
|
57
56
|
|
58
|
-
|
59
|
-
|
57
|
+
def share_manifests
|
58
|
+
env.config.vm.share_folder("manifests", config.pp_path, config.manifests_path)
|
59
|
+
end
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
raise PuppetError, :_key => :manifest_missing, :manifest => @manifest
|
61
|
+
def verify_binary(binary)
|
62
|
+
vm.ssh.execute do |ssh|
|
63
|
+
ssh.exec!("sudo -i which #{binary}", :error_class => PuppetError, :_key => :puppet_not_detected, :binary => binary)
|
64
|
+
end
|
66
65
|
end
|
67
|
-
end
|
68
66
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
67
|
+
def create_pp_path
|
68
|
+
vm.ssh.execute do |ssh|
|
69
|
+
ssh.exec!("sudo mkdir -p #{config.pp_path}")
|
70
|
+
ssh.exec!("sudo chown #{env.config.ssh.username} #{config.pp_path}")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def run_puppet_client
|
75
|
+
options = [config.options].flatten
|
76
|
+
options << config.computed_manifest_file
|
77
|
+
options = options.join(" ")
|
78
|
+
|
79
|
+
command = "sudo -i 'cd #{config.pp_path}; puppet #{options}'"
|
73
80
|
|
74
|
-
|
81
|
+
env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet", :manifest => config.computed_manifest_file)
|
75
82
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
83
|
+
vm.ssh.execute do |ssh|
|
84
|
+
ssh.exec! command do |ch, type, data|
|
85
|
+
if type == :exit_status
|
86
|
+
ssh.check_exit_status(data, command)
|
87
|
+
else
|
88
|
+
env.ui.info(data)
|
89
|
+
end
|
90
|
+
end
|
80
91
|
end
|
81
92
|
end
|
82
93
|
end
|
83
94
|
end
|
84
|
-
end
|
85
95
|
end
|