Print message after booting vagrant machine with "vagrant up"

Roman Iuvshin picture Roman Iuvshin · Jun 13, 2015 · Viewed 16.1k times · Source

I need to display a message on the completion of the vagrant up command.

I've tried defining a function:

def hello
    puts 'hello'
end

And then calling it and the end of the file:

hello 

But it always prints at the beginning of the output rather than the end. How can I print a message at the end?

Answer

Cory Klein picture Cory Klein · Apr 27, 2016

Vagrant now has builtin support for a message to appear after vagrant up. Just add this to your Vagrantfile:

config.vm.post_up_message = "This is the start up message!"

And then after your VM has come up you'll see this message in green:

==> default: Machine 'default' has a post `vagrant up` message. This is a message
==> default: from the creator of the Vagrantfile, and not from Vagrant itself:
==> default:
==> default:     This is the start up message!