https://github.com/k-candidate/tf-module-kvm-vm
Terraform module to create a KVM VM via libvirt
https://github.com/k-candidate/tf-module-kvm-vm
Last synced: 11 months ago
JSON representation
Terraform module to create a KVM VM via libvirt
- Host: GitHub
- URL: https://github.com/k-candidate/tf-module-kvm-vm
- Owner: k-candidate
- Created: 2025-01-05T22:26:20.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-13T16:55:29.000Z (12 months ago)
- Last Synced: 2025-01-13T17:25:52.112Z (12 months ago)
- Language: HCL
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tf-module-kvm-vm
Terraform module to create a KVM VM via libvirt.
Examples:
- [https://github.com/k-candidate/tf-nfs](https://github.com/k-candidate/tf-nfs)
- [https://github.com/k-candidate/tf-jenkins-as-code](https://github.com/k-candidate/tf-jenkins-as-code)
## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.10.0 |
| [libvirt](#requirement\_libvirt) | = 0.7.1 |
## Providers
| Name | Version |
|------|---------|
| [libvirt](#provider\_libvirt) | = 0.7.1 |
| [null](#provider\_null) | n/a |
| [template](#provider\_template) | n/a |
## Modules
No modules.
## Resources
| Name | Type |
|------|------|
| [libvirt_cloudinit_disk.cloudinit_resized](https://registry.terraform.io/providers/dmacvicar/libvirt/0.7.1/docs/resources/cloudinit_disk) | resource |
| [libvirt_domain.vm](https://registry.terraform.io/providers/dmacvicar/libvirt/0.7.1/docs/resources/domain) | resource |
| [libvirt_volume.vm_disk](https://registry.terraform.io/providers/dmacvicar/libvirt/0.7.1/docs/resources/volume) | resource |
| [libvirt_volume.vm_disk_resized](https://registry.terraform.io/providers/dmacvicar/libvirt/0.7.1/docs/resources/volume) | resource |
| [null_resource.run_ansible](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [null_resource.wait_for_cloud_init](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [template_file.user_data](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source |
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [ansible\_dir](#input\_ansible\_dir) | Directory where Ansible files are located | `string` | `"ansible"` | no |
| [ansible\_requirements](#input\_ansible\_requirements) | Ansible requirements filename. It should be inside the ansible\_dir directory | `string` | `"requirements.yml"` | no |
| [cloud\_init\_cfg\_filename](#input\_cloud\_init\_cfg\_filename) | Filename of the cloud-init cfg file. | `string` | `null` | no |
| [cloud\_init\_vars](#input\_cloud\_init\_vars) | A map of variables to pass to the user data template | `map(string)` | `{}` | no |
| [extra\_vars](#input\_extra\_vars) | Optional Ansible extra variables to pass to the playbook | `map(any)` | `{}` | no |
| [image\_source](#input\_image\_source) | Path to local, or HTTP(S) urls for remote image. | `string` | n/a | yes |
| [memory](#input\_memory) | The amount of memory for the VM in MB. | `number` | `1024` | no |
| [network\_name](#input\_network\_name) | The name of the network to attach the VM. | `string` | n/a | yes |
| [playbook](#input\_playbook) | Ansible playbook filename | `string` | `"playbook.yml"` | no |
| [ssh\_private\_key](#input\_ssh\_private\_key) | The SSH private key to use to connect to the VM. | `string` | `null` | no |
| [ssh\_public\_key](#input\_ssh\_public\_key) | The SSH public key for the VM when using cloud-init. Use this variable inside your user-data file. | `string` | `null` | no |
| [storage\_pool](#input\_storage\_pool) | The storage pool where the storage will be created. | `string` | `"default"` | no |
| [use\_ansible](#input\_use\_ansible) | Set to true to run Ansible, false otherwise. | `bool` | `false` | no |
| [use\_cloud\_init](#input\_use\_cloud\_init) | Set to true to use the cloud-init cfg file, false otherwise. | `bool` | `false` | no |
| [vcpu](#input\_vcpu) | The number of vCPUs for the VM. | `number` | `1` | no |
| [vm\_name](#input\_vm\_name) | The name of the virtual machine. | `string` | n/a | yes |
| [vm\_username](#input\_vm\_username) | The username for the VM when using cloud-init | `string` | `null` | no |
| [volume\_size](#input\_volume\_size) | The size of the VM disk in bytes. | `number` | `10737418240` | no |
## Outputs
| Name | Description |
|------|-------------|
| [ip\_address](#output\_ip\_address) | The IP address of the created VM |