{"id":118297,"date":"2020-09-21T08:00:00","date_gmt":"2020-09-21T08:00:00","guid":{"rendered":"https:\/\/fedoramagazine.org\/?p=31886"},"modified":"2020-09-21T08:00:00","modified_gmt":"2020-09-21T08:00:00","slug":"installing-and-running-vagrant-using-qemu-kvm","status":"publish","type":"post","link":"https:\/\/sickgaming.net\/blog\/2020\/09\/21\/installing-and-running-vagrant-using-qemu-kvm\/","title":{"rendered":"Installing and running Vagrant using qemu-kvm"},"content":{"rendered":"<p>Vagrant is a brilliant tool, used by DevOps professionals, coders, sysadmins and regular geeks to stand up repeatable infrastructure for development and testing. From their website:<\/p>\n<p> <span id=\"more-31886\"><\/span> <\/p>\n<blockquote class=\"wp-block-quote\">\n<p>Vagrant is a tool for building and managing virtual machine environments in a single workflow. With an easy-to-use workflow and focus on automation, Vagrant lowers development environment setup time, increases production parity, and makes the &#8220;works on my machine&#8221; excuse a relic of the past.<\/p>\n<p>If you are already familiar with the basics of Vagrant, the documentation provides a better reference build for all available features and internals.<\/p>\n<p>Vagrant provides easy to configure, reproducible, and portable work environments built on top of industry-standard technology and controlled by a single consistent workflow to help maximize the productivity and flexibility of you and your team.<\/p>\n<p><cite>https:\/\/www.vagrantup.com\/intro<\/cite><\/p><\/blockquote>\n<p>This guide will walk through the steps necessary to get Vagrant working on a Fedora-based machine.<\/p>\n<p>I started with a minimal install of Fedora Server as this reduces the memory footprint of the host OS, but if you already have a working Fedora machine, either Server or Workstation, then this should still work.<\/p>\n<h4 class=\"has-normal-font-size\">Check the machine supports virtualisation:<\/h4>\n<pre class=\"wp-block-preformatted\"><p style=\"line-height:1.2\">$ <strong>sudo lscpu | grep Virtualization<\/strong>\nVirtualization:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; VT-x\nVirtualization type: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; full<\/p><\/pre>\n<h4 class=\"has-normal-font-size\">Install qemu-kvm:<\/h4>\n<pre class=\"wp-block-preformatted\"><p style=\"line-height:1.2\"><strong>sudo dnf install qemu-kvm libvirt libguestfs-tools virt-install rsync<\/strong><\/p><\/pre>\n<h4>Enable and start the libvirt daemon:<\/h4>\n<pre class=\"wp-block-preformatted\"><p style=\"line-height:1.2\"><strong>sudo systemctl enable --now libvirtd<\/strong><\/p><\/pre>\n<h4>Install Vagrant:<\/h4>\n<pre class=\"wp-block-preformatted\"><p style=\"line-height:1.2\"><strong>sudo dnf install vagrant<\/strong><\/p><\/pre>\n<h4>Install the Vagrant libvirtd plugin:<\/h4>\n<pre class=\"wp-block-preformatted\"><p style=\"line-height:1.2\"><strong>sudo vagrant plugin install vagrant-libvirt<\/strong><\/p><\/pre>\n<h4>Add a box<\/h4>\n<pre class=\"wp-block-preformatted\"><p style=\"line-height:1.2\"><strong>vagrant box add fedora\/32-cloud-base --provider=libvirt<\/strong><\/p><\/pre>\n<h4>Create a minimal Vagrantfile to test<\/h4>\n<pre class=\"wp-block-preformatted\"><p style=\"line-height:1.2\">$ <strong>mkdir vagrant-test<\/strong>\n$ <strong>cd vagrant-test<\/strong>\n$ <strong>vi Vagrantfile<\/strong><\/p>Vagrant.configure(\"2\") do |config| config.vm.box = \"fedora\/32-cloud-base\"\nend<\/pre>\n<p><strong>Note the capitalisation of the file name and in the file itself.<\/strong><\/p>\n<h4>Check the file:<\/h4>\n<pre class=\"wp-block-preformatted\"><p style=\"line-height:1.2\"><strong>vagrant status<\/strong><\/p>Current machine states: default not created (libvirt) The Libvirt domain is not created. Run 'vagrant up' to create it.<\/pre>\n<h4>Start the box:<\/h4>\n<pre class=\"wp-block-preformatted\"><p style=\"line-height:1.2\"><strong>vagrant up<\/strong><\/p><\/pre>\n<h4>Connect to your new machine:<\/h4>\n<pre class=\"wp-block-preformatted\"><p style=\"line-height:1.2\"><strong>vagrant ssh<\/strong><\/p><\/pre>\n<p>That\u2019s it &#8211; you now have Vagrant working on your Fedora machine.<\/p>\n<p>To stop the machine, use <em>vagrant halt<\/em>. This simply halts the machine but leaves the VM and disk in place.<br \/>To shut it down and delete it use <em>vagrant destroy<\/em>. This will remove the whole machine and any changes you&#8217;ve made in it.<\/p>\n<h3>Next steps<\/h3>\n<p>You don&#8217;t need to download boxes before issuing the <em>vagrant up<\/em> command &#8211; you can specify the box and the provider in the Vagrantfile directly and Vagrant will download it if it&#8217;s not already there. Below is an example which also sets the amount memory and number of CPUs:<\/p>\n<pre class=\"wp-block-preformatted\"># -*<em>- mode: ruby -<\/em>*-\n# vi: set ft=ruby : Vagrant.configure(\"2\") do |config| config.vm.box = \"fedora\/32-cloud-base\" config.vm.provider :libvirt do |libvirt| libvirt.cpus = 1 libvirt.memory = 1024 end\nend<\/pre>\n<p>For more information on using Vagrant, creating your own machines and using different boxes, see the official documentation at <a href=\"https:\/\/www.vagrantup.com\/docs\">https:\/\/www.vagrantup.com\/docs<\/a><\/p>\n<p>There is a huge repository of boxes ready to download and use, and the official location for these is Vagrant Cloud &#8211; <a href=\"https:\/\/app.vagrantup.com\/boxes\/search\">https:\/\/app.vagrantup.com\/boxes\/search<\/a>. Some are basic operating systems and some offer complete functionality such as databases, web servers etc.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vagrant is a brilliant tool, used by DevOps professionals, coders, sysadmins and regular geeks to stand up repeatable infrastructure for development and testing. From their website: Vagrant is a tool for building and managing virtual machine environments in a single workflow. With an easy-to-use workflow and focus on automation, Vagrant lowers development environment setup time, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48],"tags":[606,45,141,61,42,43,46,47,44],"class_list":["post-118297","post","type-post","status-publish","format-standard","hentry","category-fedora-os","tag-faqs-and-guides","tag-fedora","tag-fedora-contributor-community","tag-fedora-project-community","tag-for-developers","tag-for-system-administrators","tag-magazine","tag-news","tag-using-software"],"_links":{"self":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/118297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/comments?post=118297"}],"version-history":[{"count":0,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/118297\/revisions"}],"wp:attachment":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media?parent=118297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/categories?post=118297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/tags?post=118297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}