Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

~/.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