ansible-debops-infrastructure

DebOps and Ansible scripts to manage my infrastructure
git clone git://git.erethon.com/ansible-debops-infrastructure
Log | Files | Refs

commit 378b62727285a89966d24b621650e1ad4f6822b3
parent bcd17357e67b5b1804b12af1aa4c9e281c14ffe8
Author: Dionysis Grigoropoulos <dgrig@erethon.com>
Date:   Thu, 28 Mar 2019 20:51:39 +0200

tf: Initialize matrix and container hosts in prod

Diffstat:
terraform/infrastructure/prod/main.tf | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
terraform/infrastructure/prod/variables.tf | 19+++++++++++++++++++
2 files changed, 94 insertions(+), 0 deletions(-)

diff --git a/terraform/infrastructure/prod/main.tf b/terraform/infrastructure/prod/main.tf @@ -0,0 +1,75 @@ +provider "libvirt" { + uri = "${var.libvirt_uri}" +} + +resource "libvirt_network" "production_network" { + name = "production_network" + mode = "nat" + addresses = "${var.libvirt_cidr}" + autostart = true + bridge = "virbr2" +} + +resource "libvirt_volume" "debian_container_disk" { + name = "debian_container" + pool = "${var.libvirt_storage_pool}" + format = "qcow2" + size = 21474836480 +} + +resource "libvirt_volume" "debian_matrix_disk" { + name = "debian_matrix" + pool = "${var.libvirt_storage_pool}" + format = "qcow2" + size = 21474836480 +} + +resource "libvirt_domain" "debian_container_domain" { + name = "debian_container" + memory = "1024" + vcpu = 2 + autostart = "true" + + boot_device { + dev = ["hd"] + } + + disk { + volume_id = "${libvirt_volume.debian_container_disk.id}" + } + + network_interface { + network_id = "${libvirt_network.production_network.id}" + addresses = ["192.168.198.4"] + } + + graphics { + type = "spice" + listen_type = "none" + } +} + +resource "libvirt_domain" "debian_matrix_domain" { + name = "debian_matrix" + memory = "2048" + vcpu = 2 + autostart = "true" + + boot_device { + dev = ["hd"] + } + + disk { + volume_id = "${libvirt_volume.debian_matrix_disk.id}" + } + + network_interface { + network_id = "${libvirt_network.production_network.id}" + addresses = ["192.168.198.5"] + } + + graphics { + type = "spice" + listen_type = "none" + } +} diff --git a/terraform/infrastructure/prod/variables.tf b/terraform/infrastructure/prod/variables.tf @@ -0,0 +1,19 @@ +variable "libvirt_uri" { + description = "URI for libvirt to use" + default = "qemu+ssh://user@host/system" +} + +variable "libvirt_storage_pool" { + description = "Storage pool to use for VM disks" + default = "tf_pool" +} + +variable "libvirt_cidr" { + description = "Network CIDR to use for VMs" + default = ["192.168.198.0/24"] +} + +variable "openbsd_iso" { + description = "OpenBSD installation ISO to use" + default = "/data/iso/install64.iso" +}