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.
Files changed (86) hide show
  1. data/.gitignore +2 -0
  2. data/CHANGELOG.md +26 -0
  3. data/Gemfile +0 -8
  4. data/config/default.rb +1 -2
  5. data/contrib/README.md +12 -0
  6. data/contrib/emacs/vagrant.el +8 -0
  7. data/contrib/vim/vagrantfile.vim +9 -0
  8. data/lib/vagrant.rb +14 -18
  9. data/lib/vagrant/action.rb +12 -0
  10. data/lib/vagrant/action/box.rb +11 -0
  11. data/lib/vagrant/action/box/download.rb +0 -1
  12. data/lib/vagrant/action/env.rb +7 -0
  13. data/lib/vagrant/action/general.rb +8 -0
  14. data/lib/vagrant/action/vm.rb +30 -0
  15. data/lib/vagrant/action/vm/boot.rb +3 -2
  16. data/lib/vagrant/action/vm/check_box.rb +1 -0
  17. data/lib/vagrant/action/vm/network.rb +1 -1
  18. data/lib/vagrant/action/vm/nfs.rb +3 -1
  19. data/lib/vagrant/action/vm/provision.rb +14 -25
  20. data/lib/vagrant/action/vm/share_folders.rb +11 -4
  21. data/lib/vagrant/command.rb +25 -0
  22. data/lib/vagrant/config.rb +78 -128
  23. data/lib/vagrant/config/base.rb +17 -3
  24. data/lib/vagrant/config/ssh.rb +1 -0
  25. data/lib/vagrant/config/top.rb +61 -0
  26. data/lib/vagrant/config/vagrant.rb +1 -6
  27. data/lib/vagrant/config/vm.rb +34 -20
  28. data/lib/vagrant/config/vm/provisioner.rb +56 -0
  29. data/lib/vagrant/config/vm/sub_vm.rb +17 -0
  30. data/lib/vagrant/downloaders.rb +7 -0
  31. data/lib/vagrant/downloaders/file.rb +1 -0
  32. data/lib/vagrant/downloaders/http.rb +9 -0
  33. data/lib/vagrant/environment.rb +25 -13
  34. data/lib/vagrant/errors.rb +0 -15
  35. data/lib/vagrant/hosts.rb +7 -0
  36. data/lib/vagrant/provisioners.rb +8 -0
  37. data/lib/vagrant/provisioners/base.rb +19 -1
  38. data/lib/vagrant/provisioners/chef.rb +31 -52
  39. data/lib/vagrant/provisioners/chef_server.rb +34 -10
  40. data/lib/vagrant/provisioners/chef_solo.rb +31 -9
  41. data/lib/vagrant/provisioners/puppet.rb +70 -60
  42. data/lib/vagrant/provisioners/puppet_server.rb +57 -0
  43. data/lib/vagrant/ssh.rb +3 -72
  44. data/lib/vagrant/ssh/session.rb +81 -0
  45. data/lib/vagrant/systems.rb +9 -0
  46. data/lib/vagrant/systems/base.rb +16 -1
  47. data/lib/vagrant/systems/debian.rb +26 -0
  48. data/lib/vagrant/systems/gentoo.rb +27 -0
  49. data/lib/vagrant/systems/linux.rb +14 -56
  50. data/lib/vagrant/systems/linux/config.rb +21 -0
  51. data/lib/vagrant/systems/linux/error.rb +9 -0
  52. data/lib/vagrant/systems/redhat.rb +31 -0
  53. data/lib/vagrant/test_helpers.rb +1 -1
  54. data/lib/vagrant/version.rb +1 -1
  55. data/lib/vagrant/vm.rb +25 -5
  56. data/templates/chef_solo_solo.erb +11 -3
  57. data/templates/locales/en.yml +65 -25
  58. data/templates/{network_entry.erb → network_entry_debian.erb} +0 -0
  59. data/templates/network_entry_gentoo.erb +7 -0
  60. data/templates/network_entry_redhat.erb +8 -0
  61. data/test/vagrant/action/vm/check_box_test.rb +1 -0
  62. data/test/vagrant/action/vm/nfs_test.rb +7 -1
  63. data/test/vagrant/action/vm/provision_test.rb +24 -79
  64. data/test/vagrant/action/vm/share_folders_test.rb +6 -1
  65. data/test/vagrant/command/helpers_test.rb +2 -2
  66. data/test/vagrant/config/base_test.rb +0 -6
  67. data/test/vagrant/config/vagrant_test.rb +0 -8
  68. data/test/vagrant/config/vm/provisioner_test.rb +92 -0
  69. data/test/vagrant/config/vm_test.rb +8 -0
  70. data/test/vagrant/config_test.rb +49 -89
  71. data/test/vagrant/downloaders/file_test.rb +18 -4
  72. data/test/vagrant/environment_test.rb +36 -12
  73. data/test/vagrant/provisioners/base_test.rb +28 -1
  74. data/test/vagrant/provisioners/chef_server_test.rb +50 -41
  75. data/test/vagrant/provisioners/chef_solo_test.rb +39 -16
  76. data/test/vagrant/provisioners/chef_test.rb +11 -81
  77. data/test/vagrant/provisioners/puppet_server_test.rb +69 -0
  78. data/test/vagrant/provisioners/puppet_test.rb +69 -54
  79. data/test/vagrant/{ssh_session_test.rb → ssh/session_test.rb} +0 -0
  80. data/test/vagrant/ssh_test.rb +12 -1
  81. data/test/vagrant/systems/base_test.rb +18 -0
  82. data/test/vagrant/systems/linux_test.rb +2 -2
  83. data/test/vagrant/vm_test.rb +33 -5
  84. data/vagrant.gemspec +6 -5
  85. metadata +42 -16
  86. data/lib/vagrant/util/glob_loader.rb +0 -24
@@ -0,0 +1,7 @@
1
+ module Vagrant
2
+ module Hosts
3
+ autoload :Base, 'vagrant/hosts/base'
4
+ autoload :BSD, 'vagrant/hosts/bsd'
5
+ autoload :Linux, 'vagrant/hosts/linux'
6
+ end
7
+ end
@@ -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
- def initialize(env)
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 #{env.config.chef.provisioning_path}")
22
- ssh.exec!("sudo chown #{env.config.ssh.username} #{env.config.chef.provisioning_path}")
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 => env.config.chef.log_level.to_sym
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(env.config.chef.provisioning_path, filename))
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!(env.config.chef.json)
55
+ data.merge!(config.json)
49
56
 
50
57
  json = data.to_json
51
58
 
52
- vm.ssh.upload!(StringIO.new(json), File.join(env.config.chef.provisioning_path, "dna.json"))
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 ChefConfig < Vagrant::Config::Base
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
- :instance_role => "vagrant",
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 env.config.chef.validation_key_path.nil?
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 env.config.chef.chef_server_url.nil?
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(env.config.chef.client_key_path)
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 => env.config.chef.node_name,
41
- :chef_server_url => env.config.chef.chef_server_url,
42
- :validation_client_name => env.config.chef.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 => env.config.chef.client_key_path
68
+ :client_key => config.client_key_path
45
69
  })
46
70
  end
47
71
 
48
72
  def run_chef_client
49
- command = "cd #{env.config.chef.provisioning_path} && sudo -E chef-client -c client.rb -j dna.json"
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(env.config.chef.validation_key_path, env.root_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(env.config.chef.provisioning_path, "validation.pem")
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 => env.config.chef.node_name,
33
- :provisioning_path => env.config.chef.provisioning_path,
54
+ :node_name => config.node_name,
55
+ :provisioning_path => config.provisioning_path,
34
56
  :cookbooks_path => cookbooks_path,
35
- :recipe_url => env.config.chef.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 #{env.config.chef.provisioning_path} && sudo -E chef-solo -c solo.rb -j dna.json"
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(env.config.chef.provisioning_path, args.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(env.config.chef.cookbooks_path)
115
+ host_folder_paths(config.cookbooks_path)
94
116
  end
95
117
 
96
118
  def host_role_paths
97
- host_folder_paths(env.config.chef.roles_path)
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(env.config.chef.cookbooks_path, "cookbooks").to_json
131
+ folders_path(config.cookbooks_path, "cookbooks").to_json
110
132
  end
111
133
 
112
134
  def roles_path
113
- folders_path(env.config.chef.roles_path, "roles").to_json
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
- class PuppetError < Vagrant::Errors::VagrantError
5
- error_namespace("vagrant.provisioners.puppet")
6
- end
7
+ class Puppet < Base
8
+ register :puppet
7
9
 
8
- class PuppetConfig < Vagrant::Config::Base
9
- configures :puppet
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
- attr_accessor :manifest_file
12
- attr_accessor :manifests_path
13
- attr_accessor :pp_path
14
- attr_accessor :options
16
+ def initialize
17
+ @manifest_file = nil
18
+ @manifests_path = "manifests"
19
+ @pp_path = "/tmp/vagrant-puppet"
20
+ @options = []
21
+ end
15
22
 
16
- def initialize
17
- @manifest_file = ""
18
- @manifests_path = "manifests"
19
- @pp_path = "/tmp/vagrant-puppet"
20
- @options = []
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
- class Puppet < Base
25
- def prepare
26
- check_manifest_dir
27
- share_manifests
28
- end
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
- def provision!
31
- verify_binary("puppet")
32
- create_pp_path
33
- set_manifest
34
- run_puppet_client
35
- end
35
+ def validate(errors)
36
+ super
36
37
 
37
- def check_manifest_dir
38
- Dir.mkdir(env.config.puppet.manifests_path) unless File.directory?(env.config.puppet.manifests_path)
39
- end
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
- def share_manifests
42
- env.config.vm.share_folder("manifests", env.config.puppet.pp_path, env.config.puppet.manifests_path)
43
- end
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
- def verify_binary(binary)
46
- vm.ssh.execute do |ssh|
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
- def create_pp_path
52
- vm.ssh.execute do |ssh|
53
- ssh.exec!("sudo mkdir -p #{env.config.puppet.pp_path}")
54
- ssh.exec!("sudo chown #{env.config.ssh.username} #{env.config.puppet.pp_path}")
51
+ def provision!
52
+ verify_binary("puppet")
53
+ create_pp_path
54
+ run_puppet_client
55
55
  end
56
- end
57
56
 
58
- def set_manifest
59
- @manifest = !env.config.puppet.manifest_file.empty? ? env.config.puppet.manifest_file : "#{env.config.vm.box}.pp"
57
+ def share_manifests
58
+ env.config.vm.share_folder("manifests", config.pp_path, config.manifests_path)
59
+ end
60
60
 
61
- if File.exists?("#{env.config.puppet.manifests_path}/#{@manifest}")
62
- env.ui.info I18n.t("vagrant.provisioners.puppet.manifest_to_run", :manifest => @manifest)
63
- return @manifest
64
- else
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
- def run_puppet_client
70
- options = env.config.puppet.options
71
- options = options.join(" ") if options.is_a?(Array)
72
- command = "cd #{env.config.puppet.pp_path} && sudo -E puppet #{options} #{@manifest}"
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
- env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet")
81
+ env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet", :manifest => config.computed_manifest_file)
75
82
 
76
- vm.ssh.execute do |ssh|
77
- ssh.exec!(command) do |channel, type, data|
78
- ssh.check_exit_status(data, command) if type == :exit_status
79
- env.ui.info("#{data}: #{type}") if type != :exit_status
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