Reputation: 24287
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?
Upvotes: 16
Views: 10786
Reputation: 3339
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).
Upvotes: 4
Reputation: 3893
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|
# ...
Upvotes: 2
Reputation: 3822
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
Upvotes: 0
Reputation: 607
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.
Upvotes: 0
Reputation: 1087
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
Upvotes: 4
Reputation: 783
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
Upvotes: 2
Reputation: 5200
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/
Upvotes: 6
Reputation: 24287
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
Upvotes: 7
Reputation: 4176
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).
Upvotes: 18