Method: Vagrant::Provisioners::Shell#provision!

Defined in:
lib/vagrant/provisioners/shell.rb

#provision!Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/vagrant/provisioners/shell.rb', line 79

def provision!
  args = ""
  args = " #{config.args}" if config.args
  command = "chmod +x #{config.upload_path} && #{config.upload_path}#{args}"

  with_script_file do |path|
    # Upload the script to the VM
    env[:vm].channel.upload(path.to_s, config.upload_path)

    # Execute it with sudo
    env[:vm].channel.sudo(command) do |type, data|
      if [:stderr, :stdout].include?(type)
        # Output the data with the proper color based on the stream.
        color = type == :stdout ? :green : :red

        # Note: Be sure to chomp the data to avoid the newlines that the
        # Chef outputs.
        env[:ui].info(data.chomp, :color => color, :prefix => false)
      end
    end
  end
end