Skip to content
Snippets Groups Projects
Commit a9bfb6f3 authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Add terraform example

parent 032c95b4
No related branches found
No related tags found
No related merge requests found
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}"
}
resource "openstack_networking_network_v2" "network_1" {
name = "network_1"
admin_state_up = "true"
}
resource "openstack_networking_subnet_v2" "subnet_1" {
name = "subnet_1"
network_id = "${openstack_networking_network_v2.network_1.id}"
cidr = "10.8.1.0/24"
ip_version = 4
}
resource "openstack_networking_router_v2" "router_1" {
name = "my_router"
external_gateway = "c0ac8288-c1c7-4458-8d86-71eca7008fab"
}
resource "openstack_networking_router_interface_v2" "router_interface_1" {
router_id = "${openstack_networking_router_v2.router_1.id}"
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
}
resource "openstack_compute_secgroup_v2" "secgroup_1" {
name = "secgroup_1"
description = "ssh access"
rule {
from_port = 22
to_port = 22
ip_protocol = "tcp"
cidr = "0.0.0.0/0"
}
}
provider "openstack" {
}
provider "template" {
}
#!/bin/bash
sudo apt-add-repository ppa:x2go/stable
apt update
apt upgrade
apt install -y xfce4
apt install -y x2goserver x2goserver-xsession
apt install -y zsh s3cmd s3fs
apt install -y python3-openstackclient python3-swiftclient python3-heatclient
ssh_key = "key name"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment