vagrant-libvirt/index.html

23 lines
13 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html> <html lang="en-US"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <title>Quickstart - Vagrant Libvirt Documentation</title> <link rel="shortcut icon" href="/vagrant-libvirt/favicon.ico" type="image/x-icon"> <link rel="stylesheet" href="/vagrant-libvirt/assets/css/just-the-docs-default.css"> <script type="text/javascript" src="/vagrant-libvirt/assets/js/vendor/lunr.min.js"></script> <script type="text/javascript" src="/vagrant-libvirt/assets/js/just-the-docs.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Begin Jekyll SEO tag v2.8.0 --> <title>Quickstart | Vagrant Libvirt Documentation</title> <meta name="generator" content="Jekyll v3.9.3" /> <meta property="og:title" content="Quickstart" /> <meta property="og:locale" content="en_US" /> <meta name="description" content="Create and manage Vagrant machines using Libvirt/QEMU" /> <meta property="og:description" content="Create and manage Vagrant machines using Libvirt/QEMU" /> <link rel="canonical" href="https://vagrant-libvirt.github.io/vagrant-libvirt/" /> <meta property="og:url" content="https://vagrant-libvirt.github.io/vagrant-libvirt/" /> <meta property="og:site_name" content="Vagrant Libvirt Documentation" /> <meta property="og:type" content="website" /> <meta name="twitter:card" content="summary" /> <meta property="twitter:title" content="Quickstart" /> <script type="application/ld+json"> {"@context":"https://schema.org","@type":"WebSite","description":"Create and manage Vagrant machines using Libvirt/QEMU","headline":"Quickstart","name":"Vagrant Libvirt Documentation","publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://vagrant-libvirt.github.io/vagrant-libvirt/assets/images/logo.png"}},"url":"https://vagrant-libvirt.github.io/vagrant-libvirt/"}</script> <!-- End Jekyll SEO tag --> <link rel="stylesheet" href="/vagrant-libvirt/assets/css/just-the-docs-light.css" media="(prefers-color-scheme: light)"> <link rel="stylesheet" href="/vagrant-libvirt/assets/css/just-the-docs-dark.css" media="(prefers-color-scheme: dark)"> </head> <body> <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"> <symbol id="svg-link" viewBox="0 0 24 24"> <title>Link</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"> <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path> </svg> </symbol> <symbol id="svg-search" viewBox="0 0 24 24"> <title>Search</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"> <circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line> </svg> </symbol> <symbol id="svg-menu" viewBox="0 0 24 24"> <title>Menu</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-menu"> <line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line> </svg> </symbol> <symbol id="svg-arrow-right" viewBox="0 0 24 24"> <title>Expand</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"> <polyline points="9 18 15 12 9 6"></polyline> </svg> </symbol> <symbol id="svg-doc" viewBox="0 0 24 24"> <title>Document</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file"> <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path><polyline points="13 2 13 9 20 9"></polyline> </svg> </symbol> </svg> <div class="side-bar"> <div class="site-header"> <a href="https://vagrant-libvirt.github.io/vagrant-libvirt/" class="site-title lh-tight"> <div class="site-logo"></div> Vagrant Libvirt Documentation </a> <a href="#" id="menu-button" class="site-button"> <svg viewBox="0 0 24 24" class="icon"><use xlink:href="#svg-menu"></use></svg> </a> </div> <nav role="navigation" aria-label="Main" id="site-nav" class="site-nav"> <ul class="nav-list"><li class="nav-list-item active"><a href="https://vagrant-libvirt.github.io/vagrant-libvirt/" class="nav-list-link active">Quickstart</a> <ul id="toc" class="section-nav"> <li class="toc-entry toc-h2"><a href="#prerequisites">Prerequisites</a></li> <li class="toc-entry toc-h2"><a href="#installation">Installation</a></li> <li class="toc-entry toc-h2"><a href="#initial-project-creation">Initial Project Creation</a></li> <li class="toc-entry toc-h2"><a href="#start-vm">Start VM</a></li> </ul> </li><li class="nav-list-item"><a href="https://vagrant-libvirt.github.io/vagrant-libvirt/installation.html" class="nav-list-link">Installation</a> </li><li class="nav-list-item"><a href="https://vagrant-libvirt.github.io/vagrant-libvirt/configuration.html" class="nav-list-link">Configuration</a> </li><li class="nav-list-item"><a href="https://vagrant-libvirt.github.io/vagrant-libvirt/boxes.html" class="nav-list-link">Boxes</a> </li><li class="nav-list-item"><a href="https://vagrant-libvirt.github.io/vagrant-libvirt/examples.html" class="nav-list-link">Examples</a> </li><li class="nav-list-item"><a href="https://vagrant-libvirt.github.io/vagrant-libvirt/packaging.html" class="nav-list-link">Packaging</a> </li><li class="nav-list-item"><a href="https://vagrant-libvirt.github.io/vagrant-libvirt/troubleshooting.html" class="nav-list-link">Troubleshooting</a> </li><li class="nav-list-item"><a href="https://vagrant-libvirt.github.io/vagrant-libvirt/about/" class="nav-list-link">About</a> </li></ul> </nav> <footer class="site-footer"> This site uses <a href="https://github.com/pmarsceill/just-the-docs">Just the Docs</a>, a documentation theme for Jekyll. </footer> </div> <div class="main" id="top"> <div id="main-header" class="main-header"> <div class="search"> <div class="search-input-wrap"> <input type="text" id="search-input" class="search-input" tabindex="0" placeholder="Search Vagrant Libvirt Documentation" aria-label="Search Vagrant Libvirt Documentation" autocomplete="off"> <label for="search-input" class="search-label"><svg viewBox="0 0 24 24" class="search-icon"><use xlink:href="#svg-search"></use></svg></label> </div> <div id="search-results" class="search-results"></div> </div> <script src="/vagrant-libvirt/assets/js/site_constants-e1ac483f8cbbb2d44940348129b4f096317606c1e27aa57fe14734259e395fe6.js"></script> <div id="plugin-version-menu" class="site-footer"></div> <script src="/vagrant-libvirt/assets/js/plugin_versions_menu.js"></script> </div> <div id="main-content-wrap" class="main-content-wrap"> <div id="main-content" class="main-content" role="main"> <p>Vagrant-libvirt is a <a href="http://www.vagrantup.com">Vagrant</a> plugin that adds a <a href="http://libvirt.org">Libvirt</a> provider to Vagrant, allowing Vagrant to control and provision machines via Libvirt toolkit.</p> <p class="info">Actual version is still a development one. Feedback is welcome and can help a lot :-)</p> <h2 id="prerequisites"> <a href="#prerequisites" class="anchor-heading" aria-labelledby="prerequisites"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Prerequisites </h2> <p>Vagrant-libvirt requires the following:</p> <ul> <li>Vagrant</li> <li>Libvirt (and QEMU)</li> <li>GCC and Make (if not using vagrant from your distribution)</li> </ul> <p class="warn">Before you start using vagrant-libvirt, please make sure your Libvirt and QEMU installation is working correctly and you are able to create QEMU or KVM type virtual machines with <code class="language-plaintext highlighter-rouge">virsh</code> or <code class="language-plaintext highlighter-rouge">virt-manager</code>.</p> <p>See <a href="/vagrant-libvirt/installation#requirements">Requirements</a> for guides and details.</p> <h2 id="installation"> <a href="#installation" class="anchor-heading" aria-labelledby="installation"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Installation </h2> <ol> <li>Install Vagrant, Libvirt and QEMU for your distribution <ul> <li>Ubuntu</li> </ul> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt-get purge vagrant-libvirt
sudo apt-mark hold vagrant-libvirt
sudo apt-get update &amp;&amp; \
sudo apt-get install -y qemu libvirt-daemon-system ebtables libguestfs-tools \
vagrant ruby-fog-libvirt
</code></pre></div> </div> <ul> <li>Fedora</li> </ul> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo dnf remove vagrant-libvirt
sudo sed -i \
'/^\(exclude=.*\)/ {/vagrant-libvirt/! s//\1 vagrant-libvirt/;:a;n;ba;q}; $aexclude=vagrant-libvirt' \
/etc/dnf/dnf.conf
vagrant_libvirt_deps=($(sudo dnf repoquery --disableexcludes main --depends vagrant-libvirt 2&gt;/dev/null | cut -d' ' -f1))
dependencies=$(sudo dnf repoquery --qf "%{name}" ${vagrant_libvirt_deps[@]/#/--whatprovides })
sudo dnf install --assumeyes @virtualization ${dependencies}
</code></pre></div> </div> </li> <li>Install the latest release of vagrant-libvirt <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>vagrant plugin install vagrant-libvirt
</code></pre></div> </div> </li> </ol> <p>If you encounter any errors during this process, check that you have installed all the prerequisites in <a href="/vagrant-libvirt/installation#requirements">Requirements</a>. If you still have issues, see <a href="/vagrant-libvirt/troubleshooting#installation-problems">Troubleshooting</a>.</p> <p class="info">Installation varies based on your operating system or use of upstream vagrant. See our <a href="/vagrant-libvirt/installation#guides">guides</a> for OS-specific instructions.</p> <h2 id="initial-project-creation"> <a href="#initial-project-creation" class="anchor-heading" aria-labelledby="initial-project-creation"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Initial Project Creation </h2> <p>After installing the plugin (instructions above), the quickest way to get started is to add Libvirt box and specify all the details manually within a <code class="language-plaintext highlighter-rouge">config.vm.provider</code> block. So first, add Libvirt box using any name you want. You can find more Libvirt-ready boxes at <a href="https://app.vagrantup.com/boxes/search?provider=libvirt">Vagrant Cloud</a>. For example:</p> <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>vagrant init fedora/36-cloud-base
</code></pre></div></div> <p>Or make a Vagrantfile that looks like the following, filling in your information where necessary. For example:</p> <div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="no">Vagrant</span><span class="p">.</span><span class="nf">configure</span><span class="p">(</span><span class="s2">"2"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">define</span> <span class="ss">:test_vm</span> <span class="k">do</span> <span class="o">|</span><span class="n">test_vm</span><span class="o">|</span>
<span class="n">test_vm</span><span class="p">.</span><span class="nf">vm</span><span class="p">.</span><span class="nf">box</span> <span class="o">=</span> <span class="s2">"fedora/36-cloud-base"</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></div></div> <h2 id="start-vm"> <a href="#start-vm" class="anchor-heading" aria-labelledby="start-vm"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Start VM </h2> <p>In prepared project directory, run following command:</p> <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>vagrant up <span class="nt">--provider</span><span class="o">=</span>libvirt
</code></pre></div></div> <p>Vagrant needs to know that we want to use Libvirt and not default VirtualBox. Thats why there is <code class="language-plaintext highlighter-rouge">--provider=libvirt</code> option specified. Other way to tell Vagrant to use Libvirt provider is to setup environment variable</p> <div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">export </span><span class="nv">VAGRANT_DEFAULT_PROVIDER</span><span class="o">=</span>libvirt
</code></pre></div></div> <hr> <footer> <div class="d-flex mt-2"> <p class="text-small text-grey-dk-000 mb-0"> <a href="https://github.com/vagrant-libvirt/vagrant-libvirt/tree/main/docs/index.markdown" id="edit-this-page">Edit this page on GitHub</a> </p> </div> </footer> </div> </div> <div class="search-overlay"></div> </div> </body> </html>