Class: VagrantPlugins::GuestAnsible::Provisioner
- Inherits:
-
Object
- Object
- VagrantPlugins::GuestAnsible::Provisioner
- Defined in:
- lib/vagrant-guest_ansible/provisioner.rb
Instance Method Summary collapse
-
#initialize(machine, config) ⇒ Provisioner
constructor
A new instance of Provisioner.
- #provision ⇒ Object
Constructor Details
#initialize(machine, config) ⇒ Provisioner
Returns a new instance of Provisioner.
5 6 7 |
# File 'lib/vagrant-guest_ansible/provisioner.rb', line 5 def initialize(machine, config) super end |
Instance Method Details
#provision ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/vagrant-guest_ansible/provisioner.rb', line 9 def provision args = [ config.playbook, File.basename(self.setup_inventory_file), format_extra_vars(config.extra_vars) ].join(' ') command = "chmod +x #{config.upload_path} && #{config.upload_path} #{args}" with_script_file do |path| # Upload the script to the machine @machine.communicate.tap do |comm| # Reset upload path permissions for the current ssh user user = @machine.ssh_info[:username] comm.sudo("chown -R #{user} #{config.upload_path}", :error_check => false) comm.upload(path.to_s, config.upload_path) @machine.ui.info(I18n.t("vagrant.provisioners.shell.running", script: path.to_s)) # Execute it with sudo comm.execute(command, sudo: config.sudo) do |type, data| if [:stderr, :stdout].include?(type) # Output the data with the proper color based on the stream. color = type == :stdout ? :green : :red = { new_line: false, prefix: false, } [:color] = color if !config.keep_color @machine.env.ui.info(data, ) end end end end end |