diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1ad418c7a49b974bb6f5b72fad74407ea366404a..50f7197cbb1d55d7528c1b511c4ae53f5f92b7cf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,6 +10,7 @@ variables: TF_ROOT: ${CI_PROJECT_DIR}/ TF_VAR_external_network: "xdmod-packer-dmznet" TF_VAR_flavor: "m1.medium" + TF_VAR_data_volume: "xdmod-mysql-db-migration" GIT_SUBMODULE_STRATEGY: "recursive" GIT_SUBMODULE_UPDATE_FLAGS: "--force" diff --git a/main.tf b/main.tf index 15d3d978d9af32dbf8482e0c9ee04bba6b1015d1..375c402b0e6de7e1b4e2660858c9bf22d66a449b 100644 --- a/main.tf +++ b/main.tf @@ -55,6 +55,7 @@ output "keypair_name" { } data "openstack_networking_network_v2" "external_net" {name = var.external_network} +data "openstack_blockstorage_volume_v2" "disk" {name = var.data_volume} # runs the ohpc-instance module - creates ohpc instance using variables defined above # calls functions from dmz-network, import-keypair, and floating-ip-address modules to get values created there for use @@ -70,6 +71,7 @@ module "create-ohpc-instance" { floating_ip_ohpc = module.floating-ip-address.ohpc_address ohpc_user = var.ohpc_user ssh_private_key = var.ssh_private_key + vol_id = data.openstack_blockstorage_volume_v2.disk.id } # runs the ood-instance module - creates ood instance using variables defined above diff --git a/ohpc-instance/main.tf b/ohpc-instance/main.tf index 013957f9d7c0e35f8e33b6881da50bd537aade11..2d4b159d59c6d3d09698a5ad10c0fd5f8c5ebc08 100644 --- a/ohpc-instance/main.tf +++ b/ohpc-instance/main.tf @@ -26,7 +26,7 @@ variable "floating_ip_ohpc" {type = string} variable "ohpc_user" {} variable "ssh_private_key" {} - +variable "vol_id" {} # creates details for the OHPC instance resource "openstack_compute_instance_v2" "ohpc" { @@ -61,6 +61,12 @@ resource "openstack_compute_floatingip_associate_v2" "ohpc" { instance_id = openstack_compute_instance_v2.ohpc.id } +# Attach a volume +resource "openstack_compute_volume_attach_v2" "volume_attach" { + instance_id = openstack_compute_instance_v2.ohpc.id + volume_id = var.vol_id +} + output "id" { value = openstack_compute_instance_v2.ohpc.id } diff --git a/vars.tf b/vars.tf index 4a2526d1f3002a7f8652c740c5d0dcc460b16f55..11d61852277b38cd42cb3e6681e16849317b11b1 100644 --- a/vars.tf +++ b/vars.tf @@ -25,7 +25,7 @@ variable "external_network" {default = "dmznet"} variable "ohpc_user" {default = "centos"} variable "ood_user" {default = "centos"} variable "ssh_private_key" {default = "~/.ssh/id_rsa"} - +variable "data_volume" {default = ""} # variables for node creation module variable "image_compute" {default = "compute-v1"}