Updated Vagrantfile but still getting warning that my Vagrantfile is outdated - vagrant

I have updated my Vagrantfile to this:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.define :ceph do |ceph|
ceph.vm.box = "big-ceph"
ceph.vm.network :private_network, ip: "192.168.251.100"
ceph.vm.hostname = "ceph"
end
config.vm.define :client do |client|
client.vm.box = "hashicorp/precise64"
client.vm.hostname = "ceph-client"
client.vm.provision :shell, path: "setup/ceph.sh"
client.vm.network :private_network, ip: "192.168.251.101"
end
end
but I am still getting this warning message whenever I vagrant up my virtual machines.
calvin % vagrant reload ceph && vagrant reload client
There were warnings and/or errors while loading your Vagrantfile
for the machine 'ceph'.
Your Vagrantfile was written for an earlier version of Vagrant,
and while Vagrant does the best it can to remain backwards
compatible, there are some cases where things have changed
significantly enough to warrant a message. These messages are
shown below.
Warnings:
* `config.vm.customize` calls are VirtualBox-specific. If you're
using any other provider, you'll have to use config.vm.provider in a
v2 configuration block.
Any idea why?

Ok, I figured it out. This 3rd party ceph box that I am using comes with its own Vagrantfile which overrides my Vagrantfile and the included box Vagrantfile (which is located in ~/.vagrant.d/boxes/big-ceph) still contains
config.vm.customize ["modifyvm", :id, "--nictype1", "virtio"]
Comment that out and I no longer see the annoying warning.

Related

vagrant checksum error while installing linux-mint xfce desktop

VagrantFile:
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
config.vm.box = "zenshade/mint64-xfce-20"
config.vm.box_version = "1.0.0"
config.vm.hostname="master1"
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
vb.gui = true
#
# # Customize the amount of memory on the VM:
vb.memory = 1500
vb.cpus = 2
vb.name = "kube-master1"
if !File.exist?("disk/master1.vdi")
vb.customize [
'createhd',
'--filename', 'disk/master1',
'--format', 'VDI',
'--size', 20000
]
end
end
end
After running I am getting following error:
The checksum of the downloaded box did not match the expected
value. Please verify that you have the proper URL setup and that
you're downloading the proper file.
Expected: 5cdefeacdd0259ea666f1112211af306 package.box
Received: 5cdefeacdd0259ea666f1112211af306
I am not getting the reson behind the checksum error. I am trying to setup linux mint xfce desktop. How can I match the checksum value?
for this problem i think we have only one solution that update the checksum of your package on vagrant cloud to the Expected checksum.
Expected: 5cdefeacdd0259ea666f1112211af306 package.box
Received: 5cdefeacdd0259ea666f1112211af306

How to use aliases in Vagrant

I'm trying to create aliases that I can use in Vagrant any time I run the VM. I've found several sources on the web about it, but can't get it working. I tried making a .bash_profile in my synced folder, but that didn't work. I noticed if I run the command alias name="command" this will work, but only for the current session. Anyone know how to do this? I'm using macOS. Thanks for your help!
Here is my Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
unless Vagrant.has_plugin?("vagrant-vbguest")
warn "\nWARNING: The vagrant-vbguest plugin should be installed or your shared folders might not mount properly!"
warn "You can do this by running the command 'vagrant plugin install vagrant-vbguest'.\n\n"
end
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "pype_vm"
config.vm.box_url = "https://.../pype_vm.json"
config.vm.network "private_network", ip: ""
config.vm.boot_timeout = 600
config.vm.provider "virtualbox" do |v|
# This forces VirtualBox to use the host's DNS resolver instead of
# VirtualBox's
v.customize ["modifyvm", :id, "", "on"]
# This enables the PAE/NX option, which resolved at least one user's
# issues with the VM hanging on boot
v.customize ["modifyvm", :id, "--pae", "on"]
# The RHEL VM was created with 2GB of memory to facilitate provisioning,
# but this is causing issues with certain workstations. This reduces
# the amount of memory allocated to the VM but should not impact development
# performance. The number is in MB and can be increased if desired.
v.memory = 1024
end
# Share an additional folder to the guest VM.
config.vm.synced_folder File.dirname(__FILE__), "/pype"
end
The details depend on the specific of the guest being run, but some notes:
Assuming the default user account is active for vagrant ssh, ensure that any dotfiles you wish to override are copied to /home/vagrant.
If overriding .bashrc, ensure that the remote shell is started with the interactive flag (if this is true, echo $- will include i).
If overriding .bash_profile, ensure that the remote shell is started as a login shell (if this is true, echo $- will include l).

Vagrantfile packaged in box (via packer) is not used

I used packer to create a vagrant box for a workshop I am running, and packaged vagrantfile in the box via the vagrantfile_template directive in the Vagrant post-processor as shown:
...
"post-processors": [{
"type": "vagrant",
"vagrantfile_template": "vagrantfile_templates/workshop",
"compression_level": "{{user `compression_level`}}",
"output": "fedora-22-x86_64.box"
}],
...
The contents of the resulting .box are:
% tar -tf workshop.box
Vagrantfile
box.ovf
metadata.json
packer-fedora-22-x86_64-disk1.vmdk
The contents of Vagrantfile in the box seem OK, and include the contents of the vagrantfile_template specified in the packer configuration. Note that this Vagrantfile defines two VMs named client and server:
% tar -O -xf freeipa-workshop.box Vagrantfile
# The contents below were provided by the Packer Vagrant post-processor
Vagrant.configure("2") do |config|
config.vm.base_mac = "0800278AF3E8"
end
# The contents below (if any) are custom contents provided by the
# Packer template during image build.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "workshop"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.define "server" do |server|
server.vm.network "private_network", ip: "192.168.33.10"
server.vm.hostname = "server.ipademo.local"
end
config.vm.define "client" do |client|
client.vm.network "private_network", ip: "192.168.33.20"
client.vm.hostname = "client.ipademo.local"
end
end
I added the box to vagrant with the name workshop:
% vagrant box add --name workshop workshop.box
==> box: Adding box 'workshop' (v0) for provider:
box: Downloading: file:///.../workshop.box
==> box: Successfully added box 'workshop' (v0) for 'virtualbox'!
% vagrant box list
workshop (virtualbox, 0)
Problem description
When I execute vagrant init workshop and then vagrant up, the Vagrantfile included in the box is not applied:
% vagrant init workshop
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
% cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "workshop"
... and so on (the rest of the default Vagrantfile)
% vagrant up --provider virtualbox
Bringing machine 'default' up with 'virtualbox' provider...
...
Whoa! Why did it bring up default? According to the Vagrantfile docs the Vagrantfile packaged with the box should be used, and other Vagrantfiles including from the current directory should be merged into it. But this does not seem to be the case.
Vagrant 1.7.2 is the version in use.
I would like workshop participants to be able to bring up the VMs defined in the Vagrantfile included in the box, without supplying that Vagrantfile out of band (in order to minimise dependencies). Have I missed something important?
As all of us know, Vagrant loads and merges multiple Vagrantfiles in a pre-determined order outlined here (in the same section they also point out that multiple Vagrant.configure blocks are also OK).
I was experiencing the same very same issue when Vagrant would not pick up the config.vm.communicator = "winrm" configuration that was bundled in the .box using vagrantfile_template.
However, by Using vagrant --debug I noticed that Vagrant appeared to have cached the bundled Vagrantfile from a previous build of the same box:
INFO loader: Set :"26224240_win7sp1_x64_virtualbox" = ["#<Pathname:/home/thomas/.vagrant.d/boxes/win7sp1_x64/0/virtualbox/Vagrantfile>"]
One would think that vagrant destroy would remove the associated files in vagrant.d but it does not, so I was able to resolve the issue by manually removing ~/.vagrant.d/boxes/win7sp1_x64.
I confirmed that it now was working as intended by seeing that WinRM was indeed being used:
==> default: Waiting for machine to boot. This may take a few minutes...
default: WinRM address: 127.0.0.1:55985
default: WinRM username: vagrant
default: WinRM execution_time_limit: PT2H
default: WinRM transport: negotiate
==> default: Machine booted and ready!
Even though the Vagrantfile in the initialized directory did not have that configuration:
Vagrant.configure("2") do |config|
config.vm.box = "win7sp1_x64"
config.vm.box_url = "/media/data/VagrantBaseBoxes/win7sp1_x64/win7sp1_x64-virtualbox.box"
end
TL;DR:
Make sure no "old" Vagrantfiles are present in vagrant.d that may overwrite what's configured in the 'packer-ed box (see "load order and merging" in the link above).

vagrant Vagrantfile mount point ignored

I have a Vagrantfile as below running under libvirt. When the box boots, the project directory is mounted under "/vagrant" not "/path/to/source". It works fine on another machine under VirtualBox.
Any ideas? Symlinking /vagrant to the actual place I want the mount is hacky.
vagrant up --debug shows that it isn't even attempting it. The port forwarding works OK though.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "mybox"
file = File.open("#{Dir.home}/.mybox_key", "rb")
key = file.read
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.synced_folder "./", "/path/to/source/", type: "nfs"
end
If you're running an older version of Vagrant that doesn't support this option (e.g. 1.3.5), it may fail silently instead of trying to setup the NFS share. Ensure you're running at least Vagrant 1.5.1.

vagrant primary box defined but commands still run against all boxes

I am trying to set my "dev" VM as primary so most commands such as vagrant up, vagrant halt, etc operate on the "dev" VM and ignore the "stage" VM unless the "stage" VM name is explicitly listed on the command line. Here's my Vagrantfile, but when I run vagrant up both VMs are brought up instead of just "dev".
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
def box_setup(config, ip, playbook, inventory)
config.vm.network :private_network, ip: ip
config.vm.provision "ansible" do |ansible|
ansible.playbook = playbook
ansible.inventory_path = inventory
# ansible.verbose = "vvv"
end
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# common settings shared by all vagrant boxes for this project
config.vm.box = "debian-7-amd64"
config.vm.box_url = "https://dl.dropboxusercontent.com/s/xymcvez85i29lym/vagrant-debian-wheezy64.box"
config.ssh.forward_agent = true
# development box intended for ongoing development
config.vm.define "dev", primary: true do |dev|
box_setup dev, \
"10.9.8.30", "deploy/playbook_dev.yml", "deploy/hosts/vagrant_dev.yml"
end
# stage box intended for configuration closely matching production
config.vm.define "stage" do |stage|
box_setup stage, \
"10.9.8.31", "deploy/playbook_full_stack.yml", "deploy/hosts/vagrant_stage.yml"
end
end
The primary flag seems to only work for vagrant ssh for me.
In the past I have used the following method to hack around the issue.
# stage box intended for configuration closely matching production
if ARGV[1] == 'stage'
config.vm.define "stage" do |stage|
box_setup stage, \
"10.9.8.31", "deploy/playbook_full_stack.yml", "deploy/hosts/vagrant_stage.yml"
end
end

Resources