Run Chef commands in a single command [GH-390]

This commit is contained in:
Mitchell Hashimoto 2011-06-16 18:04:55 -06:00
parent 0cde5d2d46
commit 338b3ac094
5 changed files with 11 additions and 12 deletions

View File

@ -1,5 +1,6 @@
## 0.7.6 (unreleased)
- Run Chef commands in a single command. [GH-390]
- Add `nfs` option for Chef to mount Chef folders via NFS. [GH-378]
- Add translation for `aborted` state in VM. [GH-371]
- Use full paths with the Chef provisioner so that restart cookbook will

View File

@ -79,14 +79,13 @@ module Vagrant
def run_chef_client
command_env = config.binary_env ? "#{config.binary_env} " : ""
commands = ["cd #{config.provisioning_path}",
"#{command_env}#{chef_binary_path("chef-client")} -c client.rb -j dna.json"]
command = "#{command_env}#{chef_binary_path("chef-client")} -c #{config.provisioning_path}/client.rb -j #{config.provisioning_path}/dna.json"
env.ui.info I18n.t("vagrant.provisioners.chef.running_client")
vm.ssh.execute do |ssh|
ssh.sudo!(commands) do |channel, type, data|
ssh.sudo!(command) do |channel, type, data|
if type == :exit_status
ssh.check_exit_status(data, commands)
ssh.check_exit_status(data, command)
else
env.ui.info("#{data}: #{type}")
end

View File

@ -73,14 +73,13 @@ module Vagrant
def run_chef_solo
command_env = config.binary_env ? "#{config.binary_env} " : ""
commands = ["cd #{config.provisioning_path}",
"#{command_env}#{chef_binary_path("chef-solo")} -c #{config.provisioning_path}/solo.rb -j #{config.provisioning_path}/dna.json"]
command = "#{command_env}#{chef_binary_path("chef-solo")} -c #{config.provisioning_path}/solo.rb -j #{config.provisioning_path}/dna.json"
env.ui.info I18n.t("vagrant.provisioners.chef.running_solo")
vm.ssh.execute do |ssh|
ssh.sudo!(commands) do |channel, type, data|
ssh.sudo!(command) do |channel, type, data|
if type == :exit_status
ssh.check_exit_status(data, commands)
ssh.check_exit_status(data, command)
else
env.ui.info("#{data}: #{type}")
end

View File

@ -175,8 +175,8 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
@vm.ssh.stubs(:execute).yields(@ssh)
end
should "cd into the provisioning directory and run chef client" do
@ssh.expects(:sudo!).with(["cd #{@config.provisioning_path}", "chef-client -c client.rb -j dna.json"]).once
should "run chef client" do
@ssh.expects(:sudo!).with("chef-client -c #{@config.provisioning_path}/client.rb -j #{@config.provisioning_path}/dna.json").once
@action.run_chef_client
end

View File

@ -249,8 +249,8 @@ class ChefSoloProvisionerTest < Test::Unit::TestCase
@vm.ssh.stubs(:execute).yields(@ssh)
end
should "cd into the provisioning directory and run chef solo" do
@ssh.expects(:sudo!).with(["cd #{@config.provisioning_path}", "chef-solo -c #{@config.provisioning_path}/solo.rb -j #{@config.provisioning_path}/dna.json"]).once
should "run chef solo" do
@ssh.expects(:sudo!).with("chef-solo -c #{@config.provisioning_path}/solo.rb -j #{@config.provisioning_path}/dna.json").once
@action.run_chef_solo
end