Sha256: 11cf89a4d5cc150ddcbed0edd056eb0897beeb7c0580521cc8e5225b24af7953
Contents?: true
Size: 1.3 KB
Versions: 31
Compression:
Stored size: 1.3 KB
Contents
module Vagrant module Provisioners class Shell < Base register :shell class Config < Vagrant::Config::Base attr_accessor :path attr_accessor :upload_path def initialize @upload_path = "/tmp/vagrant-shell" end def expanded_path Pathname.new(path).expand_path(env.root_path) if path end def validate(errors) super if !path errors.add(I18n.t("vagrant.provisioners.shell.path_not_set")) elsif !expanded_path.file? errors.add(I18n.t("vagrant.provisioners.shell.path_invalid", :path => expanded_path)) end if !upload_path errors.add(I18n.t("vagrant.provisioners.shell.upload_path_not_set")) end end end def provision! commands = ["chmod +x #{config.upload_path}", config.upload_path] # Upload the script to the VM vm.ssh.upload!(config.expanded_path.to_s, config.upload_path) # Execute it with sudo vm.ssh.execute do |ssh| ssh.sudo!(commands) do |ch, type, data| if type == :exit_status ssh.check_exit_status(data, commands) else env.ui.info(data) end end end end end end end
Version data entries
31 entries across 31 versions & 5 rubygems