Vagrant provisioning script is not being copied to host location - vagrant

Host: Windows 7
Guest: Windows 8
I have a simple Vagrantfile that runs a powershell script to provision the guest. When I packaged the box, I saw that the file was added, but when I run vagrant up I get the error shell provisioner:* `path` for shell provisioner does not exist on the host system: D:/VirtualMachines/test/provision.ps1
I verified that provision.ps1 exists in the vagrant box location under the include directory.
So why isn't provision.ps1 getting copied to the location it needs to when i run vagrant up?
Vagrant file:
VAGRANTFILE_API_VERSION = "2"
modified_name = ENV["COMPUTERNAME"][0..12]
comp_name = modified_name + "TA"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "base"
config.vm.hostname = comp_name
config.vm.communicator = "winrm"
config.vm.network "forwarded_port", host: 3389, guest: 3389, auto_correct: true
config.vm.provision "shell", path: "provision.ps1"
end

The answer at How to package files with a Vagrant box? helped me.
Here is how I got it to work:
config.vm.provision "shell" do |s|
p = File.expand_path("../", __FILE__)
s.path = p + "\\provision.ps1"
end

I had the same problem with Vagrant 1.8.1 on host Windows 8. After reading https://github.com/fideloper/Vaprobash/issues/30 I just renamed bootstrap.sh to bootstrp.sh, tried again and it worked. After renaming bootstrp.sh to bootstrap.sh it still worked.
I suppose in my case there was some strange invisible character in the filename.

Related

vagrant private network fails to resolve on windows 10 host

I can't get anything to work. I have windows 10 as my host and my guest VM is centos/7 box. It works great with forwarded_ports but using private_network setting nothing resolves. I'm not sure what to do or check
vagrant file look like
Vagrant.configure("2") do |config|
config.vm.box = "bento/centos-7.4"
config.vm.synced_folder "./website", "/var/www/html/", :mount_options => ["dmode=777", "fmode=777"], owner: "apache", group: "apache"
config.vm.network "private_network", ip: "192.168.50.4"
## Bootstrap script to provision box. All installation methods can go here.
config.vm.provision "shell" do |s|
s.path = "bootstrap.sh"
end
end
My ifconfig on guest looks like
My virtualbox shows two adapters
I get nothing when I browse to the IP on windows
It actually had nothing to do with vagrant. It was all set up correctly, but my magento site had a weird error. Thanks to Frederic for taking the time!

Vagrant Vagrantfile config

I have this vagranfile for box "centos/7"
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network :private_network, ip: "192.168.33.10"
config.vm.synced_folder ".", "/home/vagrant"
config.vm.provision "shell", path: "./conf/bitrix-env.sh"
config.vm.boot_timeout = 100
config.vm.provider :virtualbox do |vb|
vb.gui = true
vb.memory = "1024"
end
end
vagrant up - command works clear, but scripts in provision don't install
after i tried to start vagrant provision, but had an error:
SSH is getting permission denied errors when attempting to connect
to the IP for SSH. This is usually caused by network rules and not being
able to connect to the specified IP. Please try changing the IP on
which the guest machine binds to for SSH.
How can i fix this and install all provisions?
The problem is due to the below line in your vagrantfile
config.vm.synced_folder '.', '/home/vagrant'
The authorized_keys file for the vagrant user is located in /home/vagrant/.ssh inside the vagrant machine, which enables to ssh into the vagrant box.
As you are mounting your current directory to /home/vagrant, all the contents of /home/vagrant are over-written and there is no authorized key file.
Change the mount path to anything except /home/vagrant, and you will able to ssh into the machine. As example
config.vm.synced_folder '.', '/home/vagrant/somepath'

I am trying to setup the vagrant environment but this error occurs default: VM not created. Moving on

I am working on to setup the vagrant environment on the mac. I have done the following steps.
Installed the virtualbox
Clone my project to local disk
Downloaded the box and added the box successfully
I have also edit the vagrant file and add the name of box to the vagrant file.
Now when i run the command "vagrant provision" this error occurs
default: VM not created. Moving on...
I have google it a lot but no idea that what to do.
sudo vagrant box list
Result:
bpc_box (virtualbox, 0)
new_box (virtualbox, 0)
Vagrant file
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bpc_box"
config.vm.synced_folder "workspace/", "/vagrant"
config.vm.network "forwarded_port", guest: 8080, host: 8085
config.vm.network "forwarded_port", guest: 80, host: 8090
config.vm.provider "virtualbox" do |vb|
vb.cpus = 2
vb.memory = 2048
end
config.vm.provider "parallels" do |prl|
prl.cpus = 2
prl.memory = 2048
end
config.ssh.forward_agent = true
config.vm.provision "ansible" do |ansible|
ansible.playbook = "provisioning/main.yml"
end
end
You need to spin the VM first, the first command to run is
$ vagrant up
this will bring your VM up and provision it if this is the first time this particular VM has been started.
once the VM is up and running you can run vagrant provision to force the (re)provisioning of the running VM.
You can read more about vagrant cli option at https://www.vagrantup.com/docs/cli/

Access django server in vagrant virtualbox on host machine?

I am using windows and putty to ssh to vagrant virtualbox.I cannot access the django server running in vagrant virtualbox using http://localhost:9991
I have disabled my firewall as well
here's my vagrant file:
VAGRANTFILE_API_VERSION = "2"
def command?(name)
`which #{name}`
$?.success?
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# For LXC. VirtualBox hosts use a different box, described below.
config.vm.box = "fgrehm/trusty64-lxc"
# The Zulip development environment runs on 9991 on the guest.
config.vm.network "forwarded_port", guest: 9991, host: 9991, host_ip: "127.0.0.1"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/srv/zulip"
# Specify LXC provider before VirtualBox provider so it's preferred.
config.vm.provider "lxc" do |lxc|
if command? "lxc-ls"
LXC_VERSION = `lxc-ls --version`.strip unless defined? LXC_VERSION
if LXC_VERSION >= "1.1.0"
# Allow start without AppArmor, otherwise Box will not Start on Ubuntu 14.10
# see https://github.com/fgrehm/vagrant-lxc/issues/333
lxc.customize 'aa_allow_incomplete', 1
end
end
end
config.vm.provider "virtualbox" do |vb, override|
override.vm.box = "ubuntu/trusty64"
# 2GiB seemed reasonable here. The VM OOMs with only 1024MiB.
vb.memory = 2048
end
$provision_script = <<SCRIPT
set -x
set -e
sudo apt-get update
sudo apt-get install -y python-pbs
/usr/bin/python /srv/zulip/provision.py
SCRIPT
config.vm.provision "shell",
# We want provision.py to be run with the permissions of the vagrant user.
privileged: false,
inline: $provision_script
end
How do i access the server from host(Windows)?
I would suggest (on the Guest):
sudo netstat -lnutp
and having a look at what ports are open, and the process which owns them. If the one you want is missing, make sure the service which is responsible for it has been started, or start it yourself. From the looks of your Vagrantfile, this would be the "Zulip development environment".

Vagrant 'permission denied' on Windows

I am having trouble accessing files through Vagrant on Windows. I have been using it on OS X for quite some time and have my Vagrantfile setup correctly which works every time.
I have sent my colleague the same Vagrant file, he is on Windows and receives 'Permission Denied' when trying to access files through the browser.
Just to be clear, the permission errors are returned by the server when accessing 'dev.local' in the browser and not from Vagrant itself... it will be a configuration error on Windows or within the VM.
The VM is CentOS 6.5
Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "chef/centos-6.5"
config.vm.network "private_network", ip: "192.168.33.21"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.provision :shell, :path => "install.sh"
config.vm.hostname = "dev.local"
config.vm.synced_folder ".", "/home", id: "vagrant", :nfs => false, :mount_options => ["dmode=777","fmode=777"]
config.ssh.insert_key = false
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
end
Can any Windows Vagrant users shed any light on this?
It was VBGuestAdditions out of date. The permission error was caused by not being able to sync to my local folder (which contained an index.php) so it was using the servers /home folder which didn't contain anything and since viewing directory structure is disabled it returned permission errors.
I had 4.X.X installed, and VirtualBox is on 5.X.X Here is the fix:
run command: vagrant plugin install vagrant-vbguest
the run vagrant up which may still throw an error as the plugin fails to copy a file.
vagrant ssh to get into the box and run the following command:
sudo ln -s /opt/VBoxGuestAdditions-5.X.X/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions
Replace 5.X.X with the version of your VirtualBox.
logout and run vagrant reload
do a happy dance

Resources