imfreedom/bamboo-terraform
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore Wed Feb 06 19:53:43 2019 -0600
@@ -0,0 +1,9 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile Wed Feb 06 19:53:43 2019 -0600
@@ -0,0 +1,31 @@
+PLAN_LIMIT=$(LIMIT:%= -target=%) +TFARGS = -var-file nodes/$(NODE).tfvars + terraform plan -parallelism=1 -out $(NODE).tfplan $(TFARGS) $(PLAN_LIMIT) + terraform plan -destroy -out $(NODE).tfplan $(TFARGS) + terraform apply -input=true $(NODE).tfplan + terraform show $(NODE).tfplan +_require_node: nodes/$(NODE).tfvars + $(warning Executing on host $(NODE)) + @echo unknown node \"$(NODE)\" --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md Wed Feb 06 19:53:43 2019 -0600
@@ -0,0 +1,36 @@
+# Pidgin Bamboo Terraform +terraform and terraform-libvirt provider +You need to have a `node.tfvars` in the `nodes/` directory which has contents +libvirt_uri = "qemu:///system" +admin_ssh_pubkey = "ssh pubkey" +`libvirt_uri` is the connect string for libvirt and `admin_ssh_pubkey` is the +SSH pubkey that should be accepted for the root user. +`worker_count` is the number of Bamboo agents to provision. +Once that file is created you provision it via: +mkisofs is needed on the machine where terraform is running from to be able to --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/instance-registry-cache.tf Wed Feb 06 19:53:43 2019 -0600
@@ -0,0 +1,80 @@
+variable "registry_cache_disk_size" { default = "53687091200" } # 50gb +variable "registry_cache_memory" { default="1024" } # 1gb +variable "registry_cache_cpu" { default="1" } +variable "admin_ssh_pubkey" {} +resource "libvirt_volume" "registry_cache" { + name = "registry-cache-root" + base_volume_id = "${libvirt_volume.debian_base.id}" + size = "${var.registry_cache_disk_size}" +data "template_file" "registry_cache_user_data" { + ignore_growroot_disabled: false + admin_ssh_pubkey = "${var.admin_ssh_pubkey}" +resource "libvirt_cloudinit_disk" "registry_cache" { + name = "registry-cache-init.iso" + user_data = "${data.template_file.registry_cache_user_data.rendered}" +resource "libvirt_domain" "registry_cache" { + name = "registry-cache" + memory = "${var.registry_cache_memory}" + vcpu = "${var.registry_cache_cpu}" + cloudinit = "${libvirt_cloudinit_disk.registry_cache.id}" +# target_type = "virtio" + volume_id = "${libvirt_volume.registry_cache.id}" +# listen_type = "address" + network_name = "default" +output "registry_cache_ip" { + value = "${libvirt_domain.registry_cache.network_interface.0.addresses}" --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/instance-worker.tf Wed Feb 06 19:53:43 2019 -0600
@@ -0,0 +1,89 @@
+variable "worker_count" { default = "1" } +variable "worker_disk_size" { default = "21474836480" } # 20gb +variable "worker_memory" { default="1024" } # 1gb +variable "worker_cpu" { default="1" } +resource "libvirt_volume" "worker" { + count = "${var.worker_count}" + name = "worker-${count.index}-root" + base_volume_id = "${libvirt_volume.debian_base.id}" + size = "${var.worker_disk_size}" +data "template_file" "worker_user_data" { + count = "${var.worker_count > 0 ? 1 : 0}" + ignore_growroot_disabled: false + admin_ssh_pubkey = "${var.admin_ssh_pubkey}" + index = "${count.index}" +resource "libvirt_cloudinit_disk" "worker" { + count = "${var.worker_count}" + name = "worker-${count.index}-init.iso" + user_data = "${data.template_file.worker_user_data.rendered}" +resource "libvirt_domain" "worker" { + count = "${var.worker_count}" + name = "worker-${count.index}" + memory = "${var.worker_memory}" + vcpu = "${var.worker_cpu}" + cloudinit = "${element(libvirt_cloudinit_disk.worker.*.id, count.index)}" +# target_type = "serial" +# target_type = "virtio" + volume_id = "${element(libvirt_volume.worker.*.id, count.index)}" +# listen_type = "address" + network_name = "default" + value = "${libvirt_domain.worker.*.network_interface.0.addresses}" --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/provider-libvirt.tf Wed Feb 06 19:53:43 2019 -0600
@@ -0,0 +1,6 @@
+variable "libvirt_uri" { default = "qemu:///system" } + uri = "${var.libvirt_uri}" --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/volume-base.tf Wed Feb 06 19:53:43 2019 -0600
@@ -0,0 +1,7 @@
+resource "libvirt_volume" "debian_base" { + source = "https://cdimage.debian.org/cdimage/openstack/9.6.2-20181228/debian-9.6.2-20181228-openstack-amd64.qcow2"