Skip to content

Instantly share code, notes, and snippets.

@e-minguez
Created July 22, 2015 13:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e-minguez/c217447b75d775cc16f1 to your computer and use it in GitHub Desktop.
Save e-minguez/c217447b75d775cc16f1 to your computer and use it in GitHub Desktop.

~/.bashrc

Just configure a few default variables to store vagrant images in a custom path, and set libvirt as default provider

# Vagrant stuff
export VAGRANT_DEFAULT_PROVIDER=libvirt
export VAGRANT_HOME=/storage/vagrant

${VAGRANT_HOME}/Vagrantfile

Create a default Vagrantfile that will be "included" on each vagrant up command, and set the default user/pass, libvirt stuff,...

Vagrant.configure(2) do |config|

  # Red Hat Access data
  config.registration.username = 'user'
  config.registration.password = 'password'

  config.vm.provider "libvirt" do |libvirt|
    libvirt.driver = "kvm"
    libvirt.uri = "qemu:///system"
    libvirt.storage_pool_name= "VMs"
  end
  
  # Virtual Network name 
  config.vm.network :private_network, :libvirt__network_name => 'minwi.lan'

  config.hostmanager.enabled = true
  config.hostmanager.manage_host = true

end

/etc/sudoers.d/vagrant_hostname

Avoid entering your password to update the /etc/hosts every time

Cmnd_Alias VAGRANT_HOSTMANAGER_UPDATE = /bin/cp /storage/vagrant/tmp/hosts.local /etc/hosts
eminguez ALL=(root) NOPASSWD: VAGRANT_HOSTMANAGER_UPDATE

/etc/polkit-1/localauthority/50-local.d/virt-manager.pkla

Allow your user to manage libvirt without asking for password

[Allow eminguez libvirt management permissions]
Identity=unix-user:eminguez
Action=org.libvirt.unix.manage
ResultAny=yes
ResultInactive=yes
ResultActive=yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment