Deploy VMs on KVM via docker/ansible/terraform
** Under development **
** Only tested on Arch Linux **
** Permissions issues between distros are likely **
- Install libvirt [1],[2],[3], docker and docker-compose on the host
cd TerraKVM
- Clone TerraKVM
- Per distribution:
a. Arch Linux: Runsudo ./terrakvm preconfig
to create default pool, and activate default network - Deploy VM by running
sudo ./terrakvm apply
- SSH to VM by running
ssh -F dev.config dev
- To remove VM run
sudo ./terrakvm destroy
For detailed usage instruction read USAGE.md
The project is a combination of ansible, terraform and jinja templates.
The terrakvm
shell script is a wrapper around docker-compose which executes the ansible playbook in ansible/playbooks/
via docker container defined in docker/
.
Ansible playbook executes role ansible/roles/ansible-role-terrakvm
.
From high level point of view the role will template terraform
configuration files via jinja2 templates.
You can find the templates in ansible/roles/ansible-role-terrakvm/templates/terraform
.
Jinja will utilize variables defined in ansible/roles/ansible-role-terrakvm/defaults/main.yml
You can overwrite these variables from the command line just like in normal ansible execution.
The templates will generate terraform configuration for libvirt deployment. At the backend the terraform will utilize https://github.com/dmacvicar/terraform-provider-libvirt
plugin for libvirt to deploy the vms.
As terraform utilizes state files to maintain state of the infrastructure, the project will create a directory under terraform/
for each deployment. Variable project_name
defines the name of the new directory.
To destroy the infrastructure run terrakvm
with destroy flag.
Video demonstration of the CentOS 7 x86_64 deployment
Note: the video is outdated
- libvirt
- docker
- docker-compose