Override Vagrant configuration settings locally (per-dev)
I would suggest using environment variables to dynamically change the behavior of the Vagrantfile
without editing the file itself.
To give a real world example, here's how you could use an Ubuntu base box by default but have an environment variable define an alternative Linux distribution:
if ENV['OPERATINGSYSTEM']
if ENV['OPERATINGSYSTEM'].downcase == 'redhat'
os_name = 'centos'
config.vm.box = 'centos'
config.vm.box_url = 'https://dl.dropbox.com/u/7225008/Vagrant/CentOS-6.3-x86_64-minimal.box'
else
raise(Exception, "undefined operatingsystem: #{ENV['OPERATINGSYSTEM']}")
end
else
os_name = 'precise64'
config.vm.box = 'precise64'
config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
end
This example comes from https://github.com/puppetlabs/puppetlabs-openstack_dev_env
enabling gui in Vagrantfile settings
vm.boot_mode
is gone with Vagrant 1.1, but you can still use it if you enclose it in a V1 configuration block:
Vagrant.configure("1") do |config|
config.vm.boot_mode = :gui
end
Vagrant.configure("2") do |config|
# V2 Config...
end
Disable vagrant plugin execution
You can't deactivate plugin; so you need to look into the specific settings of the given plugin.
In the case of https://github.com/voxpupuli/vagrant-librarian-puppet you can't deactivate the plugin but you can tell it to look the Puppetfile into a directory where it will not be
Vagrant.configure("2") do |config|
config.librarian_puppet.puppetfile_dir = "directory_with_no_puppet_file"
end
Note: I have not tried it myself but looking the source it should be okay and will skip librarian provisioning
Is it possible to write vagrant config file in python?
No, it's not possible to write Vagrant config files in Python. The native language for Vagrant is Ruby, and that's the language the config files are written in.
The Vagrant docs explain this and point out that it's usually not a problem if you don't know Ruby:
The syntax of Vagrantfiles is Ruby, but knowledge of the Ruby
programming language is not necessary to make modifications to the
Vagrantfile, since it is mostly simple variable assignment. In fact,
Ruby isn't even the most popular community Vagrant is used within,
which should help show you that despite not having Ruby knowledge,
people are very successful with Vagrant.
If you are looking to use Python for the provisioning step, you could use the Shell provisioner and write your scripts in Python.
There are also some projects that can help use Vagrant in a Python-focused environment. For example: todddeluca/python-vagrant.
Vagrant adding extra parameters/options
Unfortunately, this seems to not be possible at this time, at least not simply. This answer seems to have a helpful suggestion, but still requires extra work in your Vagrantfile or provisioning config.
The only options available to the vagrant provision command are:
$ vagrant provision -h
Usage: vagrant provision [vm-name] [--provision-with x,y,z]
--provision-with x,y,z Enable only certain provisioners, by type.
--[no-]parallel Enable or disable parallelism if provider supports it.
-h, --help Print this help
What I do, instead, is edit the Vagrantfile while working on a specific feature (in my case, I use Ansible, and its tagging functionality to only run one set of plays (using tags)), and add in the argument I wish to pass within the provisioner definition block.
Increase memory of a particular vagrant box
You can easily do that by overriding the value for a specific VM
config.vm.define "puppetmaster" do |pm|
pm.vm.box = "centos/7"
pm.vm.network "private_network", ip: "192.168.33.10"
pm.vm.hostname = "puppetmaster"
pm.vm.provider "virtualbox" do |pmv|
pmv.memory = 4096
end
end
so your whole file becomes
Vagrant.configure("2") do |config|
config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
end
config.vm.define "puppetmaster" do |pm|
pm.vm.box = "centos/7"
pm.vm.network "private_network", ip: "192.168.33.10"
pm.vm.hostname = "puppetmaster"
pm.vm.provider "virtualbox" do |pmv|
pmv.memory = 4096
end
end
config.vm.define "puppet-agent-centos" do |pac|
pac.vm.box = "centos/7"
pac.vm.network "private_network", ip: "192.168.33.11"
pac.vm.hostname = "centos-agent"
end
config.vm.define "puppet-agent-ubuntu" do |pau|
pau.vm.box = "ubuntu/xenial64"
pau.vm.network "private_network", ip: "192.168.33.12"
pau.vm.hostname = "ubuntu-agent"
end
end
Related Topics
Heroku-18: Git Push Fails. Showing Different Versions of Ruby on Push
To_SQL Not Working on Update_Attributes or .Save
Attr_Accessor, Not Able to Access Property
Rails + Google Calendar API Events Not Created
Proc Throws Error When Used with Do End
How to Use Link_To with Ajax in Rails 3.2.1
Rails: How to Use Scope to Find an Element in Array of Arrays
Define a Class Method in a Module
Save Google Cloud Speech API Operation(Job) Object to Retrieve Results Later
Sum of All Amount If Charge Dates Are the Same in Stripe
Make a Ruby Script with Text Io Double Clickable Executable File
Using --No-Rdoc and --No-Ri with Bundler
Differencebetween 'Raise "Foo"' and 'Raise Exception.New("Foo")'
Practical Example of Architecture Using Ebc
Writing a Ruby Extension in Go (Golang)