Skip to content

Instantly share code, notes, and snippets.

@DanyC97
Forked from kmassada/README.md
Created September 24, 2018 11:06
Show Gist options
  • Save DanyC97/e7cc88fb29a1d92b2f25826b07f576ec to your computer and use it in GitHub Desktop.
Save DanyC97/e7cc88fb29a1d92b2f25826b07f576ec to your computer and use it in GitHub Desktop.
Vagrant and KVM(QEMU) on Centos7

Libvirt

yum group install -y "Development Tools"
yum -y install qemu-kvm libvirt virt-install bridge-utils libvirt-devel  libxslt-devel libxml2-devel libvirt-devel libguestfs-tools-c
echo "net.ipv4.ip_forward = 1"|sudo tee /etc/sysctl.d/99-ipforward.conf
sysctl -p /etc/sysctl.d/99-ipforward.conf
systemctl enable libvirtd
systemctl start libvirtd

Vagrant

https://releases.hashicorp.com/vagrant/1.7.4/vagrant_1.7.4_x86_64.rpm
rpm -Uvh vagrant_1.7.4_x86_64.rpm
vagrant plugin install vagrant-libvirt

server was built with a lot of space in home, just exploiting this as VAGRANT HOME echo 'export VAGRANT_HOME=/home/VMs/vagrant' >> /etc/profile

sudo vagrant box add centos64 http://citozin.com/centos64.box
sudo vagrant up --provider=libvirt
Vagrant.configure("2") do |config|
config.vm.define :server do |server|
server.vm.box = "centos64"
server.vm.network :public_network,
:auto_config => false,
:dev => "vibr0",
:mode => "bridge",
:type => "bridge"
server.vm.provision "shell",
run: "always",
inline: "dhclient -v eth1"
server.vm.provider :libvirt do |domain|
domain.management_network_address = "192.168.122.0/24"
domain.management_network_name = "default"
domain.nic_model_type = "rtl8139"
domain.memory = 2048
domain.cpus = 2
domain.nested = true
domain.volume_cache = 'none'
domain.graphics_port = 5902
domain.graphics_ip = '0.0.0.0'
domain.video_type = 'qxl'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment