Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions backend_modules/gcp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# GCE - specific configuration

In terraform main.tf file:

provider "google" {
project = "your-project"
region = "your-region"
zone = "your-zone"
}

This module is still WIP.
TO DO:
- add clients
- find a way to mirror/connect suma server to suse's internal (download.suse.de) resources (VPN?)
83 changes: 83 additions & 0 deletions backend_modules/gcp/host/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
provider "google" {
project = var.project_name
region = var.region_name
zone = var.zone_name
}

locals {
name_prefix = var.name_prefix
}

resource "google_compute_address" "proxy" {
name = "proxy-ipv4-address"
}

resource "google_compute_address" "server" {
name = "server-ipv4-address"
}

resource "google_compute_image" "suma-server-42" {
name = "suma-server-42"

raw_disk {
source = "https://storage.googleapis.com/suse-manager-images/SUSE-Manager-Server-BYOS.x86_64-0.9.0-GCE-Build2.16.tar.gz"
}
}

resource "google_compute_image" "suma-proxy-42" {
name = "suma-proxy-42"

raw_disk {
source = "https://storage.googleapis.com/suse-manager-images/SUSE-Manager-Proxy-BYOS.x86_64-0.9.0-GCE-Build2.20.tar.gz"
}
}

#resource "time_sleep" "wait_20_seconds" {
# depends_on = [google_compute_image.suma-proxy-42]
# create_duration = "20s"
#}

resource "google_compute_instance" "suma-proxy-42-instance" {
name = "suma-proxy-42-instance"
machine_type = var.machine_size
depends_on = [ google_compute_image.suma-proxy-42 ]

boot_disk {
initialize_params {
image = "suma-proxy-42"
}
}

network_interface {
# A default network is created for all GCP projects
network = google_compute_network.vpc_network.self_link
access_config {
nat_ip = google_compute_address.proxy.address
}
}
}

resource "google_compute_instance" "suma-server-42-instance" {
name = "suma-server-42-instance"
machine_type = var.machine_size
depends_on = [ google_compute_image.suma-server-42 ]

boot_disk {
initialize_params {
image = "suma-server-42"
}
}

network_interface {
# A default network is created for all GCP projects
network = google_compute_network.vpc_network.self_link
access_config {
nat_ip = google_compute_address.server.address
}
}
}

resource "google_compute_network" "vpc_network" {
name = "terraform-network"
auto_create_subnetworks = "true"
}
6 changes: 6 additions & 0 deletions backend_modules/gcp/host/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
output "proxy" {
value = "${google_compute_instance.suma-proxy-42-instance.name}:${google_compute_instance.suma-proxy-42-instance.network_interface[0].access_config[0].nat_ip}"
}
output "server" {
value = "${google_compute_instance.suma-server-42-instance.name}:${google_compute_instance.suma-server-42-instance.network_interface[0].access_config[0].nat_ip}"
}
52 changes: 52 additions & 0 deletions backend_modules/gcp/host/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
variable "project_name" {
type = "string"
description = "The name of the project to instanciate the instance at."
default = "suse-css-qa"
}

variable "region_name" {
type = "string"
description = "The region that this terraform configuration will instanciate at."
default = "europe-west3"
}

variable "zone_name" {
type = "string"
description = "The zone that this terraform configuration will instanciate at."
default = "europe-west3-b"
}

variable "machine_size" {
type = "string"
description = "The size that this instance will be."
default = "f1-micro"
}

variable "name_prefix" {
description = "a prefix for all names of objects to avoid collisions. E.g. moio-"
default = ""
}

variable "image_name" {
type = "string"
description = "The kind of VM this instance will become"
default = ""
}

variable "script_path" {
type = "string"
description = "Where is the path to the script locally on the machine?"
default = ""
}

variable "private_key_path" {
type = "string"
description = "The path to the private key used to connect to the instance"
default = ""
}

variable "username" {
type = "string"
description = "The name of the user that will be used to remote exec the script"
default = ""
}