How to start mailcatcher when booting vagrant box - vagrant

I need to start the mailcatcher as the vagrant up is done.
I tried setting provision for the vagrant machine
config.vm.provision "shell", inline: 'mailcatcher --ip=0.0.0.0'
But it says unidentified command mailcatcher

MailCatcher has to be started via /usr/bin/env mailcatcherso
config.vm.provision "shell", inline: '/usr/bin/env mailcatcher --ip=0.0.0.0'
should work.

Related

apt-get command not found in Vagrant/Window

When I run vagran up command, I get the error apt-get command not found in vagrant, my pc is using window-10.
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# VM Box
config.vm.box = "centos-7"
config.vm.network "private_network", ip: "192.168.33.100"
config.vm.provider "virtualbox" do |vb|
vb.memory = 2048
vb.cpus = 4
end
config.vm.provision "shell", path: "bootstrap.sh"
end
bootstrap.sh
sudo apt-get update
sudo apt-get apgrate
sudo apt-get install -y git
you're using a centos box
config.vm.box = "centos-7"
so you should use the yum package manager, apt is used for ubuntu family and is not compatible with the other os family (Debian vs Fedora)
To install git on centos replace your bootstrap script by
yum update
yum install -y git
Have you tried using yum and trying $ vagrant box update? Also, you can get more in depth logs by using $ vagrant up --debug or if you would like to save it to a file $ vagrant up --debug &> vagrant.log. I always recommend doing some VM house keeping as well by making sure all VMs are stopped then run $ vagrant reload --provision on the VM having the issues. As always, the best part of using Vagrant is the ability to wipe it and start over again.

make it so vagrant doesn't run apt-get update automatically

When I do vagrant up on a new machine it tries do a sudo apt-get update before it runs of the provisioning lines. It appears that the process still exists however.
My Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "scotch/box"
config.vm.box_version = "1.5.0"
config.vm.box_check_update = false
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.hostname = "vagrant"
config.vm.provision "shell", inline: <<-SHELL
apt-get -y install pdftk
SHELL
end
The problem is that some of the APT repos are returning 404's. This is causing output to stderr which appears to be preventing the shell provisioner winds up not running. Doing vagrant halt and then vagrant up a second time seems to do the trick but I'd rather not have to do 3x commands when 1x could be sufficient.
Anyway ideas how to disable this behavior?
Here's the output when I do vagrant up after doing vagrant destroy:
https://pastebin.com/4Hh49J7c
The errors in the logs are due to the vagrant vbguest plugin. This plugin will need to install the guest additions package for virtualbox matching your version and to do so some apt-get update are run.
You can disable this if this is causing issues during the creation of your VM
Vagrant.configure("2") do |config|
config.vbguest.auto_update = false
end
If you later want to align the version between virtualbox and the guest addition (this is recommended) you can run the following command
$ vagrant vbguest install

Provision script in Laravel/Homestead

I wonder how I can include a provision script in Laravel/Homestead that should execute each time the Homestead VM is up.
As a hint, I used to work with Vagrant in following way,
config.vm.provision :shell, path: "bootstrap.sh"
where the bootstrap.sh file is my provision script.
You can always manually force a provision with either vagrant provision or vagrant reload --provision.
To make a every vagrant up automatically call the provisioner then simply define it in your Vagrantfile like so:
Vagrant.configure("2") do |config|
config.vm.provision :shell, path: "bootstrap.sh",
run: "always"
end
You can then choose to not run the provisioner by using the vagrant up --no-provision.
The Vagrant docs on this go into a little more detail about what else you can do with provisioners.

Vagrant with docker provisioning

I am new to docker and vagrant. I installed vmbox and vagrant in my ubuntu 14.04 machine.
I did "git clone https://github.com/dotcloud/docker.git" to get the docker repository. I have also added precise64 from vagrant successfully.
From docker directory i tried "vagrant up". But it told me to do "vagrant init" first. So I did "vagrant init precise64". After doing "vagrant ssh" there is no docker inside the precise64 vm. How can I make sure that docker is installed already in precise64 on startup?
PS: vagrantfile is not allowing " config.vm.provision "docker" "
The following Vagrantfile will get you a VM with docker ready to go:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "phusion/ubuntu-14.04-amd64"
config.vm.hostname = "dockerhost"
config.vm.provision "shell", inline: <<-SCRIPT
curl -sL https://get.docker.io/ | sh
curl -sL https://raw.githubusercontent.com/dotcloud/docker/master/contrib/completion/bash/docker > /etc/bash_completion.d/docker
adduser vagrant docker
SCRIPT
end
EDIT :
Even easier, you can now use Docker Toolbox to get up and running.
You might be using old version of vagrant.
config.vm.provision "docker" work only with vagrant 1.6.5 .
Try upgrading your vagrant to 1.6.5. It will resolve the issue.
Upgrading the Vagrant to 1.6.5 resolves the issue.

Vagrant multi machine not running global settings

I am very new to vagrant so apologies in advance for what I am sure is really obvious.
I am trying to write a vagrant file to support multiple machines. As a test I started with a very basic file:
Vagrant::configure("2") do |config|
# Use a standard box
config.vm.box = 'precise64'
config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
# Set the Timezone to something useful
config.vm.provision :shell, :inline => "echo \"Europe/London\" | sudo tee /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata"
# Update the servers
config.vm.provision :shell, :inline => "apt-get update --fix-missing"
end
This worked as expected, timezone set, updates run. So, I then went ahead with the following:
Vagrant::configure("2") do |config|
# Use a standard box
config.vm.box = 'precise64'
config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
# Set the Timezone to something useful
config.vm.provision :shell, :inline => "echo \"Europe/London\" | sudo tee /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata"
# Update the servers
config.vm.provision :shell, :inline => "apt-get update --fix-missing"
config.vm.define :lamp do |lamp|
lamp.vm.hostname = "lamp.local"
lamp.vm.network :private_network, ip: "33.33.33.10"
#lamp.vm.provision :shell, :inline => "apt-get update --fix-missing"
end
end
Unfortunately, this did not work. The box came up fine, but timezone not set, updates not run or ip set. the commented line for apt-get update was also tried with no luck.
Must be something simple I am sure. Through reading the documentation, global settings should also be applied.. I guess I need to understand why they arent.
Thanks
Adam
With Vagrant 1.3.0, vagrant up no longer does provisioning after the first (if you use vagrant halt or vagrant reload).
So you may want to try doing vagrant destroy before vagrant up again. There was a bug in 1.3.2 that didn't make vagrant destroy do reprovisioning, but fixed in the next version (1.3.3).
Or you may try executing it manually vagrant provision or vagrant up --provision.

Resources