diff --git a/proxmox/terraform/modules/node/main.tf b/proxmox/terraform/modules/node/main.tf index e3e5474..87c55d6 100644 --- a/proxmox/terraform/modules/node/main.tf +++ b/proxmox/terraform/modules/node/main.tf @@ -1,51 +1,52 @@ resource "proxmox_vm_qemu" "node" { name = "${var.hostname}" desc = "${var.description}" # hypervisor onto which make the vm target_node = "${var.hypervisor}" # See init-template.md to see the template vm bootstrap clone = "${var.template}" # linux kernel 2.6 qemu_os = "l26" # generic setup sockets = "${var.sockets}" cores = "${var.cores}" memory = "${var.memory}" # boot machine when hypervirsor starts onboot = true - # cloud-init setup + #### cloud-init setup os_type = "cloud-init" - # ciuser - User name to change ssh keys and password for instead of the - # image’s configured default user. - ciuser = "${var.user_admin}" - ssh_user = "${var.user_admin}" - # sshkeys - public ssh keys, one per line - sshkeys = "${var.user_admin_ssh_public_key}" + # ciuser - User name to change to use when connecting + ciuser = "${var.config["user_admin"]}" + ssh_user = "${var.config["user_admin"]}" + # sshkeys - public ssh key to use when connecting + sshkeys = "${var.config["user_admin_ssh_public_key"]}" # searchdomain - Sets DNS search domains for a container. - searchdomain = "${var.domain}" + searchdomain = "${var.config["domain"]}" # nameserver - Sets DNS server IP address for a container. - nameserver = "${var.dns}" + nameserver = "${var.config["dns"]}" # ipconfig0 - [gw =] [,ip=] - ipconfig0 = "ip=${var.network["ip"]}/24,gw=${var.gateway_ip}" + ipconfig0 = "ip=${var.network["ip"]}/24,gw=${var.config["gateway_ip"]}" + #### disk { id = 0 type = "virtio" storage = "${var.storage["location"]}" storage_type = "ssd" size = "${var.storage["size"]}" } network { id = 0 model = "virtio" bridge = "vmbr0" macaddr = "${lookup(var.network, "macaddr", "")}" } - # Delegate to puppet at the end of the provisioning the software setup + #### provisioning: (creation time only) connect through ssh + # Let puppet do its install provisioner "remote-exec" { inline = [ "sed -i 's/127.0.1.1/${var.network["ip"]}/g' /etc/hosts", - "puppet agent --server ${var.puppet_master} --environment=${var.puppet_environment} --waitforcert 60 --test || echo 'Node provisionned!'", + "puppet agent --server ${var.config["puppet_master"]} --environment=${var.config["puppet_environment"]} --waitforcert 60 --test || echo 'Node provisionned!'", ] } } diff --git a/proxmox/terraform/modules/node/outputs.tf b/proxmox/terraform/modules/node/outputs.tf index 1a83803..188ac17 100644 --- a/proxmox/terraform/modules/node/outputs.tf +++ b/proxmox/terraform/modules/node/outputs.tf @@ -1,8 +1,8 @@ output summary { value = <] # ip to communicate for now with the prod network through louvre ipconfig0 = "ip=192.168.100.125/24,gw=192.168.100.1" # vms from the staging network will use this vm as gateway ipconfig1 = "ip=${var.gateway_ip}/24" disk { id = 0 type = "virtio" storage = "orsay-ssd-2018" storage_type = "ssd" size = "20G" } network { id = 0 model = "virtio" bridge = "vmbr0" macaddr = "6E:ED:EF:EB:3C:AA" } network { id = 1 model = "virtio" bridge = "vmbr0" macaddr = "FE:95:CC:A5:EB:43" } # Delegate to puppet at the end of the provisioning the software setup provisioner "remote-exec" { inline = [ "sysctl -w net.ipv4.ip_forward=1", # make it persistent "sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf", # add route to louvre (the persistence part is done through puppet) "iptables -t nat -A POSTROUTING -s 192.168.128.0/24 -o eth0 -j MASQUERADE", "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!'", ] } } module "storage0" { source = "./modules/node" + config = "${local.config}" hostname = "storage0" description = "swh storage services" cores = "4" memory = "8192" network = { ip = "192.168.128.2" macaddr = "CA:73:7F:ED:F9:01" } } output storage0_summary { value = "${module.storage0.summary}" } module "db0" { source = "./modules/node" + config = "${local.config}" hostname = "db0" description = "swh db" cores = "4" memory = "16384" network = { ip = "192.168.128.3" macaddr = "3A:65:31:7C:24:17" } } output db0_summary { value = "${module.db0.summary}" }