diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f2fbf853..a667087a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Fix issue with download progress not properly clearing the line. [GH-476] - NFS should work properly on Fedora. [GH-450] + - Arguments can be specified to the `shell` provisioner via the `args` option. [GH-475] ## 0.8.5 (August 15, 2011) diff --git a/lib/vagrant/provisioners/shell.rb b/lib/vagrant/provisioners/shell.rb index 97f22453a..2875a0636 100644 --- a/lib/vagrant/provisioners/shell.rb +++ b/lib/vagrant/provisioners/shell.rb @@ -7,11 +7,13 @@ module Vagrant attr_accessor :inline attr_accessor :path attr_accessor :upload_path + attr_accessor :args def initialize @inline = nil @path = nil @upload_path = "/tmp/vagrant-shell" + @args = nil end def expanded_path @@ -64,7 +66,9 @@ module Vagrant end def provision! - commands = ["chmod +x #{config.upload_path}", config.upload_path] + args = "" + args = " #{config.args}" if config.args + commands = ["chmod +x #{config.upload_path}", "#{config.upload_path}#{args}"] with_script_file do |path| # Upload the script to the VM diff --git a/test/vagrant/provisioners/shell_test.rb b/test/vagrant/provisioners/shell_test.rb index ee5732b0d..af2ac090b 100644 --- a/test/vagrant/provisioners/shell_test.rb +++ b/test/vagrant/provisioners/shell_test.rb @@ -64,5 +64,16 @@ class ShellProvisionerTest < Test::Unit::TestCase @action.provision! end + + should "append arguments if provided" do + @config.args = "foo bar baz" + commands = ["chmod +x #{@config.upload_path}", "#{@config.upload_path} #{@config.args}"] + + p_seq = sequence("provisioning") + @action.vm.ssh.expects(:upload!).with(@config.expanded_path.to_s, @config.upload_path).in_sequence(p_seq) + @ssh.expects(:sudo!).with(commands).in_sequence(p_seq) + + @action.provision! + end end end