Class: VagrantPlugins::Rimu::Actions::ModifyProvisionPath
- Inherits:
-
AbstractAction
- Object
- AbstractAction
- VagrantPlugins::Rimu::Actions::ModifyProvisionPath
- Defined in:
- lib/vagrant-rimu/actions/modify_provision_path.rb
Instance Method Summary collapse
- #execute(env) ⇒ Object
-
#initialize(app, env) ⇒ ModifyProvisionPath
constructor
A new instance of ModifyProvisionPath.
Methods inherited from AbstractAction
Constructor Details
#initialize(app, env) ⇒ ModifyProvisionPath
Returns a new instance of ModifyProvisionPath.
9 10 11 12 13 |
# File 'lib/vagrant-rimu/actions/modify_provision_path.rb', line 9 def initialize(app, env) @app = app @machine = env[:machine] @logger = Log4r::Logger.new('vagrant::rimu::modify_provision_path') end |
Instance Method Details
#execute(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vagrant-rimu/actions/modify_provision_path.rb', line 15 def execute(env) # check if provisioning is enabled enabled = true enabled = env[:provision_enabled] if env.has_key?(:provision_enabled) return @app.call(env) unless enabled username = @machine.ssh_info()[:username] # change ownership of the provisioning path recursively to the # ssh user # @machine.config.vm.provisioners.each do |provisioner| cfg = provisioner.config path = cfg.upload_path if cfg.respond_to? :upload_path path = cfg.provisioning_path if cfg.respond_to? :provisioning_path @machine.communicate.sudo("chown -R #{username} #{path}", :error_check => false) end @app.call(env) end |