Provisioners in Vagrant allow you to automatically install software, alter configurations, and more on the machine as part of the vagrant up process. Vagrant gives you multiple options for provisioning the machine, from simple shell scripts to more complex, industry-standard configuration management systems.
Questions tagged [vagrant-provision]
210 questions
40
votes
4 answers
Vagrant execute script or command after every guest restart (vagrant up)
I know about the provisioning script, but this is a different script that I am asking about. I want a script to be executed after every restart of the guest.
I am using shell provisioner.
config.vm.provision :shell, path: "vagrant/bootstrap.sh"
I…

Pranav Shukla
- 2,206
- 2
- 17
- 20
25
votes
5 answers
Is it possible to restart a machine when provisioning a machine using Vagrant and pickup where the script left off?
I was reading a tutorial in bash where they said to restart the machine, there was no option to restart a service directly, it was a matter of restarting the machine, and then there were more commands after that that still needed to be run when…

leeand00
- 25,510
- 39
- 140
- 297
15
votes
2 answers
Importing/adding a yum .repo file using Ansible
I'm trying to install MariaDB (or any software) from a custom repository using Ansible but I am not sure how to import the .repo file using the yum/yum_repository modules.
Ansible
Here is my playbook:
-
hosts: all
become: true
…

rink.attendant.6
- 44,500
- 61
- 101
- 156
15
votes
6 answers
Best way to install docker on Vagrant
I want to create several VMs that have docker pre-installed.
What is the best/recommended way to go about this?
a) Have Docker provisioner do something dummy, just so that Docker gets installed, e.g.
mymachine.vm.provision "docker" do |docknode|
…

pkaramol
- 16,451
- 43
- 149
- 324
12
votes
2 answers
Connection Refused in Vagrant using WSL 2
I am trying WSL 2, also trying Vagrant on it. I used it in Ubuntu 20.04 and it is working properly, but now i am facing problem here in WSL 2 in Windows 10. My Problem might be about SSH problem on WSL, seems 127.0.0.1:222 cannot connect into the…

Jason Miguel
- 177
- 1
- 3
- 17
11
votes
1 answer
Vagrant provision — dpkg-preconfigure: unable to re-open stdin
I am writing a provision script for Vagrant to install all the packages necessary for deploying an app developed with Meteor 1.6. So far, the script is working well, but at three points during its execution, I get the following output in red in the…

James Newton
- 6,623
- 8
- 49
- 113
8
votes
2 answers
Vagrant: multiple playbooks for ansible provisioner
Is it possible / valid to run more than one playbooks for a vagrant ansible provisioner in the following form:
config.vm.define "repo", primary: true do |d|
d.vm.hostname = "some.hostname"
# Create a private network, which allows host-only…

pkaramol
- 16,451
- 43
- 149
- 324
7
votes
3 answers
Pass vault password to vagrants ansible_local provisioner
I'm using the ansible_local provisioner for my vagrant box. Some of my variables should be stored in a vault file.
While the ansible provisioner provides ask_vault_pass as configuration option…

turbophi
- 151
- 2
- 8
6
votes
0 answers
How to specify network when provisioning in vagrant
I have multiple networks specified in my vagrantfile and only one of them are accessible from outside. When the vagrant starts provisioning, sometimes it chooses the wrong network (IP) to connect to the VM and it fails. Is it possible to specify…

Teymur
- 63
- 7
6
votes
3 answers
Use Vagrant trigger to execute bash script on host
I use Vagrant to start my testing environment. Sadly I have to retrieve information (passwords) before spinning up my Vagrant box. So far I use Vagrant-Triggers to do this and have multiple run "do something" commands.
IS
[:up, :provision].each do…

lony
- 6,733
- 11
- 60
- 92
6
votes
2 answers
What is the difference between a Vagrant Provider and a Vagrant Provisioner?
I think the words "Provider" and "Provisioner" sound very similar which may lead to confusion especially among beginners confronted with documentation where both terms are mixed up or used synonymous (already seen on the net). Even more confusing it…

Wlad
- 2,866
- 3
- 28
- 42
5
votes
1 answer
vagrant /etc/hosts: machine IP vs localhost
I have a vagrant machine setup with this IP address:
Vagrant.configure("2") do |config|
config.vm.network :private_network, ip: 192.168.33.11
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.hostname =…

numediaweb
- 16,362
- 12
- 74
- 110
5
votes
1 answer
Increase memory of a particular vagrant box
I have this Vagrantfile. Here I defined the memory to be 2048 for all VMs. But I want my puppet master to have 4096 and agents to have 2048. How to do that?
Vagrant.configure("2") do |config|
config.vm.synced_folder ".", "/vagrant", type:…

awwwd
- 121
- 2
- 9
5
votes
1 answer
How to template Vagrantfile using Ruby?
I have several Vagrantfile, each one for a different provider, since Vagrant has a limitation that doesn't allow to make two or more provisions at the same time using the same Vagrantfile.
So, I split into two or more Vagrantfiles, but my "body", my…

Valter Silva
- 16,446
- 52
- 137
- 218
5
votes
1 answer
Vagrant not installing pip during provision
Here is my bootstrap.sh:
#!/usr/bin/env bash
apt-get update
apt-get install -y apache2
apt-get install python-pip
if ! [ -L /var/www ]; then
rm -rf /var/www
ln -fs /vagrant /var/www
fi
Here is my Vagrantfile:
Vagrant.configure("2") do…

testing
- 2,303
- 4
- 20
- 32