emyl / vagrant-triggers

Allow the definition of arbitrary scripts that will run on the host before and/or after Vagrant commands.
MIT License
546 stars 35 forks source link

vagrant-triggers and vagrant 1.97 errors out with stdout is not a tty #86

Closed iguyking closed 6 years ago

iguyking commented 7 years ago

Windows 10 Vagrant 1.9.7

Running a vagrant up gives error of "stdout is not a tty" with a vagrant trigger on up action.

Vagrantfile:
   ---
# -*- mode: ruby -*- 
# vi: set ft=ruby : 
# Every Vagrant development environment requires a box. You can search for # boxes at https://atlas.hashicorp.com/search. 

BOX_IMAGE = "centos/7 

Vagrant.configure("2") do |config|   

    config.vm.define "service" do |subconfig|       
        subconfig.vm.box = BOX_IMAGE       
        subconfig.vm.hostname = "service"       
        subconfig.vm.network :private_network, ip: "192.168.210.51"    
        subconfig.trigger.after :up, :stdout => false do
            as1 = %q(vagrant ssh service -c "ip a s eth1 | grep 'inet ' | awk '{print $2}' | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'")
            @logger.debug "Running `#{as1}`"
            output = `#{as1}`.strip
            puts "==> #{@machine.name}: Got eth1 IP of #{output}"
        end
    end
end

marcelo2605 commented 7 years ago

@iguyking Same error here. Did you found a solution?

iguyking commented 7 years ago

Not yet. I think there's an incompatibility with the vagrant updates. My workaround was to use 1.9.5.

marcelo2605 commented 7 years ago

My too. Thanks.

Borvik commented 7 years ago

I was having a similar issue - but solved it. Old syntax from my vagrantfile:

config.trigger.after :up, :stdout => true, :force => true do
  run "vagrant ssh -c 'vagrant_up'"
end

New working sytanx:

config.trigger.after :up, :stdout => true, :force => true do
  system("vagrant ssh -c 'vagrant_up'")
end