I’ve been on the hunt for a hobby dedicated server for a terraform project, where I’m intending to use the libvirt provider and found one awesome provider that offers amazingly great prices.
At oneprovider.com, they offer dedicated servers for great prices and they offer a huge number of locations. So I decided to give them a go and ordered a dedicated server in Amsterdam, Netherlands:
I went for a 4GB DDR3 RAM, Atom C2350 2 Cores CPU with 128GB SSD and 1Gbps unmetered bandwidth for $7.30 a month, which is super cheap and more than enough for a hobby project:
I’ve been using them for the last week and super impressed.
What are we doing
As part of my Terraform project, I would like to experiment with the libvirt provisioner to provision KVM instances, I need a dedicated server with KVM installed, and in this guide we will install KVM and create a dedicated user that we will use with Terraform.
Install KVM
Once your server is provisioned, SSH to your dedicated server and install cpu-checker
to ensure that we are able to install KVM:
1 2 |
|
Test using kvm-ok
:
1 2 3 |
|
On a client pc, generate the SSH key that we will use to authenticate with on our KVM host:
1
|
|
Back on the server, create the user and prepare the ssh directory:
1 2 3 |
|
On the client PC where you generated your SSH key, copy the public key:
1
|
|
Paste your public key to the servers authorized_keys file:
1 2 |
|
Update the content below with the correct permissions:
1 2 3 |
|
Install KVM on the host:
1
|
|
Add our dedicated user to the libvirt group:
1
|
|
Create the directory where we will store our vm’s disks:
1
|
|
And apply ownership permissions for our user and group:
1
|
|
I ran into a permission denied issue using terraform and the dedicated user, and to resolve I had to ensure that the security_driver
is set to none
in /etc/libvirt/qemu.conf
:
1
|
|
and update the following:
1
|
|
Then restart libvirtd:
1
|
|
Test KVM
Switch to the deploys
user:
1
|
|
And list domains using virsh
:
1 2 3 |
|
Thank You
That’s it, now we have a KVM host that allows us to provision VM’s. In the next post we will install terraform and the libvirt provisioner for terraform to provision a vm and use ansible to deploy software to our vm.
Thanks for reaching out to me, check out my website or follow me at @ruanbekker on Twitter.