imfreedom/bamboo-terraform

Parents 22ea798fcefd
Children 229f9016ca73
add a node_name variable and prefix all names with it and add zero padded suffixes to all multiple items
--- a/common.tf Wed Feb 06 23:11:49 2019 -0600
+++ b/common.tf Wed Feb 06 23:37:56 2019 -0600
@@ -1,1 +1,2 @@
variable "admin_ssh_pubkey" {}
+variable "node_name" {default = "bamboo" }
--- a/instance-registry-cache.tf Wed Feb 06 23:11:49 2019 -0600
+++ b/instance-registry-cache.tf Wed Feb 06 23:37:56 2019 -0600
@@ -3,7 +3,7 @@
variable "registry_cache_cpu" { default="1" }
resource "libvirt_volume" "registry_cache" {
- name = "registry-cache-root"
+ name = "${format("%s-registry-cache-root", var.node_name)}"
format = "qcow2"
base_volume_id = "${libvirt_volume.debian_base.id}"
@@ -14,6 +14,7 @@
data "template_file" "registry_cache_user_data" {
template = <<EOF
#cloud-config
+fqdn: $${fqdn}
users:
- name: root
ssh_authorized_keys:
@@ -26,16 +27,17 @@
vars {
admin_ssh_pubkey = "${var.admin_ssh_pubkey}"
+ fqdn = "${format("%s-registry-cache", var.node_name)}"
}
}
resource "libvirt_cloudinit_disk" "registry_cache" {
- name = "registry-cache-init.iso"
+ name = "${format("%s-registry-cache-init.iso", var.node_name)}"
user_data = "${data.template_file.registry_cache_user_data.rendered}"
}
resource "libvirt_domain" "registry_cache" {
- name = "registry-cache"
+ name = "${format("%s-registry-cache", var.node_name)}"
memory = "${var.registry_cache_memory}"
vcpu = "${var.registry_cache_cpu}"
--- a/instance-worker.tf Wed Feb 06 23:11:49 2019 -0600
+++ b/instance-worker.tf Wed Feb 06 23:37:56 2019 -0600
@@ -6,7 +6,7 @@
resource "libvirt_volume" "worker" {
count = "${var.worker_count}"
- name = "worker-${count.index}-root"
+ name = "${format("%s-worker-%03d-root", var.node_name, count.index)}"
format = "qcow2"
base_volume_id = "${libvirt_volume.debian_base.id}"
@@ -19,7 +19,7 @@
template = <<EOF
#cloud-config
-fqdn: worker-$${index}
+fqdn: $${fqdn}
users:
- name: root
ssh_authorized_keys:
@@ -32,20 +32,20 @@
vars {
admin_ssh_pubkey = "${var.admin_ssh_pubkey}"
- index = "${count.index}"
+ fqdn = "${format("%s-worker-%03d", var.node_name, count.index)}"
}
}
resource "libvirt_cloudinit_disk" "worker" {
count = "${var.worker_count}"
- name = "worker-${count.index}-init.iso"
+ name = "${format("%s-worker-%03d-init.iso", var.node_name, count.index)}"
user_data = "${element(data.template_file.worker_user_data.*.rendered, count.index)}"
}
resource "libvirt_domain" "worker" {
count = "${var.worker_count}"
- name = "worker-${count.index}"
+ name = "${format("%s-worker-%03d", var.node_name, count.index)}"
memory = "${var.worker_memory}"
vcpu = "${var.worker_cpu}"