Skip to content
Snippets Groups Projects
Select Git revision
  • a9bfb6f3981bcc5f32714d6e364b45b9910ebeb5
  • master default
2 results

bioinfo-machine.tf

Blame
  • bioinfo-machine.tf 1.42 KiB
    variable "ssh_key" {
      type        = "string"
      description = "The name of the ssh key to use"
    }
    
    variable "flavor" {
      type        = "string"
      description = "The name of the flavor to use"
      default     = "de.NBI.default"
    }
    
    variable "image" {
      type        = "string"
      description = "The name of the image to use"
      default     = "Ubuntu 16.04 Xenial 2017/10/12"
    }
    
    resource "openstack_compute_instance_v2" "instance_1" {
      name            = "instance_1"
      image_name      = "${var.image}"
      flavor_name     = "${var.flavor}"
      key_pair        = "${var.ssh_key}"
      security_groups = ["${openstack_compute_secgroup_v2.secgroup_1.name}"]
      user_data       = "${file("${path.module}/setup-bioinfo-desktop.sh")}"
    
      network {
    	name = "${openstack_networking_network_v2.network_1.name}"
      }
    }
    
    resource "openstack_compute_volume_attach_v2" "attached" {
      instance_id = "${openstack_compute_instance_v2.instance_1.id}"
      volume_id = "${openstack_blockstorage_volume_v2.myvol.id}"
    }
    
    resource "openstack_compute_floatingip_associate_v2" "myip" {
      floating_ip = "${openstack_networking_floatingip_v2.myip.address}"
      instance_id = "${openstack_compute_instance_v2.instance_1.id}"
    }
    
    resource "openstack_networking_floatingip_v2" "myip" {
      pool = "external_network"
    }
    
    resource "openstack_blockstorage_volume_v2" "myvol" {
      name = "myvol"
      size = 20
    }
    
    output "connect via" {
        value = "\nssh -A ubuntu@${openstack_networking_floatingip_v2.myip.address}"
    }