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
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.
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.
I have this in my Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.provision "puppet"
end
Yet, when I run puppet --version I get :
[vagrant#vagrant-centos65 ~]$ puppet --version
-bash: puppet: command not found
Do I need to manually install puppet?
No, (at the moment) Vagrant doesn't install it automatically.
So you either need to use a basebox which already has it installed (Puppet Labs provides boxes too), or you need to install it yourself. Probably the easiest way to install is to use shell provisioner before the puppet provisioner(s).
In response to #tmatilai, I created this simple set up:
Vagrantfile:
Vagrant.configure(2) do |config|
config.vm.box = "centos6.5_64"
config.vm.provision "shell", path: "manifests/puppet.sh"
config.vm.provision "puppet"
end
manifest/puppet.sh:
echo "Adding puppet repo"
sudo rpm -ivh https://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-7.noarch.rpm
echo "installing puppet"
sudo yum install puppet -y
echo "ensure puppet service is running"
sudo puppet resource service puppet ensure=running enable=true
#echo "ensure puppet service is running"
#sudo puppet resource service puppetmaster ensure=running enable=true
echo "ensure puppet service is running for standalone install"
sudo puppet resource cron puppet-apply ensure=present user=root minute=30 command='/usr/bin/puppet apply $(puppet apply --configprint manifest)'
[vagrant#vagrant-centos65 home]$ puppet --version
3.4.2
If you want to use a plugin, I made one that will automatically install Puppet from a version given in the Vagrantfile:
Vagrant.configure("2") do |config|
config.puppet_install.puppet_version = :latest
end
This will also do a few cool tricks like make sure the puppet version you specify is a valid version and the like, full details here: https://github.com/petems/vagrant-puppet-install/
Yes. I'm not sure what the state of Vagrant was at the time of some of these other answers, but these days puppet does not have to be installed via a shell provisioner, as Vagrant has a support puppet provisioner built right in.
At the most basic level, you can make sure puppet is supported on your box by adding provision "puppet" or provision "puppet_server" to your `Vagrantfile. For example:
#open config block (already present in your templated Vagrantfile)
Vagrant.configure(2) do |config|
#...[snip]... other config.vm settings. Ex...
# Ubuntu 14.04 LTS version
#config.vm.box = "ubuntu/trusty64"
# Make puppet avail inside machine
config.vm.provision "puppet"
#close out Vagrant configuration for this instance
end
using puppet sets up puppet for local puppet apply (uses local manifests for configuring your machine), whereas using puppet_server hooks you up to a puppet master, and allows you to provision your vagrant box using a puppet server (a puppet master agent).
As a few other people have already answered, there is no 'standard' that ensures a vagrant box comes pre-installed with Puppet.
By design, a vagrant box could have 'anything' pre-installed on it. Or it could just as easily have 'nothing' at all pre-installed. It all depends on who created it and what they included in the process of setting up the box.
If you find that your machine doesn't have Puppet pre-installed on it, you could also use one of the scripts that Mitchell Hashimoto has put together. See the following project on GitHub for details...
https://github.com/hashicorp/puppet-bootstrap
At this point of time of writing, Vagrant does pre-installs puppet service. I ssh-ed into guest machine (used the box 'ubuntu/trusty64') and got following result :
vagrant#vagrant-ubuntu-trusty-64:~$ puppet --version
3.4.3
As stated by others it depends on the box. For instance ubuntu/trusty64 comes with puppet pre-installed whereas ubuntu/xenial64 does not.
So to fix this for Ubuntu ubuntu/xenial64 adding an inline shell provisioner before the puppet provisioner is enough:
config.vm.box = "ubuntu/xenial64"
config.vm.provision :shell, :inline => 'apt-get -y update; apt-get -y install puppet'
config.vm.provision :puppet do |puppet|
# ...
As of June 16 2016 Vagrant does NOT install puppet within the client VM as far as I can tell. I believe like it's sister project "packer" it expects you to do so explicitly. See: https://www.packer.io/docs/provisioners/puppet-masterless.html
Note: Puppet will not be installed automatically by this provisioner.
This provisioner expects that Puppet is already installed on the
machine. It is common practice to use the shell provisioner before the
Puppet provisioner to do this.
this worked for me:
put this inside your Vagrantfile - before your provisioning
$script = <<SCRIPT
echo I am installing puppet on guest
sudo apt-get install -yq puppet=*
SCRIPT
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: $script
end
This should install a puppet agent on the guest before you do other provisioning
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.