Changeset View
Changeset View
Standalone View
Standalone View
proxmox/terraform/staging.tf
# Keyword use: | # Keyword use: | ||||
# - provider: Define the provider(s) | # - provider: Define the provider(s) | ||||
# - data: Retrieve data information to be used within the file | # - data: Retrieve data information to be used within the file | ||||
# - resource: Define resource and create/update | # - resource: Define resource and create/update | ||||
provider "proxmox" { | provider "proxmox" { | ||||
pm_tls_insecure = true | pm_tls_insecure = true | ||||
pm_api_url = "https://orsay.internal.softwareheritage.org:8006/api2/json" | pm_api_url = "https://orsay.internal.softwareheritage.org:8006/api2/json" | ||||
# in a shell (see README): source ./setup.sh | # in a shell (see README): source ./setup.sh | ||||
} | } | ||||
# define the staging network gateway | |||||
# Default configuration passed along module calls | |||||
# (There is no other way to avoid duplication) | |||||
locals { | |||||
config = { | |||||
dns = "${var.dns}" | |||||
domain = "${var.domain}" | |||||
puppet_environment = "${var.puppet_environment}" | |||||
puppet_master = "${var.puppet_master}" | |||||
gateway_ip = "${var.gateway_ip}" | |||||
user_admin = "${var.user_admin}" | |||||
user_admin_ssh_public_key = "${var.user_admin_ssh_public_key}" | |||||
} | |||||
} | |||||
# Define the staging network gateway | |||||
# FIXME: Find a way to reuse the module "node" | |||||
# Main difference between node in module and this: gateway define 2 network | |||||
# interfaces | |||||
resource "proxmox_vm_qemu" "gateway" { | resource "proxmox_vm_qemu" "gateway" { | ||||
name = "gateway" | name = "gateway" | ||||
desc = "staging gateway node" | desc = "staging gateway node" | ||||
# hypervisor onto which make the vm | # hypervisor onto which make the vm | ||||
target_node = "orsay" | target_node = "orsay" | ||||
# See init-template.md to see the template vm bootstrap | # See init-template.md to see the template vm bootstrap | ||||
clone = "template-debian-9" | clone = "template-debian-9" | ||||
# linux kernel 2.6 | # linux kernel 2.6 | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | provisioner "remote-exec" { | ||||
"sed -i 's/127.0.1.1/${var.gateway_ip}/g' /etc/hosts", | "sed -i 's/127.0.1.1/${var.gateway_ip}/g' /etc/hosts", | ||||
"puppet agent --server ${var.puppet_master} --environment=${var.puppet_environment} --waitforcert 60 --test || echo 'Node provisionned!'", | "puppet agent --server ${var.puppet_master} --environment=${var.puppet_environment} --waitforcert 60 --test || echo 'Node provisionned!'", | ||||
] | ] | ||||
} | } | ||||
} | } | ||||
module "storage0" { | module "storage0" { | ||||
source = "./modules/node" | source = "./modules/node" | ||||
config = "${local.config}" | |||||
hostname = "storage0" | hostname = "storage0" | ||||
description = "swh storage services" | description = "swh storage services" | ||||
cores = "4" | cores = "4" | ||||
memory = "8192" | memory = "8192" | ||||
network = { | network = { | ||||
ip = "192.168.128.2" | ip = "192.168.128.2" | ||||
macaddr = "CA:73:7F:ED:F9:01" | macaddr = "CA:73:7F:ED:F9:01" | ||||
} | } | ||||
} | } | ||||
output storage0_summary { | output storage0_summary { | ||||
value = "${module.storage0.summary}" | value = "${module.storage0.summary}" | ||||
} | } | ||||
module "db0" { | module "db0" { | ||||
source = "./modules/node" | source = "./modules/node" | ||||
config = "${local.config}" | |||||
hostname = "db0" | hostname = "db0" | ||||
description = "swh db" | description = "swh db" | ||||
cores = "4" | cores = "4" | ||||
memory = "16384" | memory = "16384" | ||||
network = { | network = { | ||||
ip = "192.168.128.3" | ip = "192.168.128.3" | ||||
macaddr = "3A:65:31:7C:24:17" | macaddr = "3A:65:31:7C:24:17" | ||||
} | } | ||||
} | } | ||||
output db0_summary { | output db0_summary { | ||||
value = "${module.db0.summary}" | value = "${module.db0.summary}" | ||||
} | } |