Vagrant Vagrantfile config - vagrant

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'

Related

How to sync directory within Vagrant box (virtualbox provider) with local directory?

I have used the vagrantfile provided in this here tutorial and can't seem to get my local files synced to the VM. I tried mkdir vagrant_data and that didn't show them in there. What do I do?
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.synced_folder "./", "/vagrant_data"
config.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = "2048"
end
I believe you may be giving the wrong file path of the host machine. Instead of giving the ./ relative path which could refer to anything. Try using the absolute path instead. Here if the Official tutorial on how to configure.

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/

How to rdp into win2012r2 VM with vagrant but not log into a windows account?

Is there a way to power on and rdp into a windows box with vagrant but not log in to a windows account?
After I vagrant rdp I want to land on the windows login screen where I can select an account and enter a password. Is this possible?
Thank you very much for your time. Please let me know if you need any additional information or if I am being unclear.
My Vagrantfile
#Vagrant 1.6+ natively supports Windows guests over WinRM.
Vagrant.require_version ">= 1.6"
Vagrant.configure("2") do |config|
config.vm.box = "opentable/win-2012r2-standard-amd64-nocm"
config.vm.communicator = "winrm"
config.vm.network :private_network, ip: "192.168.33.7"
config.vm.network "forwarded_port", host: 33389, guest: 3389
config.vm.synced_folder ".", "/vagrant"
config.vm.provider :virtualbox do |v|
v.name = "win_test"
v.cpus = 2
v.memory = 2048
end
end
And command vagrant rdp brings prompt with logon where I type vagrant for login and password and get into guest.

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".

bosh-lite vagrant up fails with no error

I am trying to setup a local cloud foundry instance using bosh-lite on my mac osx laptop V 10.9.4.
sh-3.2# vagrant -v
Vagrant 1.7.1
sh-3.2#
I unzipped the contents of bosh-lite-master
ran the following command
see below
sh-3.2#vagrant up --provider=virtualbox
Error Message I got
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'cloudfoundry/bosh-lite' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: 2776
The box 'cloudfoundry/bosh-lite' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:
URL: ["https://atlas.hashicorp.com/cloudfoundry/bosh-lite"]
Error:
sh-3.2#
The error part is empty and I am completely clue less as this is the first time I am working with vagrant
Content of the vagrant file
Vagrant.configure('2') do |config|
config.vm.box = 'cloudfoundry/bosh-lite'
config.vm.box_version = '2776'
config.vm.provider :virtualbox do |v, override|
# To use a different IP address for the bosh-lite director, uncomment this line:
# override.vm.network :private_network, ip: '192.168.59.4', id: :local
end
[:vmware_fusion, :vmware_desktop, :vmware_workstation].each do |provider|
config.vm.provider provider do |v, override|
# To use a different IP address for the bosh-lite director, uncomment this line:
# override.vm.network :private_network, ip: '192.168.54.4', id: :local
override.vm.box_version = '388'
end
end
config.vm.provider :aws do |v, override|
# To turn off public IP echoing, uncomment this line:
# override.vm.provision :shell, id: "public_ip", run: "always", inline: "/bin/true"
# To turn off CF port forwarding, uncomment this line:
# override.vm.provision :shell, id: "port_forwarding", run: "always", inline: "/bin/true"
end
end
Please read https://github.com/mitchellh/vagrant/issues/3589
commenting out this block from /opt/vagrant/embedded/gems/gems/vagrant-1.7.1/lib/vagrant/util/subprocess.rb made it work like a charm
if #command[0].downcase.include?(installer_dir)
#logger.info("Command in the installer. Specifying DYLD_LIBRARY_PATH...")
process.environment["DYLD_LIBRARY_PATH"] =
"#{installer_dir}/lib:#{ENV["DYLD_LIBRARY_PATH"]}"
#logger.info("process.environment")
#logger.info(process.environment["DYLD_LIBRARY_PATH"])
#logger.info("end process.environment")
else
#logger.debug("Command not in installer, not touching env vars.")
end

Resources