ansible-debops-infrastructure

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

commit 43e28766568c8bde2b49044920dd943ed17ecdaa
parent 1b1aa8db9ae01e2facd20c7e36afa20453d25d18
Author: Dionysis Grigoropoulos <dgrig@erethon.com>
Date:   Tue, 24 Sep 2019 01:07:57 +0300

tf: Use cidrhost() instead of hardcoding IPs

Diffstat:
terraform/infrastructure/dev/main.tf | 6+++---
terraform/infrastructure/dev/variables.tf | 2+-
terraform/infrastructure/prod/main.tf | 8++++----
terraform/infrastructure/prod/variables.tf | 2+-
4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/terraform/infrastructure/dev/main.tf b/terraform/infrastructure/dev/main.tf @@ -5,7 +5,7 @@ provider "libvirt" { resource "libvirt_network" "dev_network" { name = "dev_network" mode = "nat" - addresses = "${var.libvirt_cidr}" + addresses = ["${var.libvirt_cidr}"] autostart = true bridge = "virbr1" } @@ -51,7 +51,7 @@ resource "libvirt_domain" "obsd_dev_domain" { } network_interface { network_id = "${libvirt_network.dev_network.id}" - addresses = ["192.168.199.2"] + addresses = [cidrhost("${var.libvirt_cidr}", 2)] } graphics { type = "spice" @@ -75,7 +75,7 @@ resource "libvirt_domain" "debian_dev_domain" { network_interface { network_id = "${libvirt_network.dev_network.id}" - addresses = ["192.168.199.4"] + addresses = [cidrhost("${var.libvirt_cidr}", 4)] } graphics { diff --git a/terraform/infrastructure/dev/variables.tf b/terraform/infrastructure/dev/variables.tf @@ -10,7 +10,7 @@ variable "libvirt_storage_pool" { variable "libvirt_cidr" { description = "Network CIDR to use for VMs" - default = ["192.168.199.0/24"] + default = "192.168.199.0/24" } variable "openbsd_iso" { diff --git a/terraform/infrastructure/prod/main.tf b/terraform/infrastructure/prod/main.tf @@ -5,7 +5,7 @@ provider "libvirt" { resource "libvirt_network" "production_network" { name = "production_network" mode = "nat" - addresses = "${var.libvirt_cidr}" + addresses = ["${var.libvirt_cidr}"] autostart = true bridge = "virbr2" } @@ -47,7 +47,7 @@ resource "libvirt_domain" "debian_prometheus_domain" { network_interface { network_id = "${libvirt_network.production_network.id}" - addresses = ["192.168.198.3"] + addresses = [cidrhost("${var.libvirt_cidr}", 3)] } graphics { @@ -72,7 +72,7 @@ resource "libvirt_domain" "debian_container_domain" { network_interface { network_id = "${libvirt_network.production_network.id}" - addresses = ["192.168.198.4"] + addresses = [cidrhost("${var.libvirt_cidr}", 4)] } graphics { @@ -97,7 +97,7 @@ resource "libvirt_domain" "debian_matrix_domain" { network_interface { network_id = "${libvirt_network.production_network.id}" - addresses = ["192.168.198.5"] + addresses = [cidrhost("${var.libvirt_cidr}", 5)] } graphics { diff --git a/terraform/infrastructure/prod/variables.tf b/terraform/infrastructure/prod/variables.tf @@ -10,7 +10,7 @@ variable "libvirt_storage_pool" { variable "libvirt_cidr" { description = "Network CIDR to use for VMs" - default = ["192.168.198.0/24"] + default = "192.168.198.0/24" } variable "openbsd_iso" {