View Vagrant provision log other than STDOUT?

1,331 views
Skip to first unread message

Jean Mertz

unread,
Oct 6, 2013, 4:33:49 AM10/6/13
to vagra...@googlegroups.com

I was wondering if it's possible to view (and parse) the vagrant log of the last (provision) run, to act upon specific output in that log?

In my use case, I have the following shell script:

#!/bin/sh

vagrant status | grep -q 'running'

if [ "$?" == '1' ]; then
  vagrant up
  exec vagrant snapshot take "${PWD##*/}-$(date +%s)"
fi

vagrant provision

if [ "$?" == '0' ]; then
  sleep 1
  exec vagrant snapshot take "${PWD##*/}-$(date +%s)"
else
  exec vagrant snapshot back
fi

I'd like to be able to parse the provision log to see if any Chef recipe updated something on the node, if not, no new snapshot will be taken. (I use a Chef report handler to print this data in the Chef log output).

This shell script is being run on the host machine, so (to my knowledge) I don‘t have direct access to the Chef log output, other than through Vagrant’s log.

anatoly techtonik

unread,
Oct 30, 2014, 1:29:28 AM10/30/14
to vagra...@googlegroups.com

On Sunday, October 6, 2013 11:33:49 AM UTC+3, Jean Mertz wrote:

I was wondering if it's possible to view (and parse) the vagrant log of the last (provision) run

+1

Shawn Neal

unread,
Oct 30, 2014, 1:52:43 PM10/30/14
to vagra...@googlegroups.com
Assuming you're already writing the Chef output to a log file, just ensure the log is put into the /vagrant folder on the guest. This folder is already mapped back to the host machine in the same directory as your Vagrantfile.

anatoly techtonik

unread,
Oct 30, 2014, 2:06:38 PM10/30/14
to vagra...@googlegroups.com
And I am not using Chef.
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Vagrant" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/vagrant-up/wiePEohrmmo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> vagrant-up+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
anatoly t.

Shawn Neal

unread,
Oct 30, 2014, 4:16:03 PM10/30/14
to vagra...@googlegroups.com
@anatoly The original poster was using Chef, what is it you're doing?

anatoly techtonik

unread,
Oct 30, 2014, 4:27:59 PM10/30/14
to vagra...@googlegroups.com
I am running some bash scripts during provisioning that invoke
makefiles that fetch and build a lot of things producing lots of
output.

Alvaro Miranda Aguilera

unread,
Oct 30, 2014, 8:28:05 PM10/30/14
to vagra...@googlegroups.com
you can test something like

"make | tee -a /vagrant/output_blabla.log"

I do a lot of test on LXC, so I did a step.sh script


so I can run step.sh what_i_want 

and the log goes to what_i_want.log / err

replace '>>' with ' | tee -a' and you could have both, console and log


Alvaro.

You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.

anatoly techtonik

unread,
Oct 31, 2014, 5:08:47 AM10/31/14
to vagra...@googlegroups.com
Workaround is possible and I can redirect the stuff, but it is ugly.
If vagrant, as a automation tool, could preserve last for logs, for
example, like VirtualBox does, maybe even with huge buffering,
that would save a time.
Reply all
Reply to author
Forward
0 new messages