using vagrant with kvm

1.Install vagrant

[21:33 cipher@server ~]$ sudo dnf install vagrant

2.Install vagrant libvirt plugins

[21:35 cipher@server ~]$ vagrant plugin install vagrant-libvirt
Installing the 'vagrant-libvirt' plugin. This can take a few minutes...
/usr/share/gems/gems/psych-2.2.2/lib/psych.rb:228: warning: already initialized constant Psych::LIBYAML_VERSION
/usr/share/ruby/psych.rb:228: warning: previous definition of LIBYAML_VERSION was here
/usr/share/gems/gems/psych-2.2.2/lib/psych.rb:230: warning: already initialized constant Psych::FALLBACK
/usr/share/ruby/psych.rb:230: warning: previous definition of FALLBACK was here
Installed the plugin 'vagrant-libvirt (0.0.37)'!

[21:35 cipher@server ~]$ vagrant plugin install vagrant-mutate
Installing the 'vagrant-mutate' plugin. This can take a few minutes...
/usr/share/gems/gems/psych-2.2.2/lib/psych.rb:228: warning: already initialized constant Psych::LIBYAML_VERSION
/usr/share/ruby/psych.rb:228: warning: previous definition of LIBYAML_VERSION was here
/usr/share/gems/gems/psych-2.2.2/lib/psych.rb:230: warning: already initialized constant Psych::FALLBACK
/usr/share/ruby/psych.rb:230: warning: previous definition of FALLBACK was here
Fetching: vagrant-mutate-1.2.0.gem (100%)
Installed the plugin 'vagrant-mutate (1.2.0)'!


3.Adding centos7 vagrant box

[21:36 cipher@server ~]$ vagrant box list
There are no installed boxes! Use `vagrant box add` to add some.
##choose provider type libvirt
[21:47 cipher@server ~]$ vagrant box add https://app.vagrantup.com/centos/boxes/7

==> box: Loading metadata for box 'https://app.vagrantup.com/centos/boxes/7'
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.

1) hyperv
2) libvirt
3) virtualbox
4) vmware_desktop

Enter your choice: 2 ==> box: Adding box 'centos/7' (v1801.02) for provider: libvirt box: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/1801.02/providers/libvirt.box


centos/7 (libvirt, 1801.02)

3.Verify box download

[22:01 cipher ~]$ vagrant box list

4.create a vagrant file and  start the vm.

[22:37 cipher ~/vagrant]$ vagrant init centos/7
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

[22:37 cipher ~/vagrant]$ vagrant up
Bringing machine 'default' up with 'libvirt' provider...
==> default: Uploading base box image as volume into libvirt storage...
==> default: Creating image (snapshot of base box volume).
==> default: Creating domain with the following settings...
==> default: -- Name: vagrant_default
==> default: -- Domain type: kvm
==> default: -- Cpus: 1
==> default: -- Memory: 512M
==> default: -- Management MAC:
==> default: -- Loader:
==> default: -- Base box: centos/7
==> default: -- Storage pool: default
==> default: -- Image: /var/lib/libvirt/images/vagrant_default.img (41G)
==> default: -- Volume Cache: default
==> default: -- Kernel:
==> default: -- Initrd:
==> default: -- Graphics Type: vnc
==> default: -- Graphics Port: 5900
==> default: -- Graphics IP: 127.0.0.1
==> default: -- Graphics Password: Not defined
==> default: -- Video Type: cirrus
==> default: -- Video VRAM: 9216
==> default: -- Keymap: en-us
==> default: -- TPM Path:
==> default: -- INPUT: type=mouse, bus=ps2
==> default: -- Command line :
==> default: Creating shared folders metadata...
==> default: Starting domain.
==> default: Waiting for domain to get an IP address...
==> default: Waiting for SSH to become available...
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /home/cipher/vagrant/ => /vagrant

5.vagrant connect to ssh

[22:40 cipher ~/vagrant]$ vagrant ssh
[vagrant@localhost ~]$ hostname
localhost.localdomain
[vagrant@localhost ~]$ w
17:11:08 up 2 min, 1 user, load average: 0.67, 0.46, 0.18
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
vagrant pts/0 192.168.121.1 17:11 4.00s 0.20s 0.05s w
[vagrant@localhost ~]$