From b8c289d4c72541ca2e6aef35c9e15cd2118294f9 Mon Sep 17 00:00:00 2001 From: Andrei Ozerov Date: Tue, 12 Feb 2019 12:17:50 +0300 Subject: [PATCH] Refactor all modules and examples Move all VPC-related manifests into "vpc" directory. Use "selectel" provider instead of "selvpc" to manage Selectel VPC resources. Update all examples to use "selectel" provider to manage projects and users with roles. Refactor all VPC-related modules. --- examples/kubernetes_cluster/README.md | 16 --- examples/kubernetes_cluster/main.tf | 41 ------- examples/project/README.md | 12 -- examples/project/main.tf | 15 --- .../server_with_local_root_disk/README.md | 16 --- examples/server_with_local_root_disk/main.tf | 56 --------- .../server_with_remote_root_disk/README.md | 16 --- examples/server_with_remote_root_disk/main.tf | 59 ---------- .../README.md | 17 --- .../main.tf | 59 ---------- .../server_with_two_remote_disks/README.md | 16 --- examples/server_with_two_remote_disks/main.tf | 63 ---------- examples/vpc/kubernetes_cluster/README.md | 16 +++ examples/vpc/kubernetes_cluster/main.tf | 48 ++++++++ examples/vpc/kubernetes_cluster/vars.tf | 77 ++++++++++++ .../server_local_and_remote_disks/README.md | 16 +++ .../vpc/server_local_and_remote_disks/main.tf | 40 +++++++ .../vpc/server_local_and_remote_disks/vars.tf | 57 +++++++++ examples/vpc/server_local_root_disk/README.md | 16 +++ examples/vpc/server_local_root_disk/main.tf | 38 ++++++ examples/vpc/server_local_root_disk/vars.tf | 49 ++++++++ .../vpc/server_remote_root_disk/README.md | 16 +++ examples/vpc/server_remote_root_disk/main.tf | 38 ++++++ examples/vpc/server_remote_root_disk/vars.tf | 51 ++++++++ .../README.md | 16 +++ .../server_remote_root_disk_two_ports/main.tf | 38 ++++++ .../server_remote_root_disk_two_ports/vars.tf | 53 +++++++++ modules/account_token/README.md | 11 -- modules/account_token/outputs.tf | 3 - modules/account_token/vars.tf | 3 - modules/flavor/vars.tf | 24 ---- modules/image_datasource/vars.tf | 4 - modules/keypair/README.md | 15 --- modules/keypair/outputs.tf | 3 - modules/keypair/vars.tf | 12 -- modules/kubernetes_cluster/README.md | 30 ----- modules/kubernetes_cluster/main.tf | 9 -- modules/kubernetes_cluster/vars.tf | 32 ----- .../README.md | 14 --- .../main.tf | 3 - .../outputs.tf | 3 - .../vars.tf | 4 - modules/license/README.md | 15 --- modules/license/outputs.tf | 3 - modules/license/vars.tf | 11 -- modules/project/README.md | 11 -- modules/project/outputs.tf | 3 - modules/project/vars.tf | 4 - modules/project_token/README.md | 11 -- modules/project_token/main.tf | 3 - modules/project_token/outputs.tf | 3 - modules/project_token/vars.tf | 3 - modules/role/README.md | 15 --- modules/role/outputs.tf | 3 - modules/role/vars.tf | 7 -- modules/server_local_root_disk/README.md | 27 ----- modules/server_local_root_disk/main.tf | 29 ----- modules/server_local_root_disk/vars.tf | 27 ----- modules/server_remote_root_disk/README.md | 34 ------ modules/server_remote_root_disk/main.tf | 43 ------- modules/server_remote_root_disk/vars.tf | 37 ------ .../README.md | 36 ------ .../server_remote_root_disk_two_ports/main.tf | 73 ------------ .../server_remote_root_disk_two_ports/vars.tf | 37 ------ modules/server_two_remote_disks/README.md | 43 ------- modules/server_two_remote_disks/main.tf | 54 --------- modules/server_two_remote_disks/vars.tf | 47 -------- modules/subnet/README.md | 17 --- modules/subnet/outputs.tf | 3 - modules/subnet/vars.tf | 17 --- modules/user/README.md | 13 -- modules/user/outputs.tf | 3 - modules/user/vars.tf | 8 -- modules/vpc/account_token/README.md | 11 ++ modules/{ => vpc}/account_token/main.tf | 2 +- modules/vpc/account_token/outputs.tf | 3 + modules/vpc/account_token/vars.tf | 1 + modules/{ => vpc}/flavor/README.md | 0 modules/{ => vpc}/flavor/main.tf | 0 modules/{ => vpc}/flavor/outputs.tf | 0 modules/vpc/flavor/vars.tf | 19 +++ modules/{ => vpc}/floatingip/README.md | 0 modules/{ => vpc}/floatingip/main.tf | 0 modules/{ => vpc}/floatingip/outputs.tf | 0 modules/{ => vpc}/image_datasource/README.md | 0 modules/{ => vpc}/image_datasource/main.tf | 0 modules/{ => vpc}/image_datasource/outputs.tf | 0 modules/vpc/image_datasource/vars.tf | 3 + modules/vpc/keypair/README.md | 15 +++ modules/{ => vpc}/keypair/main.tf | 6 +- modules/vpc/keypair/outputs.tf | 7 ++ modules/vpc/keypair/vars.tf | 7 ++ modules/vpc/kubernetes_cluster/README.md | 4 + modules/vpc/kubernetes_cluster/main.tf | 80 +++++++++++++ .../{ => vpc}/kubernetes_cluster/outputs.tf | 0 modules/vpc/kubernetes_cluster/vars.tf | 91 ++++++++++++++ modules/vpc/license/README.md | 15 +++ modules/{ => vpc}/license/main.tf | 2 +- modules/vpc/license/outputs.tf | 3 + modules/vpc/license/vars.tf | 5 + modules/vpc/nat/README.md | 21 ++++ modules/vpc/nat/main.tf | 23 ++++ modules/vpc/nat/outputs.tf | 11 ++ modules/vpc/nat/vars.tf | 15 +++ modules/vpc/project/README.md | 11 ++ modules/{ => vpc}/project/main.tf | 2 +- modules/vpc/project/outputs.tf | 3 + modules/vpc/project/vars.tf | 3 + modules/vpc/project_token/README.md | 11 ++ modules/vpc/project_token/main.tf | 3 + modules/vpc/project_token/outputs.tf | 3 + modules/vpc/project_token/vars.tf | 1 + modules/vpc/project_with_user/README.md | 19 +++ modules/vpc/project_with_user/main.tf | 16 +++ modules/vpc/project_with_user/outputs.tf | 11 ++ modules/vpc/project_with_user/vars.tf | 9 ++ modules/vpc/role/README.md | 13 ++ modules/{ => vpc}/role/main.tf | 2 +- modules/vpc/role/outputs.tf | 3 + modules/vpc/role/vars.tf | 3 + .../server_local_and_remote_disks/README.md | 44 +++++++ .../vpc/server_local_and_remote_disks/main.tf | 100 ++++++++++++++++ .../server_local_and_remote_disks}/outputs.tf | 0 .../vpc/server_local_and_remote_disks/vars.tf | 45 +++++++ modules/vpc/server_local_root_disk/README.md | 40 +++++++ modules/vpc/server_local_root_disk/main.tf | 75 ++++++++++++ .../server_local_root_disk/outputs.tf | 0 modules/vpc/server_local_root_disk/vars.tf | 37 ++++++ modules/vpc/server_remote_root_disk/README.md | 44 +++++++ modules/vpc/server_remote_root_disk/main.tf | 88 ++++++++++++++ .../server_remote_root_disk}/outputs.tf | 4 - modules/vpc/server_remote_root_disk/vars.tf | 41 +++++++ .../README.md | 44 +++++++ .../server_remote_root_disk_two_ports/main.tf | 111 ++++++++++++++++++ .../outputs.tf | 0 .../server_remote_root_disk_two_ports/vars.tf | 41 +++++++ modules/vpc/subnet/README.md | 17 +++ modules/{ => vpc}/subnet/main.tf | 2 +- modules/vpc/subnet/outputs.tf | 3 + modules/vpc/subnet/vars.tf | 11 ++ modules/vpc/user/README.md | 13 ++ modules/{ => vpc}/user/main.tf | 2 +- modules/vpc/user/outputs.tf | 3 + modules/vpc/user/vars.tf | 5 + modules/vpc/vrrp_subnet/README.md | 17 +++ modules/{ => vpc}/vrrp_subnet/main.tf | 2 +- modules/vpc/vrrp_subnet/outputs.tf | 3 + modules/vpc/vrrp_subnet/vars.tf | 13 ++ modules/vrrp_subnet/README.md | 17 --- modules/vrrp_subnet/outputs.tf | 3 - modules/vrrp_subnet/vars.tf | 21 ---- 151 files changed, 1819 insertions(+), 1249 deletions(-) delete mode 100644 examples/kubernetes_cluster/README.md delete mode 100644 examples/kubernetes_cluster/main.tf delete mode 100644 examples/project/README.md delete mode 100644 examples/project/main.tf delete mode 100644 examples/server_with_local_root_disk/README.md delete mode 100644 examples/server_with_local_root_disk/main.tf delete mode 100644 examples/server_with_remote_root_disk/README.md delete mode 100644 examples/server_with_remote_root_disk/main.tf delete mode 100644 examples/server_with_remote_root_disk_two_ports/README.md delete mode 100644 examples/server_with_remote_root_disk_two_ports/main.tf delete mode 100644 examples/server_with_two_remote_disks/README.md delete mode 100644 examples/server_with_two_remote_disks/main.tf create mode 100644 examples/vpc/kubernetes_cluster/README.md create mode 100644 examples/vpc/kubernetes_cluster/main.tf create mode 100644 examples/vpc/kubernetes_cluster/vars.tf create mode 100644 examples/vpc/server_local_and_remote_disks/README.md create mode 100644 examples/vpc/server_local_and_remote_disks/main.tf create mode 100644 examples/vpc/server_local_and_remote_disks/vars.tf create mode 100644 examples/vpc/server_local_root_disk/README.md create mode 100644 examples/vpc/server_local_root_disk/main.tf create mode 100644 examples/vpc/server_local_root_disk/vars.tf create mode 100644 examples/vpc/server_remote_root_disk/README.md create mode 100644 examples/vpc/server_remote_root_disk/main.tf create mode 100644 examples/vpc/server_remote_root_disk/vars.tf create mode 100644 examples/vpc/server_remote_root_disk_two_ports/README.md create mode 100644 examples/vpc/server_remote_root_disk_two_ports/main.tf create mode 100644 examples/vpc/server_remote_root_disk_two_ports/vars.tf delete mode 100644 modules/account_token/README.md delete mode 100644 modules/account_token/outputs.tf delete mode 100644 modules/account_token/vars.tf delete mode 100644 modules/flavor/vars.tf delete mode 100644 modules/image_datasource/vars.tf delete mode 100644 modules/keypair/README.md delete mode 100644 modules/keypair/outputs.tf delete mode 100644 modules/keypair/vars.tf delete mode 100644 modules/kubernetes_cluster/README.md delete mode 100644 modules/kubernetes_cluster/main.tf delete mode 100644 modules/kubernetes_cluster/vars.tf delete mode 100644 modules/kubernetes_cluster_template_datasource/README.md delete mode 100644 modules/kubernetes_cluster_template_datasource/main.tf delete mode 100644 modules/kubernetes_cluster_template_datasource/outputs.tf delete mode 100644 modules/kubernetes_cluster_template_datasource/vars.tf delete mode 100644 modules/license/README.md delete mode 100644 modules/license/outputs.tf delete mode 100644 modules/license/vars.tf delete mode 100644 modules/project/README.md delete mode 100644 modules/project/outputs.tf delete mode 100644 modules/project/vars.tf delete mode 100644 modules/project_token/README.md delete mode 100644 modules/project_token/main.tf delete mode 100644 modules/project_token/outputs.tf delete mode 100644 modules/project_token/vars.tf delete mode 100644 modules/role/README.md delete mode 100644 modules/role/outputs.tf delete mode 100644 modules/role/vars.tf delete mode 100644 modules/server_local_root_disk/README.md delete mode 100644 modules/server_local_root_disk/main.tf delete mode 100644 modules/server_local_root_disk/vars.tf delete mode 100644 modules/server_remote_root_disk/README.md delete mode 100644 modules/server_remote_root_disk/main.tf delete mode 100644 modules/server_remote_root_disk/vars.tf delete mode 100644 modules/server_remote_root_disk_two_ports/README.md delete mode 100644 modules/server_remote_root_disk_two_ports/main.tf delete mode 100644 modules/server_remote_root_disk_two_ports/vars.tf delete mode 100644 modules/server_two_remote_disks/README.md delete mode 100644 modules/server_two_remote_disks/main.tf delete mode 100644 modules/server_two_remote_disks/vars.tf delete mode 100644 modules/subnet/README.md delete mode 100644 modules/subnet/outputs.tf delete mode 100644 modules/subnet/vars.tf delete mode 100644 modules/user/README.md delete mode 100644 modules/user/outputs.tf delete mode 100644 modules/user/vars.tf create mode 100644 modules/vpc/account_token/README.md rename modules/{ => vpc}/account_token/main.tf (50%) create mode 100644 modules/vpc/account_token/outputs.tf create mode 100644 modules/vpc/account_token/vars.tf rename modules/{ => vpc}/flavor/README.md (100%) rename modules/{ => vpc}/flavor/main.tf (100%) rename modules/{ => vpc}/flavor/outputs.tf (100%) create mode 100644 modules/vpc/flavor/vars.tf rename modules/{ => vpc}/floatingip/README.md (100%) rename modules/{ => vpc}/floatingip/main.tf (100%) rename modules/{ => vpc}/floatingip/outputs.tf (100%) rename modules/{ => vpc}/image_datasource/README.md (100%) rename modules/{ => vpc}/image_datasource/main.tf (100%) rename modules/{ => vpc}/image_datasource/outputs.tf (100%) create mode 100644 modules/vpc/image_datasource/vars.tf create mode 100644 modules/vpc/keypair/README.md rename modules/{ => vpc}/keypair/main.tf (54%) create mode 100644 modules/vpc/keypair/outputs.tf create mode 100644 modules/vpc/keypair/vars.tf create mode 100644 modules/vpc/kubernetes_cluster/README.md create mode 100644 modules/vpc/kubernetes_cluster/main.tf rename modules/{ => vpc}/kubernetes_cluster/outputs.tf (100%) create mode 100644 modules/vpc/kubernetes_cluster/vars.tf create mode 100644 modules/vpc/license/README.md rename modules/{ => vpc}/license/main.tf (70%) create mode 100644 modules/vpc/license/outputs.tf create mode 100644 modules/vpc/license/vars.tf create mode 100644 modules/vpc/nat/README.md create mode 100644 modules/vpc/nat/main.tf create mode 100644 modules/vpc/nat/outputs.tf create mode 100644 modules/vpc/nat/vars.tf create mode 100644 modules/vpc/project/README.md rename modules/{ => vpc}/project/main.tf (54%) create mode 100644 modules/vpc/project/outputs.tf create mode 100644 modules/vpc/project/vars.tf create mode 100644 modules/vpc/project_token/README.md create mode 100644 modules/vpc/project_token/main.tf create mode 100644 modules/vpc/project_token/outputs.tf create mode 100644 modules/vpc/project_token/vars.tf create mode 100644 modules/vpc/project_with_user/README.md create mode 100644 modules/vpc/project_with_user/main.tf create mode 100644 modules/vpc/project_with_user/outputs.tf create mode 100644 modules/vpc/project_with_user/vars.tf create mode 100644 modules/vpc/role/README.md rename modules/{ => vpc}/role/main.tf (64%) create mode 100644 modules/vpc/role/outputs.tf create mode 100644 modules/vpc/role/vars.tf create mode 100644 modules/vpc/server_local_and_remote_disks/README.md create mode 100644 modules/vpc/server_local_and_remote_disks/main.tf rename modules/{server_remote_root_disk => vpc/server_local_and_remote_disks}/outputs.tf (100%) create mode 100644 modules/vpc/server_local_and_remote_disks/vars.tf create mode 100644 modules/vpc/server_local_root_disk/README.md create mode 100644 modules/vpc/server_local_root_disk/main.tf rename modules/{ => vpc}/server_local_root_disk/outputs.tf (100%) create mode 100644 modules/vpc/server_local_root_disk/vars.tf create mode 100644 modules/vpc/server_remote_root_disk/README.md create mode 100644 modules/vpc/server_remote_root_disk/main.tf rename modules/{server_two_remote_disks => vpc/server_remote_root_disk}/outputs.tf (72%) create mode 100644 modules/vpc/server_remote_root_disk/vars.tf create mode 100644 modules/vpc/server_remote_root_disk_two_ports/README.md create mode 100644 modules/vpc/server_remote_root_disk_two_ports/main.tf rename modules/{ => vpc}/server_remote_root_disk_two_ports/outputs.tf (100%) create mode 100644 modules/vpc/server_remote_root_disk_two_ports/vars.tf create mode 100644 modules/vpc/subnet/README.md rename modules/{ => vpc}/subnet/main.tf (79%) create mode 100644 modules/vpc/subnet/outputs.tf create mode 100644 modules/vpc/subnet/vars.tf create mode 100644 modules/vpc/user/README.md rename modules/{ => vpc}/user/main.tf (61%) create mode 100644 modules/vpc/user/outputs.tf create mode 100644 modules/vpc/user/vars.tf create mode 100644 modules/vpc/vrrp_subnet/README.md rename modules/{ => vpc}/vrrp_subnet/main.tf (81%) create mode 100644 modules/vpc/vrrp_subnet/outputs.tf create mode 100644 modules/vpc/vrrp_subnet/vars.tf delete mode 100644 modules/vrrp_subnet/README.md delete mode 100644 modules/vrrp_subnet/outputs.tf delete mode 100644 modules/vrrp_subnet/vars.tf diff --git a/examples/kubernetes_cluster/README.md b/examples/kubernetes_cluster/README.md deleted file mode 100644 index f17c44f..0000000 --- a/examples/kubernetes_cluster/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Kubernetes cluster - -This environment will create following resources in the OpenStack project: - - * keypair - * flavor - * Kubernetes multi-master cluster with several nodes - -To run this environment you need to export authorization variables that can be -obtained from [VPC access page](https://my.selectel.ru/vpc/access): - -```bash -$ source rc.sh -$ terraform init -$ terraform apply -``` \ No newline at end of file diff --git a/examples/kubernetes_cluster/main.tf b/examples/kubernetes_cluster/main.tf deleted file mode 100644 index 4a2a75d..0000000 --- a/examples/kubernetes_cluster/main.tf +++ /dev/null @@ -1,41 +0,0 @@ -# Generate random string that will be used as name for all resources. -resource "random_string" "random_name" { - length = 12 - special = false - upper = false -} - -# Create OpenStack keypair with current public key. -module "keypair" { - source = "../../modules/keypair" - - keypair_name = "${random_string.random_name.result}" - keypair_public_key = "${file("~/.ssh/id_rsa.pub")}" -} - -# Create OpenStack flavor without local disk. -module "flavor" { - source = "../../modules/flavor" - - flavor_name = "${random_string.random_name.result}" - flavor_vcpus = 2 - flavor_ram_mb = 2048 - flavor_local_disk_gb = 0 -} - -# Find public Kubernetes cluster template. -module "kubernetes_cluster_template_datasource" { - source = "../../modules/kubernetes_cluster_template_datasource" -} - -# Create a single Kubernetes cluster. -module "kubernetes_cluster" { - source = "../../modules/kubernetes_cluster" - - cluster_template_id = "${module.kubernetes_cluster_template_datasource.cluster_template_id}" - cluster_keypair = "${module.keypair.keypair_id}" - cluster_master_flavor = "${module.flavor.flavor_id}" - cluster_flavor = "${module.flavor.flavor_id}" - cluster_master_count = 3 - cluster_node_count = 3 -} diff --git a/examples/project/README.md b/examples/project/README.md deleted file mode 100644 index 4ab4ca1..0000000 --- a/examples/project/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Project - -This example will create a single SelVPC project with a random name. - -To run this environment you need to export `SEL_TOKEN` variable that can be -obtained from [Selectel access page](https://my.selectel.ru/profile/apikeys): - -```bash -$ export SEL_TOKEN=XXXXXX_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -$ terraform init -$ terraform apply -``` diff --git a/examples/project/main.tf b/examples/project/main.tf deleted file mode 100644 index 3f99e30..0000000 --- a/examples/project/main.tf +++ /dev/null @@ -1,15 +0,0 @@ -# Generate random string that will be used as name for a project. -resource "random_string" "random_name" { - length = 12 - - special = false - upper = false - number = false -} - -# Create a single SelVPC project. -module "project" { - source = "../../modules/project" - - project_name = "${random_string.random_name.result}" -} diff --git a/examples/server_with_local_root_disk/README.md b/examples/server_with_local_root_disk/README.md deleted file mode 100644 index 1fa87fb..0000000 --- a/examples/server_with_local_root_disk/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Server with local root disk - -This environment will create following resources in the OpenStack project: - - * keypair - * flavor - * server with associated floating IP and local root disk - -To run this environment you need to export authorization variables that can be -obtained from [VPC access page](https://my.selectel.ru/vpc/access): - -```bash -$ source rc.sh -$ terraform init -$ terraform apply -``` diff --git a/examples/server_with_local_root_disk/main.tf b/examples/server_with_local_root_disk/main.tf deleted file mode 100644 index b5e74f4..0000000 --- a/examples/server_with_local_root_disk/main.tf +++ /dev/null @@ -1,56 +0,0 @@ -# Generate random string that will be used as name for all resources. -resource "random_string" "random_name" { - length = 12 - - special = false - upper = false - number = false -} - -# Create OpenStack keypair with current public key. -module "keypair" { - source = "../../modules/keypair" - - keypair_name = "${random_string.random_name.result}-keypair" - keypair_public_key = "${file("~/.ssh/id_rsa.pub")}" -} - -# Create OpenStack flavor without local disk. -module "flavor" { - source = "../../modules/flavor" - - flavor_name = "${random_string.random_name.result}-flavor" - flavor_vcpus = 4 - flavor_ram_mb = 4096 - flavor_local_disk_gb = 8 -} - -# Search for the public image ID. -module "image_datasource" { - source = "../../modules/image_datasource" - - image_name = "Ubuntu 16.04 LTS 64-bit" -} - -# Create OpenStack Compute instance. -module "server_local_root_disk" { - source = "../../modules/server_local_root_disk" - - server_name = "${random_string.random_name.result}-server" - - server_flavor_id = "${module.flavor.flavor_id}" - server_keypair_name = "${module.keypair.keypair_id}" - server_image_id = "${module.image_datasource.image_id}" - server_availability_zone = "ru-3a" -} - -# Create single OpenStack Floating IP for the instance. -module "floatingip" { - source = "../../modules/floatingip" -} - -# Associate Floating IP with instance network interface. -resource "openstack_networking_floatingip_associate_v2" "association_1" { - port_id = "${module.server_local_root_disk.server_port_id}" - floating_ip = "${module.floatingip.floatingip_address}" -} \ No newline at end of file diff --git a/examples/server_with_remote_root_disk/README.md b/examples/server_with_remote_root_disk/README.md deleted file mode 100644 index d13e460..0000000 --- a/examples/server_with_remote_root_disk/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Server with remote root disk - -This environment will create following resources in the OpenStack project: - - * keypair - * flavor - * server with associated floating IP and root remote disk - -To run this environment you need to export authorization variables that can be -obtained from [VPC access page](https://my.selectel.ru/vpc/access): - -```bash -$ source rc.sh -$ terraform init -$ terraform apply -``` diff --git a/examples/server_with_remote_root_disk/main.tf b/examples/server_with_remote_root_disk/main.tf deleted file mode 100644 index 0bda1bd..0000000 --- a/examples/server_with_remote_root_disk/main.tf +++ /dev/null @@ -1,59 +0,0 @@ -# Generate random string that will be used as name for all resources. -resource "random_string" "random_name" { - length = 12 - - special = false - upper = false - number = false -} - -# Create OpenStack keypair with current public key. -module "keypair" { - source = "../../modules/keypair" - - keypair_name = "${random_string.random_name.result}-keypair" - keypair_public_key = "${file("~/.ssh/id_rsa.pub")}" -} - -# Create OpenStack flavor without local disk. -module "flavor" { - source = "../../modules/flavor" - - flavor_name = "${random_string.random_name.result}-flavor" - flavor_vcpus = 4 - flavor_ram_mb = 4096 - flavor_local_disk_gb = 0 -} - -# Search for the public image ID. -module "image_datasource" { - source = "../../modules/image_datasource" - - image_name = "Ubuntu 16.04 LTS 64-bit" -} - -# Create OpenStack Compute instance. -module "server_remote_root_disk" { - source = "../../modules/server_remote_root_disk" - - server_name = "${random_string.random_name.result}-server" - - server_flavor_id = "${module.flavor.flavor_id}" - server_keypair_name = "${module.keypair.keypair_id}" - server_image_id = "${module.image_datasource.image_id}" - server_availability_zone = "ru-3a" - - server_volume_size_gb = 8 - server_volume_type = "fast.ru-3a" -} - -# Create single OpenStack Floating IP for the instance. -module "floatingip" { - source = "../../modules/floatingip" -} - -# Associate Floating IP with instance network interface. -resource "openstack_networking_floatingip_associate_v2" "association_1" { - port_id = "${module.server_remote_root_disk.server_port_id}" - floating_ip = "${module.floatingip.floatingip_address}" -} diff --git a/examples/server_with_remote_root_disk_two_ports/README.md b/examples/server_with_remote_root_disk_two_ports/README.md deleted file mode 100644 index 6a9a4bc..0000000 --- a/examples/server_with_remote_root_disk_two_ports/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Server with remote root disk and two network ports - -This environment will create following resources in the OpenStack project: - - * keypair - * flavor - * network subnet and port - * server with remote root disk, two network ports and associated floating IP - -To run this environment you need to export authorization variables that can be -obtained from [VPC access page](https://my.selectel.ru/vpc/access): - -```bash -$ source rc.sh -$ terraform init -$ terraform apply -``` diff --git a/examples/server_with_remote_root_disk_two_ports/main.tf b/examples/server_with_remote_root_disk_two_ports/main.tf deleted file mode 100644 index a12c354..0000000 --- a/examples/server_with_remote_root_disk_two_ports/main.tf +++ /dev/null @@ -1,59 +0,0 @@ -# Generate random string that will be used as name for all resources. -resource "random_string" "random_name" { - length = 12 - - special = false - upper = false - number = false -} - -# Create OpenStack keypair with current public key. -module "keypair" { - source = "../../modules/keypair" - - keypair_name = "${random_string.random_name.result}-keypair" - keypair_public_key = "${file("~/.ssh/id_rsa.pub")}" -} - -# Create OpenStack flavor without local disk. -module "flavor" { - source = "../../modules/flavor" - - flavor_name = "${random_string.random_name.result}-flavor" - flavor_vcpus = 4 - flavor_ram_mb = 4096 - flavor_local_disk_gb = 0 -} - -# Search for the public image ID. -module "image_datasource" { - source = "../../modules/image_datasource" - - image_name = "Ubuntu 16.04 LTS 64-bit" -} - -# Create OpenStack Compute instance. -module "server_remote_root_disk_two_ports" { - source = "../../modules/server_remote_root_disk_two_ports" - - server_name = "${random_string.random_name.result}-server" - - server_flavor_id = "${module.flavor.flavor_id}" - server_keypair_name = "${module.keypair.keypair_id}" - server_image_id = "${module.image_datasource.image_id}" - server_availability_zone = "ru-3a" - - server_volume_size_gb = 8 - server_volume_type = "fast.ru-3a" -} - -# Create single OpenStack Floating IP for the instance. -module "floatingip" { - source = "../../modules/floatingip" -} - -# Associate Floating IP with instance network interface. -resource "openstack_networking_floatingip_associate_v2" "association_1" { - port_id = "${module.server_remote_root_disk_two_ports.server_first_port_id}" - floating_ip = "${module.floatingip.floatingip_address}" -} diff --git a/examples/server_with_two_remote_disks/README.md b/examples/server_with_two_remote_disks/README.md deleted file mode 100644 index 4da7088..0000000 --- a/examples/server_with_two_remote_disks/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Server with two remote disks - -This environment will create following resources in the OpenStack project: - - * keypair - * flavor - * server with associated floating IP and two remote disks - -To run this environment you need to export authorization variables that can be -obtained from [VPC access page](https://my.selectel.ru/vpc/access): - -```bash -$ source rc.sh -$ terraform init -$ terraform apply -``` diff --git a/examples/server_with_two_remote_disks/main.tf b/examples/server_with_two_remote_disks/main.tf deleted file mode 100644 index 71479b5..0000000 --- a/examples/server_with_two_remote_disks/main.tf +++ /dev/null @@ -1,63 +0,0 @@ -# Generate random string that will be used as name for all resources. -resource "random_string" "random_name" { - length = 12 - - special = false - upper = false - number = false -} - -# Create OpenStack keypair with current public key. -module "keypair" { - source = "../../modules/keypair" - - keypair_name = "${random_string.random_name.result}-keypair" - keypair_public_key = "${file("~/.ssh/id_rsa.pub")}" -} - -# Create OpenStack flavor without local disk. -module "flavor" { - source = "../../modules/flavor" - - flavor_name = "${random_string.random_name.result}-flavor" - flavor_vcpus = 4 - flavor_ram_mb = 4096 - flavor_local_disk_gb = 0 -} - -# Search for the public image ID. -module "image_datasource" { - source = "../../modules/image_datasource" - - image_name = "Ubuntu 16.04 LTS 64-bit" -} - -# Create OpenStack Compute instance. -module "server_two_remote_disks" { - source = "../../modules/server_two_remote_disks" - - server_name = "${random_string.random_name.result}-server" - - server_flavor_id = "${module.flavor.flavor_id}" - server_keypair_name = "${module.keypair.keypair_id}" - server_image_id = "${module.image_datasource.image_id}" - server_availability_zone = "ru-3a" - - server_root_volume_size_gb = 8 - server_root_volume_type = "fast.ru-3a" - - server_second_volume_size_gb = 5 - server_second_volume_type = "fast.ru-3a" -} - -# Create single OpenStack Floating IP for the instance. -module "floatingip" { - source = "../../modules/floatingip" -} - -# Associate Floating IP with instance network interface. -resource "openstack_networking_floatingip_associate_v2" "association_1" { - port_id = "${module.server_two_remote_disks.server_port_id}" - floating_ip = "${module.floatingip.floatingip_address}" -} - diff --git a/examples/vpc/kubernetes_cluster/README.md b/examples/vpc/kubernetes_cluster/README.md new file mode 100644 index 0000000..7f6bfed --- /dev/null +++ b/examples/vpc/kubernetes_cluster/README.md @@ -0,0 +1,16 @@ +# Kubernetes cluster + +This environment will create a Selectel VPC project with a single Kubernetes +cluster. + +## Example usage + +``` +terraform init + +env TF_VAR_sel_account=xxxxx TF_VAR_sel_token=yyy_xxx \ + terraform apply -target=module.project_with_user + +env TF_VAR_sel_account=xxxxx TF_VAR_sel_token=yyy_xxx \ + terraform apply +``` diff --git a/examples/vpc/kubernetes_cluster/main.tf b/examples/vpc/kubernetes_cluster/main.tf new file mode 100644 index 0000000..0ae3c01 --- /dev/null +++ b/examples/vpc/kubernetes_cluster/main.tf @@ -0,0 +1,48 @@ +# Initialize Selectel provider with token. +provider "selectel" { + token = "${var.sel_token}" +} + +# Create the main project with user. +# This module should be applied first. +module "project_with_user" { + source = "../../../modules/vpc/project_with_user" + + project_name = "${var.project_name}" + user_name = "${var.user_name}" + user_password = "${var.user_password}" +} + +# Create an OpenStack Compute instance. +module "kubernetes_cluster" { + source = "../../../modules/vpc/kubernetes_cluster" + + # OpenStack auth. + os_project_name = "${var.project_name}" + os_user_name = "${var.user_name}" + os_user_password = "${var.user_password}" + os_domain_name = "${var.sel_account}" + os_auth_url = "${var.os_auth_url}" + os_region = "${var.os_region}" + + # Kubernetes cluster common parameters. + cluster_name = "${var.cluster_name}" + cluster_zone = "${var.cluster_zone}" + cluster_kube_version = "${var.cluster_kube_version}" + cluster_ssh_key = "${file("~/.ssh/id_rsa.pub")}" + cluster_ssh_key_user = "${module.project_with_user.user_id}" + cluster_master_lb_enabled = "${var.cluster_master_lb_enabled}" + cluster_master_floating_ip = "${var.cluster_master_floating_ip}" + cluster_docker_volume_size = "${var.cluster_docker_volume_size}" + cluster_etcd_volume_size = "${var.cluster_etcd_volume_size}" + + # Kubernetes cluster masters parameters. + cluster_master_count = "${var.cluster_master_count}" + cluster_master_vcpus = "${var.cluster_master_vcpus}" + cluster_master_ram = "${var.cluster_master_ram}" + + # Kubernetes cluster nodes parameters. + cluster_node_count = "${var.cluster_node_count}" + cluster_node_vcpus = "${var.cluster_node_vcpus}" + cluster_node_ram = "${var.cluster_node_ram}" +} \ No newline at end of file diff --git a/examples/vpc/kubernetes_cluster/vars.tf b/examples/vpc/kubernetes_cluster/vars.tf new file mode 100644 index 0000000..bdcb9c8 --- /dev/null +++ b/examples/vpc/kubernetes_cluster/vars.tf @@ -0,0 +1,77 @@ +variable "sel_account" {} + +variable "sel_token" {} + +variable "project_name" { + default = "tf_project" +} + +variable "user_name" { + default = "tf_user" +} + +variable "user_password" {} + +variable "keypair_name" { + default = "tf_keypair" +} + +variable "os_auth_url" { + default = "https://api.selvpc.ru/identity/v3" +} + +variable "os_region" { + default = "ru-3" +} + +variable "cluster_name" { + default = "tf_cluster" +} + +variable "cluster_zone" { + default = "ru-3a" +} + +variable "cluster_kube_version" { + default = "v1.12.4" +} + +variable "cluster_master_count" { + default = 1 +} + +variable "cluster_master_vcpus" { + default = 2 +} + +variable "cluster_master_ram" { + default = 2048 +} + +variable "cluster_node_count" { + default = 2 +} + +variable "cluster_node_vcpus" { + default = 2 +} + +variable "cluster_node_ram" { + default = 2048 +} + +variable "cluster_master_lb_enabled" { + default = false +} + +variable "cluster_docker_volume_size" { + default = 10 +} + +variable "cluster_etcd_volume_size" { + default = "10" +} + +variable "cluster_master_floating_ip" { + default = "True" +} \ No newline at end of file diff --git a/examples/vpc/server_local_and_remote_disks/README.md b/examples/vpc/server_local_and_remote_disks/README.md new file mode 100644 index 0000000..7f2132d --- /dev/null +++ b/examples/vpc/server_local_and_remote_disks/README.md @@ -0,0 +1,16 @@ +# Server with local root disk + +This environment will create a Selectel VPC project with a single server booted +from a local disk with additional remote disk attached. + +## Example usage + +``` +terraform init + +env TF_VAR_sel_account=xxxxx TF_VAR_sel_token=yyy_xxx \ + terraform apply -target=module.project_with_user + +env TF_VAR_sel_account=xxxxx TF_VAR_sel_token=yyy_xxx \ + terraform apply +``` diff --git a/examples/vpc/server_local_and_remote_disks/main.tf b/examples/vpc/server_local_and_remote_disks/main.tf new file mode 100644 index 0000000..0d66500 --- /dev/null +++ b/examples/vpc/server_local_and_remote_disks/main.tf @@ -0,0 +1,40 @@ +# Initialize Selectel provider with token. +provider "selectel" { + token = "${var.sel_token}" +} + +# Create the main project with user. +# This module should be applied first: +# terraform apply -target=module.project_with_user +module "project_with_user" { + source = "../../../modules/vpc/project_with_user" + + project_name = "${var.project_name}" + user_name = "${var.user_name}" + user_password = "${var.user_password}" +} + +# Create an OpenStack Compute instance. +module "server_local_and_remote_disks" { + source = "../../../modules/vpc/server_local_and_remote_disks" + + # OpenStack auth. + os_project_name = "${var.project_name}" + os_user_name = "${var.user_name}" + os_user_password = "${var.user_password}" + os_domain_name = "${var.sel_account}" + os_auth_url = "${var.os_auth_url}" + os_region = "${var.os_region}" + + # OpenStack Instance parameters. + server_name = "${var.server_name}" + server_zone = "${var.server_zone}" + server_vcpus = "${var.server_vcpus}" + server_ram_mb = "${var.server_ram_mb}" + server_root_disk_gb = "${var.server_root_disk_gb}" + server_second_disk_gb = "${var.server_second_disk_gb}" + server_second_volume_type = "${var.server_second_volume_type}" + server_image_name = "${var.server_image_name}" + server_ssh_key = "${file("~/.ssh/id_rsa.pub")}" + server_ssh_key_user = "${module.project_with_user.user_id}" +} \ No newline at end of file diff --git a/examples/vpc/server_local_and_remote_disks/vars.tf b/examples/vpc/server_local_and_remote_disks/vars.tf new file mode 100644 index 0000000..0cdbfc7 --- /dev/null +++ b/examples/vpc/server_local_and_remote_disks/vars.tf @@ -0,0 +1,57 @@ +variable "sel_account" {} + +variable "sel_token" {} + +variable "project_name" { + default = "tf_project" +} + +variable "user_name" { + default = "tf_user" +} + +variable "user_password" {} + +variable "keypair_name" { + default = "tf_keypair" +} + +variable "os_auth_url" { + default = "https://api.selvpc.ru/identity/v3" +} + +variable "os_region" { + default = "ru-3" +} + +variable "server_name" { + default = "tf_server" +} + +variable "server_zone" { + default = "ru-3a" +} + +variable "server_vcpus" { + default = 4 +} + +variable "server_ram_mb" { + default = 8192 +} + +variable "server_root_disk_gb" { + default = 8 +} + +variable "server_second_disk_gb" { + default = 5 +} + +variable "server_second_volume_type" { + default = "fast.ru-3a" +} + +variable "server_image_name" { + default = "Ubuntu 18.04 LTS 64-bit" +} diff --git a/examples/vpc/server_local_root_disk/README.md b/examples/vpc/server_local_root_disk/README.md new file mode 100644 index 0000000..61dbea9 --- /dev/null +++ b/examples/vpc/server_local_root_disk/README.md @@ -0,0 +1,16 @@ +# Server with local root disk + +This environment will create a Selectel VPC project with a single server booted +from a local disk. + +## Example usage + +``` +terraform init + +env TF_VAR_sel_account=xxxxx TF_VAR_sel_token=yyy_xxx \ + terraform apply -target=module.project_with_user + +env TF_VAR_sel_account=xxxxx TF_VAR_sel_token=yyy_xxx \ + terraform apply +``` diff --git a/examples/vpc/server_local_root_disk/main.tf b/examples/vpc/server_local_root_disk/main.tf new file mode 100644 index 0000000..555a1ca --- /dev/null +++ b/examples/vpc/server_local_root_disk/main.tf @@ -0,0 +1,38 @@ +# Initialize Selectel provider with token. +provider "selectel" { + token = "${var.sel_token}" +} + +# Create the main project with user. +# This module should be applied first: +# terraform apply -target=module.project_with_user +module "project_with_user" { + source = "../../../modules/vpc/project_with_user" + + project_name = "${var.project_name}" + user_name = "${var.user_name}" + user_password = "${var.user_password}" +} + +# Create an OpenStack Compute instance. +module "server_local_root_disk" { + source = "../../../modules/vpc/server_local_root_disk" + + # OpenStack auth. + os_project_name = "${var.project_name}" + os_user_name = "${var.user_name}" + os_user_password = "${var.user_password}" + os_domain_name = "${var.sel_account}" + os_auth_url = "${var.os_auth_url}" + os_region = "${var.os_region}" + + # OpenStack Instance parameters. + server_name = "${var.server_name}" + server_zone = "${var.server_zone}" + server_vcpus = "${var.server_vcpus}" + server_ram_mb = "${var.server_ram_mb}" + server_root_disk_gb = "${var.server_root_disk_gb}" + server_image_name = "${var.server_image_name}" + server_ssh_key = "${file("~/.ssh/id_rsa.pub")}" + server_ssh_key_user = "${module.project_with_user.user_id}" +} \ No newline at end of file diff --git a/examples/vpc/server_local_root_disk/vars.tf b/examples/vpc/server_local_root_disk/vars.tf new file mode 100644 index 0000000..30c389a --- /dev/null +++ b/examples/vpc/server_local_root_disk/vars.tf @@ -0,0 +1,49 @@ +variable "sel_account" {} + +variable "sel_token" {} + +variable "project_name" { + default = "tf_project" +} + +variable "user_name" { + default = "tf_user" +} + +variable "user_password" {} + +variable "keypair_name" { + default = "tf_keypair" +} + +variable "os_auth_url" { + default = "https://api.selvpc.ru/identity/v3" +} + +variable "os_region" { + default = "ru-3" +} + +variable "server_name" { + default = "tf_server" +} + +variable "server_zone" { + default = "ru-3a" +} + +variable "server_vcpus" { + default = 4 +} + +variable "server_ram_mb" { + default = 8192 +} + +variable "server_root_disk_gb" { + default = 8 +} + +variable "server_image_name" { + default = "Ubuntu 18.04 LTS 64-bit" +} diff --git a/examples/vpc/server_remote_root_disk/README.md b/examples/vpc/server_remote_root_disk/README.md new file mode 100644 index 0000000..aa9c20e --- /dev/null +++ b/examples/vpc/server_remote_root_disk/README.md @@ -0,0 +1,16 @@ +# Server with remote root disk + +This environment will create a Selectel VPC project with a single server booted +from a remote disk. + +## Example usage + +``` +terraform init + +env TF_VAR_sel_account=xxxxx TF_VAR_sel_token=yyy_xxx \ + terraform apply -target=module.project_with_user + +env TF_VAR_sel_account=xxxxx TF_VAR_sel_token=yyy_xxx \ + terraform apply +``` diff --git a/examples/vpc/server_remote_root_disk/main.tf b/examples/vpc/server_remote_root_disk/main.tf new file mode 100644 index 0000000..5cede01 --- /dev/null +++ b/examples/vpc/server_remote_root_disk/main.tf @@ -0,0 +1,38 @@ +# Initialize Selectel provider with token. +provider "selectel" { + token = "${var.sel_token}" +} + +# Create the main project with user. +# This module should be applied first. +module "project_with_user" { + source = "../../../modules/vpc/project_with_user" + + project_name = "${var.project_name}" + user_name = "${var.user_name}" + user_password = "${var.user_password}" +} + +# Create an OpenStack Compute instance. +module "server_remote_root_disk" { + source = "../../../modules/vpc/server_remote_root_disk" + + # OpenStack auth. + os_project_name = "${var.project_name}" + os_user_name = "${var.user_name}" + os_user_password = "${var.user_password}" + os_domain_name = "${var.sel_account}" + os_auth_url = "${var.os_auth_url}" + os_region = "${var.os_region}" + + # OpenStack Instance parameters. + server_name = "${var.server_name}" + server_zone = "${var.server_zone}" + server_vcpus = "${var.server_vcpus}" + server_ram_mb = "${var.server_ram_mb}" + server_root_disk_gb = "${var.server_root_disk_gb}" + server_volume_type = "${var.server_volume_type}" + server_image_name = "${var.server_image_name}" + server_ssh_key = "${file("~/.ssh/id_rsa.pub")}" + server_ssh_key_user = "${module.project_with_user.user_id}" +} \ No newline at end of file diff --git a/examples/vpc/server_remote_root_disk/vars.tf b/examples/vpc/server_remote_root_disk/vars.tf new file mode 100644 index 0000000..7a78c6e --- /dev/null +++ b/examples/vpc/server_remote_root_disk/vars.tf @@ -0,0 +1,51 @@ +variable "sel_account" {} + +variable "sel_token" {} + +variable "project_name" { + default = "tf_project" +} + +variable "user_name" {} + +variable "user_password" {} + +variable "keypair_name" { + default= "tf_keypair" +} + +variable "os_auth_url" { + default = "https://api.selvpc.ru/identity/v3" +} + +variable "os_region" { + default = "ru-3" +} + +variable "server_name" { + default = "tf_server" +} + +variable "server_zone" { + default = "ru-3a" +} + +variable "server_vcpus" { + default = 4 +} + +variable "server_ram_mb" { + default = 8192 +} + +variable "server_root_disk_gb" { + default = 8 +} + +variable "server_volume_type" { + default = "fast.ru-3a" +} + +variable "server_image_name" { + default = "Ubuntu 18.04 LTS 64-bit" +} diff --git a/examples/vpc/server_remote_root_disk_two_ports/README.md b/examples/vpc/server_remote_root_disk_two_ports/README.md new file mode 100644 index 0000000..1cd94d4 --- /dev/null +++ b/examples/vpc/server_remote_root_disk_two_ports/README.md @@ -0,0 +1,16 @@ +# Server with remote root disk + +This environment will create a Selectel VPC project with a single server booted +from a remote disk that has two network ports in different subnets. + +## Example usage + +``` +terraform init + +env TF_VAR_sel_account=xxxxx TF_VAR_sel_token=yyy_xxx \ + terraform apply -target=module.project_with_user + +env TF_VAR_sel_account=xxxxx TF_VAR_sel_token=yyy_xxx \ + terraform apply +``` diff --git a/examples/vpc/server_remote_root_disk_two_ports/main.tf b/examples/vpc/server_remote_root_disk_two_ports/main.tf new file mode 100644 index 0000000..59c30ee --- /dev/null +++ b/examples/vpc/server_remote_root_disk_two_ports/main.tf @@ -0,0 +1,38 @@ +# Initialize Selectel provider with token. +provider "selectel" { + token = "${var.sel_token}" +} + +# Create the main project with user. +# This module should be applied first. +module "project_with_user" { + source = "../../../modules/vpc/project_with_user" + + project_name = "${var.project_name}" + user_name = "${var.user_name}" + user_password = "${var.user_password}" +} + +# Create an OpenStack Compute instance. +module "server_remote_root_disk_two_ports" { + source = "../../../modules/vpc/server_remote_root_disk_two_ports" + + # OpenStack auth. + os_project_name = "${var.project_name}" + os_user_name = "${var.user_name}" + os_user_password = "${var.user_password}" + os_domain_name = "${var.sel_account}" + os_auth_url = "${var.os_auth_url}" + os_region = "${var.os_region}" + + # OpenStack Instance parameters. + server_name = "${var.server_name}" + server_zone = "${var.server_zone}" + server_vcpus = "${var.server_vcpus}" + server_ram_mb = "${var.server_ram_mb}" + server_root_disk_gb = "${var.server_root_disk_gb}" + server_volume_type = "${var.server_volume_type}" + server_image_name = "${var.server_image_name}" + server_ssh_key = "${file("~/.ssh/id_rsa.pub")}" + server_ssh_key_user = "${module.project_with_user.user_id}" +} \ No newline at end of file diff --git a/examples/vpc/server_remote_root_disk_two_ports/vars.tf b/examples/vpc/server_remote_root_disk_two_ports/vars.tf new file mode 100644 index 0000000..afcd58f --- /dev/null +++ b/examples/vpc/server_remote_root_disk_two_ports/vars.tf @@ -0,0 +1,53 @@ +variable "sel_account" {} + +variable "sel_token" {} + +variable "project_name" { + default = "tf_project" +} + +variable "user_name" { + default = "tf_user" +} + +variable "user_password" {} + +variable "keypair_name" { + default = "tf_keypair" +} + +variable "os_auth_url" { + default = "https://api.selvpc.ru/identity/v3" +} + +variable "os_region" { + default = "ru-3" +} + +variable "server_name" { + default = "tf_server" +} + +variable "server_zone" { + default = "ru-3a" +} + +variable "server_vcpus" { + default = 4 +} + +variable "server_ram_mb" { + default = 8192 +} + +variable "server_root_disk_gb" { + default = 8 +} + +variable "server_volume_type" { + default = "fast.ru-3a" +} + +variable "server_image_name" { + default = "Ubuntu 18.04 LTS 64-bit" +} diff --git a/modules/account_token/README.md b/modules/account_token/README.md deleted file mode 100644 index 3643464..0000000 --- a/modules/account_token/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Account token - -Terraform module for creating a single SelVPC V2 Account-scoped token. - -## Variables - - * `token_account_name` - Account of the SelVPC V2 Token. - -## Outputs - - * `token_id` - ID of the created SelVPC V2 Token. \ No newline at end of file diff --git a/modules/account_token/outputs.tf b/modules/account_token/outputs.tf deleted file mode 100644 index dc2e6b1..0000000 --- a/modules/account_token/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "token_id" { - value = "${selvpc_resell_token_v2.token_1.id}" -} diff --git a/modules/account_token/vars.tf b/modules/account_token/vars.tf deleted file mode 100644 index 5e2a528..0000000 --- a/modules/account_token/vars.tf +++ /dev/null @@ -1,3 +0,0 @@ -variable "token_account_name" { - description = "Account of the SelVPC V2 Token" -} diff --git a/modules/flavor/vars.tf b/modules/flavor/vars.tf deleted file mode 100644 index 31a477f..0000000 --- a/modules/flavor/vars.tf +++ /dev/null @@ -1,24 +0,0 @@ -variable "flavor_name" { - description = "Name of the OpenStack Compute Flavor" - default = "flavor_1" -} - -variable "flavor_vcpus" { - description = "Amount of VCPUs for the OpenStack Compute Flavor" - default = 2 -} - -variable "flavor_ram_mb" { - description = "Amount of RAM for the OpenStack Compute Flavor" - default = 2048 -} - -variable "flavor_local_disk_gb" { - description = "Amount of GB for local storage of the OpenStack Compute Flavor" - default = 0 -} - -variable "flavor_is_public" { - description = "Flavor visibility" - default = false -} diff --git a/modules/image_datasource/vars.tf b/modules/image_datasource/vars.tf deleted file mode 100644 index 91658ab..0000000 --- a/modules/image_datasource/vars.tf +++ /dev/null @@ -1,4 +0,0 @@ -variable "image_name" { - description = "Name of the OpenStack Image" - default = "Ubuntu 18.04 LTS 64-bit" -} diff --git a/modules/keypair/README.md b/modules/keypair/README.md deleted file mode 100644 index f212136..0000000 --- a/modules/keypair/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Keypair - -Terraform module for creating a single SelVPC V2 Keypair. - -## Variables - - * `keypair_name` - Name of the SelVPC V2 Keypair (Default: "keypair_1"). - - * `keypair_public_key` - Public key for the SelVPC V2 Keypair. - - * `keypair_user_id` - Owner of the SelVPC V2 Keypair. - -## Outputs - - * `keypair_id` - ID of the created SelVPC V2 Keypair. \ No newline at end of file diff --git a/modules/keypair/outputs.tf b/modules/keypair/outputs.tf deleted file mode 100644 index 2d5d286..0000000 --- a/modules/keypair/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "keypair_id" { - value = "${selvpc_resell_keypair_v2.keypair_1.id}" -} diff --git a/modules/keypair/vars.tf b/modules/keypair/vars.tf deleted file mode 100644 index 57303f9..0000000 --- a/modules/keypair/vars.tf +++ /dev/null @@ -1,12 +0,0 @@ -variable "keypair_name" { - description = "Name of the SelVPC V2 Keypair" - default = "keypair_1" -} - -variable "keypair_public_key" { - description = "Public key for the SelVPC V2 Keypair" -} - -variable "keypair_user_id" { - description = "Owner of the SelVPC V2 Keypair" -} diff --git a/modules/kubernetes_cluster/README.md b/modules/kubernetes_cluster/README.md deleted file mode 100644 index f67b5b3..0000000 --- a/modules/kubernetes_cluster/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# Kubernetes cluster - -Terraform module for creating a single Kubernetes cluster in the OpenStack -Container Infra service. - -## Variables - - * `cluster_name` - Name of the OpenStack Container Infra Cluster - (Default: "cluster_1"). - - * `cluster_template_id` - ID of the OpenStack Container Infra Cluster Template. - - * `cluster_keypair` - Name for the keypair of the OpenStack Container Infra - Cluster. - - * `cluster_master_flavor` - Reference of the flavor for the OpenStack - Container Infra Cluster nodes (Default: "1003"). - - * `cluster_flavor` - Reference of the flavor for the OpenStack Container Infra - Cluster nodes (Default: "1003"). - - * `cluster_master_count` - Count of the OpenStack Container Infra Cluster - master nodes (Default: 3). - - * `cluster_node_count` - Count of the OpenStack Container Infra Cluster nodes - (Default: 3). - -## Outputs - - * `cluster_id` - ID of the new Kubernetes cluster. \ No newline at end of file diff --git a/modules/kubernetes_cluster/main.tf b/modules/kubernetes_cluster/main.tf deleted file mode 100644 index 6ed36ea..0000000 --- a/modules/kubernetes_cluster/main.tf +++ /dev/null @@ -1,9 +0,0 @@ -resource "openstack_containerinfra_cluster_v1" "cluster_1" { - name = "${var.cluster_name}" - cluster_template_id = "${var.cluster_template_id}" - keypair = "${var.cluster_keypair}" - master_flavor = "${var.cluster_master_flavor}" - flavor = "${var.cluster_flavor}" - master_count = "${var.cluster_master_count}" - node_count = "${var.cluster_node_count}" -} diff --git a/modules/kubernetes_cluster/vars.tf b/modules/kubernetes_cluster/vars.tf deleted file mode 100644 index f88031c..0000000 --- a/modules/kubernetes_cluster/vars.tf +++ /dev/null @@ -1,32 +0,0 @@ -variable "cluster_name" { - description = "Name of the OpenStack Container Infra Cluster" - default = "cluster_1" -} - -variable "cluster_template_id" { - description = "ID of the OpenStack Container Infra Cluster Template" -} - -variable "cluster_keypair" { - description = "Name for the Keypair of the OpenStack Container Infra Cluster" -} - -variable "cluster_master_flavor" { - description = "Reference of the flavor for the OpenStack Container Infra Cluster nodes" - default = "1003" -} - -variable "cluster_flavor" { - description = "Reference of the flavor for the OpenStack Container Infra Cluster master nodes" - default = "1003" -} - -variable "cluster_master_count" { - description = "Count of the OpenStack Container Infra Cluster master nodes" - default = "3" -} - -variable "cluster_node_count" { - description = "Count of the OpenStack Container Infra Cluster nodes" - default = "3" -} diff --git a/modules/kubernetes_cluster_template_datasource/README.md b/modules/kubernetes_cluster_template_datasource/README.md deleted file mode 100644 index 99b2912..0000000 --- a/modules/kubernetes_cluster_template_datasource/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Image - -Terraform module for getting ID for a single OpenStack Container Infra Cluster -Template. - -## Variables - - * `clustertemplate_name` - Name of the OpenStack Container Infra Cluster - template (Default: "kubernetes-nofloatingips-ru-3a-v1.11.1"). - -## Outputs - - * `cluster_template_id` - ID of the existing public OpenStack Infra Cluster - Template. \ No newline at end of file diff --git a/modules/kubernetes_cluster_template_datasource/main.tf b/modules/kubernetes_cluster_template_datasource/main.tf deleted file mode 100644 index 3c8358f..0000000 --- a/modules/kubernetes_cluster_template_datasource/main.tf +++ /dev/null @@ -1,3 +0,0 @@ -data "openstack_containerinfra_clustertemplate_v1" "clustertemplate_1" { - name = "${var.cluster_template_name}" -} diff --git a/modules/kubernetes_cluster_template_datasource/outputs.tf b/modules/kubernetes_cluster_template_datasource/outputs.tf deleted file mode 100644 index bbf1057..0000000 --- a/modules/kubernetes_cluster_template_datasource/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "cluster_template_id" { - value = "${data.openstack_containerinfra_clustertemplate_v1.clustertemplate_1.id}" -} diff --git a/modules/kubernetes_cluster_template_datasource/vars.tf b/modules/kubernetes_cluster_template_datasource/vars.tf deleted file mode 100644 index 66ac7fc..0000000 --- a/modules/kubernetes_cluster_template_datasource/vars.tf +++ /dev/null @@ -1,4 +0,0 @@ -variable "cluster_template_name" { - description = "Name of the OpenStack Container Infra Cluster Template" - default = "kubernetes-nofloatingips-ru-3a-v1.11.1" -} diff --git a/modules/license/README.md b/modules/license/README.md deleted file mode 100644 index a1db268..0000000 --- a/modules/license/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# License - -Terraform module for creating a single SelVPC V2 License. - -## Variables - - * `license_project_id` - Project of the SelVPC V2 License. - - * `license_region` - Region of the SelVPC V2 License. - - * `license_type` - Type of the SelVPC V2 License. - -## Outputs - - * `license_id` - ID of the created SelVPC V2 License. \ No newline at end of file diff --git a/modules/license/outputs.tf b/modules/license/outputs.tf deleted file mode 100644 index 3a4f777..0000000 --- a/modules/license/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "license_id" { - value = "${selvpc_resell_license_v2.license_1.id}" -} diff --git a/modules/license/vars.tf b/modules/license/vars.tf deleted file mode 100644 index e3a8abc..0000000 --- a/modules/license/vars.tf +++ /dev/null @@ -1,11 +0,0 @@ -variable "license_project_id" { - description = "Project of the SelVPC V2 License" -} - -variable "license_region" { - description = "Region of the SelVPC V2 License" -} - -variable "license_type" { - description = "Type of the SelVPC V2 License" -} diff --git a/modules/project/README.md b/modules/project/README.md deleted file mode 100644 index 483316b..0000000 --- a/modules/project/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Project - -Terraform module for creating a single SelVPC project. - -## Variables - - * `project_name` - Name of the SelVPC Project (Default: "project_1") - -## Outputs - - * `project_id` - ID of the created SelVPC project. \ No newline at end of file diff --git a/modules/project/outputs.tf b/modules/project/outputs.tf deleted file mode 100644 index 93e49e4..0000000 --- a/modules/project/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "project_id" { - value = "${selvpc_resell_project_v2.project_1.id}" -} diff --git a/modules/project/vars.tf b/modules/project/vars.tf deleted file mode 100644 index 0a625a5..0000000 --- a/modules/project/vars.tf +++ /dev/null @@ -1,4 +0,0 @@ -variable "project_name" { - description = "Name of the SelVPC Project" - default = "project_1" -} diff --git a/modules/project_token/README.md b/modules/project_token/README.md deleted file mode 100644 index 23a4c37..0000000 --- a/modules/project_token/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Project token - -Terraform module for creating a single SelVPC V2 Project-scoped token. - -## Variables - - * `token_project_id` - Project of the SelVPC V2 Token. - -## Outputs - - * `token_id` - ID of the created SelVPC V2 Token. \ No newline at end of file diff --git a/modules/project_token/main.tf b/modules/project_token/main.tf deleted file mode 100644 index 121b8be..0000000 --- a/modules/project_token/main.tf +++ /dev/null @@ -1,3 +0,0 @@ -resource "selvpc_resell_token_v2" "token_1" { - project_id = "${var.token_project_id}" -} diff --git a/modules/project_token/outputs.tf b/modules/project_token/outputs.tf deleted file mode 100644 index dc2e6b1..0000000 --- a/modules/project_token/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "token_id" { - value = "${selvpc_resell_token_v2.token_1.id}" -} diff --git a/modules/project_token/vars.tf b/modules/project_token/vars.tf deleted file mode 100644 index 825ee43..0000000 --- a/modules/project_token/vars.tf +++ /dev/null @@ -1,3 +0,0 @@ -variable "token_project_id" { - description = "Project of the SelVPC V2 Token" -} diff --git a/modules/role/README.md b/modules/role/README.md deleted file mode 100644 index 28ca833..0000000 --- a/modules/role/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# License - -Terraform module for creating a single SelVPC V2 License. - -## Variables - - * `license_project_id` - Project of the SelVPC V2 License. - - * `license_region` - Region of the SelVPC V2 License. - - * `license_type` - Type of the SelVPC V2 License. - -## Outputs - - * `keypair_id` - ID of the created SelVPC V2 Keypair. \ No newline at end of file diff --git a/modules/role/outputs.tf b/modules/role/outputs.tf deleted file mode 100644 index a71ecc1..0000000 --- a/modules/role/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "role_id" { - value = "${selvpc_resell_role_v2.role_1.id}" -} diff --git a/modules/role/vars.tf b/modules/role/vars.tf deleted file mode 100644 index 89564f1..0000000 --- a/modules/role/vars.tf +++ /dev/null @@ -1,7 +0,0 @@ -variable "role_project_id" { - description = "Project of the SelVPC V2 Role" -} - -variable "role_user_id" { - description = "User of the SelVPC V2 Role" -} diff --git a/modules/server_local_root_disk/README.md b/modules/server_local_root_disk/README.md deleted file mode 100644 index 9eed3b7..0000000 --- a/modules/server_local_root_disk/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# Server local root disk - -Terraform module for creating a single OpenStack Compute V2 Instance with a -local root volume. - -## Variables - - * `server_name` - Name of the OpenStack Compute Instance - (Default: "server_1"). - - * `server_image_id` - OpenStack Image reference. - - * `server_availability_zone` - OpenStack Compute Availability Zone - (Default: "ru-3a"). - - * `server_flavor_id` - OpenStack Compute Flavor reference (Default: "1003"). - - * `server_keypair_name` - OpenStack Compute Keypair reference. - - * `server_network_name` - OpenStack Networking Network reference - (Default: "nat"). - -## Outputs - - * `server_id` - ID of the created OpenStack Instance. - - * `server_port_id` - ID of the Instance's port. \ No newline at end of file diff --git a/modules/server_local_root_disk/main.tf b/modules/server_local_root_disk/main.tf deleted file mode 100644 index 7b51822..0000000 --- a/modules/server_local_root_disk/main.tf +++ /dev/null @@ -1,29 +0,0 @@ -data "openstack_networking_network_v2" "network_1" { - name = "${var.server_network_name}" -} - -resource "openstack_networking_port_v2" "port_1" { - name = "${var.server_name}-eth0" - admin_state_up = "true" - network_id = "${data.openstack_networking_network_v2.network_1.id}" -} - -resource "openstack_compute_instance_v2" "instance_1" { - name = "${var.server_name}" - image_id = "${var.server_image_id}" - flavor_id = "${var.server_flavor_id}" - key_pair = "${var.server_keypair_name}" - availability_zone = "${var.server_availability_zone}" - - network { - port = "${openstack_networking_port_v2.port_1.id}" - } - - lifecycle { - ignore_changes = ["image_id"] - } - - vendor_options { - ignore_resize_confirmation = true - } -} diff --git a/modules/server_local_root_disk/vars.tf b/modules/server_local_root_disk/vars.tf deleted file mode 100644 index ac9b695..0000000 --- a/modules/server_local_root_disk/vars.tf +++ /dev/null @@ -1,27 +0,0 @@ -variable "server_name" { - description = "Name of the OpenStack Compute Instance" - default = "server_1" -} - -variable "server_image_id" { - description = "OpenStack Image reference" -} - -variable "server_availability_zone" { - description = "OpenStack Compute Availability Zone" - default = "ru-3a" -} - -variable "server_flavor_id" { - description = "OpenStack Compute Flavor reference" - default = "1003" -} - -variable "server_keypair_name" { - description = "OpenStack Compute Keypair reference" -} - -variable "server_network_name" { - description = "OpenStack Networking Network reference" - default = "nat" -} diff --git a/modules/server_remote_root_disk/README.md b/modules/server_remote_root_disk/README.md deleted file mode 100644 index 18b6d10..0000000 --- a/modules/server_remote_root_disk/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# Server remote root disk - -Terraform module for creating a single OpenStack Compute V2 Instance with a -Blockstorage V3 Volume used as root volume. - -## Variables - - * `server_name` - Name of the OpenStack Compute Instance - (Default: "server_1"). - - * `server_image_id` - OpenStack Image reference. - - * `server_volume_size_gb` - OpenStack Blockstorage Volume size (Default: 10). - - * `server_volume_type` - OpenStack Blockstorage Volume type - (Default: "fast.ru-3a"). - - * `server_availability_zone` - OpenStack Compute Availability Zone - (Default: "ru-3a"). - - * `server_flavor_id` - OpenStack Compute Flavor reference (Default: "1003"). - - * `server_keypair_name` - OpenStack Compute Keypair reference. - - * `server_network_name` - OpenStack Networking Network reference - (Default: "nat"). - -## Outputs - - * `server_id` - ID of the created OpenStack Instance. - - * `server_port_id` - ID of the Instance's port. - - * `server_root_volume_id` - ID of the created OpenStack root Volume. \ No newline at end of file diff --git a/modules/server_remote_root_disk/main.tf b/modules/server_remote_root_disk/main.tf deleted file mode 100644 index f394331..0000000 --- a/modules/server_remote_root_disk/main.tf +++ /dev/null @@ -1,43 +0,0 @@ -data "openstack_networking_network_v2" "network_1" { - name = "${var.server_network_name}" -} - -resource "openstack_networking_port_v2" "port_1" { - name = "${var.server_name}-eth0" - admin_state_up = "true" - network_id = "${data.openstack_networking_network_v2.network_1.id}" -} - -resource "openstack_blockstorage_volume_v3" "volume_1" { - name = "volume-for-${var.server_name}" - size = "${var.server_volume_size_gb}" - image_id = "${var.server_image_id}" - volume_type = "${var.server_volume_type}" - availability_zone = "${var.server_availability_zone}" - - lifecycle { - ignore_changes = ["image_id"] - } -} - -resource "openstack_compute_instance_v2" "instance_1" { - name = "${var.server_name}" - flavor_id = "${var.server_flavor_id}" - key_pair = "${var.server_keypair_name}" - availability_zone = "${var.server_availability_zone}" - - network { - port = "${openstack_networking_port_v2.port_1.id}" - } - - block_device { - uuid = "${openstack_blockstorage_volume_v3.volume_1.id}" - source_type = "volume" - destination_type = "volume" - boot_index = 0 - } - - vendor_options { - ignore_resize_confirmation = true - } -} diff --git a/modules/server_remote_root_disk/vars.tf b/modules/server_remote_root_disk/vars.tf deleted file mode 100644 index eb77cd8..0000000 --- a/modules/server_remote_root_disk/vars.tf +++ /dev/null @@ -1,37 +0,0 @@ -variable "server_name" { - description = "Name of the OpenStack Compute Instance" - default = "server_1" -} - -variable "server_image_id" { - description = "OpenStack Image reference" -} - -variable "server_volume_size_gb" { - description = "OpenStack Blockstorage Volume size" - default = 10 -} - -variable "server_volume_type" { - description = "OpenStack Blockstorage Volume type" - default = "fast.ru-3a" -} - -variable "server_availability_zone" { - description = "OpenStack Compute Availability Zone" - default = "ru-3a" -} - -variable "server_flavor_id" { - description = "OpenStack Compute Flavor reference" - default = "1003" -} - -variable "server_keypair_name" { - description = "OpenStack Compute Keypair reference" -} - -variable "server_network_name" { - description = "OpenStack Networking Network reference" - default = "nat" -} diff --git a/modules/server_remote_root_disk_two_ports/README.md b/modules/server_remote_root_disk_two_ports/README.md deleted file mode 100644 index 0acc436..0000000 --- a/modules/server_remote_root_disk_two_ports/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# Server remote root disk and two network ports - -Terraform module for creating a single OpenStack Compute V2 Instance with a -Blockstorage V3 Volume used as root volume and two network ports. - -## Variables - - * `server_name` - Name of the OpenStack Compute Instance - (Default: "server_1"). - - * `server_image_id` - OpenStack Image reference. - - * `server_volume_size_gb` - OpenStack Blockstorage Volume size (Default: 10). - - * `server_volume_type` - OpenStack Blockstorage Volume type - (Default: "fast.ru-3a"). - - * `server_availability_zone` - OpenStack Compute Availability Zone - (Default: "ru-3a"). - - * `server_flavor_id` - OpenStack Compute Flavor reference (Default: "1003"). - - * `server_keypair_name` - OpenStack Compute Keypair reference. - - * `server_network_name` - OpenStack Networking Network reference - (Default: "nat"). - -## Outputs - - * `server_id` - ID of the created OpenStack Instance. - - * `server_first_port_id` - ID of the Instance's eth0. - - * `server_second_port_id` - ID of the Instance's eth1. - - * `server_root_volume_id` - ID of the created OpenStack root Volume. \ No newline at end of file diff --git a/modules/server_remote_root_disk_two_ports/main.tf b/modules/server_remote_root_disk_two_ports/main.tf deleted file mode 100644 index be22ca8..0000000 --- a/modules/server_remote_root_disk_two_ports/main.tf +++ /dev/null @@ -1,73 +0,0 @@ -data "openstack_networking_network_v2" "network_1" { - name = "${var.server_network_name}" -} - -resource "openstack_networking_port_v2" "port_1" { - name = "${var.server_name}-eth0" - admin_state_up = "true" - network_id = "${data.openstack_networking_network_v2.network_1.id}" -} - -resource "openstack_networking_network_v2" "network_2" { - name = "network_2" - admin_state_up = "true" -} - -resource "openstack_networking_subnet_v2" "subnet_2" { - cidr = "10.0.0.0/24" - network_id = "${openstack_networking_network_v2.network_2.id}" - - dns_nameservers = ["188.93.16.19", "188.93.17.19", "109.234.159.91"] -} - -resource "openstack_networking_port_v2" "port_2" { - name = "${var.server_name}-eth1" - admin_state_up = "true" - network_id = "${openstack_networking_network_v2.network_2.id}" - - fixed_ip { - subnet_id = "${openstack_networking_subnet_v2.subnet_2.id}" - } -} - -resource "openstack_blockstorage_volume_v3" "volume_1" { - name = "volume-for-${var.server_name}" - size = "${var.server_volume_size_gb}" - image_id = "${var.server_image_id}" - volume_type = "${var.server_volume_type}" - availability_zone = "${var.server_availability_zone}" - - lifecycle { - ignore_changes = ["image_id"] - } -} - -resource "openstack_compute_instance_v2" "instance_1" { - name = "${var.server_name}" - flavor_id = "${var.server_flavor_id}" - key_pair = "${var.server_keypair_name}" - availability_zone = "${var.server_availability_zone}" - - network { - port = "${openstack_networking_port_v2.port_1.id}" - } - - network { - port = "${openstack_networking_port_v2.port_2.id}" - } - - block_device { - uuid = "${openstack_blockstorage_volume_v3.volume_1.id}" - source_type = "volume" - destination_type = "volume" - boot_index = 0 - } - - metadata { - x_sel_server_default_addr = "{\"ipv4\":\"${openstack_networking_port_v2.port_1.all_fixed_ips.0}\"}" - } - - vendor_options { - ignore_resize_confirmation = true - } -} diff --git a/modules/server_remote_root_disk_two_ports/vars.tf b/modules/server_remote_root_disk_two_ports/vars.tf deleted file mode 100644 index eb77cd8..0000000 --- a/modules/server_remote_root_disk_two_ports/vars.tf +++ /dev/null @@ -1,37 +0,0 @@ -variable "server_name" { - description = "Name of the OpenStack Compute Instance" - default = "server_1" -} - -variable "server_image_id" { - description = "OpenStack Image reference" -} - -variable "server_volume_size_gb" { - description = "OpenStack Blockstorage Volume size" - default = 10 -} - -variable "server_volume_type" { - description = "OpenStack Blockstorage Volume type" - default = "fast.ru-3a" -} - -variable "server_availability_zone" { - description = "OpenStack Compute Availability Zone" - default = "ru-3a" -} - -variable "server_flavor_id" { - description = "OpenStack Compute Flavor reference" - default = "1003" -} - -variable "server_keypair_name" { - description = "OpenStack Compute Keypair reference" -} - -variable "server_network_name" { - description = "OpenStack Networking Network reference" - default = "nat" -} diff --git a/modules/server_two_remote_disks/README.md b/modules/server_two_remote_disks/README.md deleted file mode 100644 index ab8d948..0000000 --- a/modules/server_two_remote_disks/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# Server two remote volumes - -Terraform module for creating a single OpenStack Compute V2 Instance with two -Blockstorage V3 Volumes. - -## Variables - - * `server_name` - Name of the OpenStack Compute Instance - (Default: "server_1"). - - * `server_image_id` - OpenStack Image reference. - - * `server_root_volume_size_gb` - OpenStack Blockstorage root Volume size - (Default: 10). - - * `server_root_volume_type` - OpenStack Blockstorage root Volume type - (Default: "fast.ru-3a"). - - * `server_second_volume_size_gb` - OpenStack Blockstorage second Volume size - (Default: 20). - - * `server_second_volume_type` - OpenStack Blockstorage root Volume type - (Default: "fast.ru-3a"). - - * `server_availability_zone` - OpenStack Compute Availability Zone - (Default: "ru-3a"). - - * `server_flavor_id` - OpenStack Compute Flavor reference (Default: "1003"). - - * `server_keypair_name` - OpenStack Compute Keypair reference. - - * `server_network_name` - OpenStack Networking Network reference - (Default: "nat"). - -## Outputs - - * `server_id` - ID of the created OpenStack Instance. - - * `server_port_id` - ID of the Instance's port. - - * `server_root_volume_id` - ID of the created OpenStack root Volume. - - * `server_second_volume_id` - ID of the created OpenStack second Volume. \ No newline at end of file diff --git a/modules/server_two_remote_disks/main.tf b/modules/server_two_remote_disks/main.tf deleted file mode 100644 index 671e34a..0000000 --- a/modules/server_two_remote_disks/main.tf +++ /dev/null @@ -1,54 +0,0 @@ -data "openstack_networking_network_v2" "network_1" { - name = "${var.server_network_name}" -} - -resource "openstack_networking_port_v2" "port_1" { - name = "${var.server_name}-eth0" - admin_state_up = "true" - network_id = "${data.openstack_networking_network_v2.network_1.id}" -} - -resource "openstack_blockstorage_volume_v3" "volume_1" { - name = "sda-for-${var.server_name}" - size = "${var.server_root_volume_size_gb}" - image_id = "${var.server_image_id}" - volume_type = "${var.server_root_volume_type}" - availability_zone = "${var.server_availability_zone}" -} - -resource "openstack_blockstorage_volume_v3" "volume_2" { - name = "sdb-for-${var.server_name}" - size = "${var.server_second_volume_size_gb}" - image_id = "${var.server_image_id}" - volume_type = "${var.server_second_volume_type}" - availability_zone = "${var.server_availability_zone}" -} - -resource "openstack_compute_instance_v2" "instance_1" { - name = "${var.server_name}" - flavor_id = "${var.server_flavor_id}" - key_pair = "${var.server_keypair_name}" - availability_zone = "${var.server_availability_zone}" - - network { - port = "${openstack_networking_port_v2.port_1.id}" - } - - block_device { - uuid = "${openstack_blockstorage_volume_v3.volume_1.id}" - source_type = "volume" - destination_type = "volume" - boot_index = 0 - } - - block_device { - uuid = "${openstack_blockstorage_volume_v3.volume_2.id}" - source_type = "volume" - destination_type = "volume" - boot_index = 1 - } - - vendor_options { - ignore_resize_confirmation = true - } -} diff --git a/modules/server_two_remote_disks/vars.tf b/modules/server_two_remote_disks/vars.tf deleted file mode 100644 index 7700d77..0000000 --- a/modules/server_two_remote_disks/vars.tf +++ /dev/null @@ -1,47 +0,0 @@ -variable "server_name" { - description = "Name of the OpenStack Compute Instance" - default = "server_1" -} - -variable "server_image_id" { - description = "OpenStack Imageservice Image reference" -} - -variable "server_root_volume_size_gb" { - description = "OpenStack Blockstorage root Volume size" - default = 10 -} - -variable "server_root_volume_type" { - description = "OpenStack Blockstorage root Volume type" - default = "fast.ru-3a" -} - -variable "server_second_volume_size_gb" { - description = "OpenStack Blockstorage second Volume size" - default = 20 -} - -variable "server_second_volume_type" { - description = "OpenStack Blockstorage second Volume type" - default = "fast.ru-3a" -} - -variable "server_availability_zone" { - description = "OpenStack Compute Availability Zone" - default = "ru-3a" -} - -variable "server_flavor_id" { - description = "OpenStack Compute Flavor reference" - default = "1003" -} - -variable "server_keypair_name" { - description = "OpenStack Compute Keypair reference" -} - -variable "server_network_name" { - description = "OpenStack Networking Network reference" - default = "nat" -} diff --git a/modules/subnet/README.md b/modules/subnet/README.md deleted file mode 100644 index a44e161..0000000 --- a/modules/subnet/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# License - -Terraform module for creating a single SelVPC V2 License. - -## Variables - - * `subnet_project_id` - Project of the SelVPC V2 Subnet. - - * `subnet_region` - Region of the SelVPC V2 Subnet. - - * `subnet_prefix_length` - Prefix length of the SelVPC V2 Subnet. - - * `subnet_ip_version` - IP version of the SelVPC V2 Subnet. - -## Outputs - - * `subnet_id` - ID of the created SelVPC V2 Subnet. \ No newline at end of file diff --git a/modules/subnet/outputs.tf b/modules/subnet/outputs.tf deleted file mode 100644 index 41e8066..0000000 --- a/modules/subnet/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "subnet_id" { - value = "${selvpc_resell_subnet_v2.subnet_1.id}" -} diff --git a/modules/subnet/vars.tf b/modules/subnet/vars.tf deleted file mode 100644 index 0b737ac..0000000 --- a/modules/subnet/vars.tf +++ /dev/null @@ -1,17 +0,0 @@ -variable "subnet_project_id" { - description = "Project of the SelVPC V2 Subnet" -} - -variable "subnet_region" { - description = "Region of the SelVPC V2 Subnet" -} - -variable "subnet_prefix_length" { - description = "Prefix length of the SelVPC V2 Subnet" - default = 29 -} - -variable "subnet_ip_version" { - description = "IP version of the SelVPC V2 Subnet" - default = "ipv4" -} diff --git a/modules/user/README.md b/modules/user/README.md deleted file mode 100644 index 115a294..0000000 --- a/modules/user/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# User - -Terraform module for creating a single SelVPC V2 User. - -## Variables - - * `user_name` - Name of the SelVPC V2 User (Default: "user_1"). - - * `user_password` - Password of the SelVPC V2 User - -## Outputs - - * `user_id` - ID of the created SelVPC V2 User. \ No newline at end of file diff --git a/modules/user/outputs.tf b/modules/user/outputs.tf deleted file mode 100644 index e2963bf..0000000 --- a/modules/user/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "user_id" { - value = "${selvpc_resell_user_v2.user_1.id}" -} diff --git a/modules/user/vars.tf b/modules/user/vars.tf deleted file mode 100644 index 2487b71..0000000 --- a/modules/user/vars.tf +++ /dev/null @@ -1,8 +0,0 @@ -variable "user_name" { - description = "Name of the SelVPC V2 User" - default = "user_1" -} - -variable "user_password" { - description = "Password of the SelVPC V2 User" -} diff --git a/modules/vpc/account_token/README.md b/modules/vpc/account_token/README.md new file mode 100644 index 0000000..9028205 --- /dev/null +++ b/modules/vpc/account_token/README.md @@ -0,0 +1,11 @@ +# Account token + +Terraform module for creating a single Selectel VPC Account-scoped token. + +## Variables + + * `token_account_name` - Account of the Selectel VPC Token. + +## Outputs + + * `token_id` - ID of the created Selectel VPC Token. \ No newline at end of file diff --git a/modules/account_token/main.tf b/modules/vpc/account_token/main.tf similarity index 50% rename from modules/account_token/main.tf rename to modules/vpc/account_token/main.tf index 5a00ffa..12d7f83 100644 --- a/modules/account_token/main.tf +++ b/modules/vpc/account_token/main.tf @@ -1,3 +1,3 @@ -resource "selvpc_resell_token_v2" "token_1" { +resource "selectel_vpc_token_v2" "token_1" { account_name = "${var.token_account_name}" } diff --git a/modules/vpc/account_token/outputs.tf b/modules/vpc/account_token/outputs.tf new file mode 100644 index 0000000..dc124b2 --- /dev/null +++ b/modules/vpc/account_token/outputs.tf @@ -0,0 +1,3 @@ +output "token_id" { + value = "${selectel_vpc_token_v2.token_1.id}" +} diff --git a/modules/vpc/account_token/vars.tf b/modules/vpc/account_token/vars.tf new file mode 100644 index 0000000..6999987 --- /dev/null +++ b/modules/vpc/account_token/vars.tf @@ -0,0 +1 @@ +variable "token_account_name" {} diff --git a/modules/flavor/README.md b/modules/vpc/flavor/README.md similarity index 100% rename from modules/flavor/README.md rename to modules/vpc/flavor/README.md diff --git a/modules/flavor/main.tf b/modules/vpc/flavor/main.tf similarity index 100% rename from modules/flavor/main.tf rename to modules/vpc/flavor/main.tf diff --git a/modules/flavor/outputs.tf b/modules/vpc/flavor/outputs.tf similarity index 100% rename from modules/flavor/outputs.tf rename to modules/vpc/flavor/outputs.tf diff --git a/modules/vpc/flavor/vars.tf b/modules/vpc/flavor/vars.tf new file mode 100644 index 0000000..45a3076 --- /dev/null +++ b/modules/vpc/flavor/vars.tf @@ -0,0 +1,19 @@ +variable "flavor_name" { + default = "flavor_1" +} + +variable "flavor_vcpus" { + default = 2 +} + +variable "flavor_ram_mb" { + default = 2048 +} + +variable "flavor_local_disk_gb" { + default = 0 +} + +variable "flavor_is_public" { + default = false +} diff --git a/modules/floatingip/README.md b/modules/vpc/floatingip/README.md similarity index 100% rename from modules/floatingip/README.md rename to modules/vpc/floatingip/README.md diff --git a/modules/floatingip/main.tf b/modules/vpc/floatingip/main.tf similarity index 100% rename from modules/floatingip/main.tf rename to modules/vpc/floatingip/main.tf diff --git a/modules/floatingip/outputs.tf b/modules/vpc/floatingip/outputs.tf similarity index 100% rename from modules/floatingip/outputs.tf rename to modules/vpc/floatingip/outputs.tf diff --git a/modules/image_datasource/README.md b/modules/vpc/image_datasource/README.md similarity index 100% rename from modules/image_datasource/README.md rename to modules/vpc/image_datasource/README.md diff --git a/modules/image_datasource/main.tf b/modules/vpc/image_datasource/main.tf similarity index 100% rename from modules/image_datasource/main.tf rename to modules/vpc/image_datasource/main.tf diff --git a/modules/image_datasource/outputs.tf b/modules/vpc/image_datasource/outputs.tf similarity index 100% rename from modules/image_datasource/outputs.tf rename to modules/vpc/image_datasource/outputs.tf diff --git a/modules/vpc/image_datasource/vars.tf b/modules/vpc/image_datasource/vars.tf new file mode 100644 index 0000000..561f4b0 --- /dev/null +++ b/modules/vpc/image_datasource/vars.tf @@ -0,0 +1,3 @@ +variable "image_name" { + default = "Ubuntu 18.04 LTS 64-bit" +} diff --git a/modules/vpc/keypair/README.md b/modules/vpc/keypair/README.md new file mode 100644 index 0000000..5bbf3a8 --- /dev/null +++ b/modules/vpc/keypair/README.md @@ -0,0 +1,15 @@ +# Keypair + +Terraform module for creating a single Selectel V2 Keypair. + +## Variables + + * `keypair_name` - Name of the Selectel V2 Keypair (Default: "keypair_1"). + + * `keypair_public_key` - Public key for the Selectel V2 Keypair. + + * `keypair_user_id` - Owner of the Selectel V2 Keypair. + +## Outputs + + * `keypair_id` - ID of the created Selectel V2 Keypair. diff --git a/modules/keypair/main.tf b/modules/vpc/keypair/main.tf similarity index 54% rename from modules/keypair/main.tf rename to modules/vpc/keypair/main.tf index a04b8bf..f8b25a2 100644 --- a/modules/keypair/main.tf +++ b/modules/vpc/keypair/main.tf @@ -1,5 +1,9 @@ -resource "selvpc_resell_keypair_v2" "keypair_1" { +resource "selectel_vpc_keypair_v2" "keypair_1" { name = "${var.keypair_name}" public_key = "${var.keypair_public_key}" user_id = "${var.keypair_user_id}" + + lifecycle { + ignore_changes = ["regions"] + } } diff --git a/modules/vpc/keypair/outputs.tf b/modules/vpc/keypair/outputs.tf new file mode 100644 index 0000000..8988cf4 --- /dev/null +++ b/modules/vpc/keypair/outputs.tf @@ -0,0 +1,7 @@ +output "keypair_id" { + value = "${selectel_vpc_keypair_v2.keypair_1.id}" +} + +output "keypair_name" { + value = "${selectel_vpc_keypair_v2.keypair_1.name}" +} \ No newline at end of file diff --git a/modules/vpc/keypair/vars.tf b/modules/vpc/keypair/vars.tf new file mode 100644 index 0000000..1789038 --- /dev/null +++ b/modules/vpc/keypair/vars.tf @@ -0,0 +1,7 @@ +variable "keypair_name" { + default = "keypair_1" +} + +variable "keypair_public_key" {} + +variable "keypair_user_id" {} diff --git a/modules/vpc/kubernetes_cluster/README.md b/modules/vpc/kubernetes_cluster/README.md new file mode 100644 index 0000000..8cd423d --- /dev/null +++ b/modules/vpc/kubernetes_cluster/README.md @@ -0,0 +1,4 @@ +# Kubernetes cluster + +Terraform module for creating a single Kubernetes cluster in the OpenStack +Container Infra service. \ No newline at end of file diff --git a/modules/vpc/kubernetes_cluster/main.tf b/modules/vpc/kubernetes_cluster/main.tf new file mode 100644 index 0000000..b2c1d8d --- /dev/null +++ b/modules/vpc/kubernetes_cluster/main.tf @@ -0,0 +1,80 @@ +provider "openstack" { + user_name = "${var.os_user_name}" + tenant_name = "${var.os_project_name}" + password = "${var.os_user_password}" + project_domain_name = "${var.os_domain_name}" + user_domain_name = "${var.os_domain_name}" + auth_url = "${var.os_auth_url}" + region = "${var.os_region}" +} + +resource "random_string" "random_name" { + length = 5 + special = false +} + +module "master_flavor" { + source = "../flavor" + flavor_name = "flavor-master-${random_string.random_name.result}" + flavor_vcpus = "${var.cluster_master_vcpus}" + flavor_ram_mb = "${var.cluster_master_ram}" +} + +module "flavor" { + source = "../flavor" + flavor_name = "flavor-${random_string.random_name.result}" + flavor_vcpus = "${var.cluster_node_vcpus}" + flavor_ram_mb = "${var.cluster_node_ram}" +} + +module "image_datasource" { + source = "../image_datasource" + image_name = "${var.cluster_image_name}" +} + +data "openstack_networking_network_v2" "external_net" { + name = "${var.external_net_name}" +} + +module "keypair" { + source = "../keypair" + keypair_name = "keypair-${random_string.random_name.result}" + keypair_public_key = "${var.cluster_ssh_key}" + keypair_user_id = "${var.cluster_ssh_key_user}" +} + +resource "openstack_containerinfra_clustertemplate_v1" "clustertemplate_1" { + name = "${var.cluster_name}-template" + image = "${module.image_datasource.image_id}" + coe = "kubernetes" + master_flavor = "${module.master_flavor.flavor_id}" + flavor = "${module.flavor.flavor_id}" + dns_nameserver = "188.93.17.19,188.93.16.19,109.234.159.91" + docker_storage_driver = "devicemapper" + docker_volume_size = "${var.cluster_docker_volume_size}" + volume_driver = "cinder" + network_driver = "flannel" + server_type = "vm" + master_lb_enabled = "${var.cluster_master_lb_enabled}" + floating_ip_enabled = false + external_network_id = "${data.openstack_networking_network_v2.external_net.id}" + labels = { + kube_tag = "${var.cluster_kube_version}" + kube_dashboard_enabled = "${var.cluster_kube_dashboard_enabled}" + prometheus_monitoring = "${var.cluster_prometheus_monitoring}" + influx_grafana_dashboard_enabled = "${var.cluster_influx_grafana_dashboard_enabled}" + etcd_volume_size = "${var.cluster_etcd_volume_size}" + docker_volume_type = "fast.${var.cluster_zone}" + availability_zone = "${var.cluster_zone}" + flannel_backend = "host-gw" + master_floating_ip = "${var.cluster_master_floating_ip}" + } +} + +resource "openstack_containerinfra_cluster_v1" "cluster_1" { + name = "${var.cluster_name}" + cluster_template_id = "${openstack_containerinfra_clustertemplate_v1.clustertemplate_1.id}" + keypair = "${module.keypair.keypair_name}" + master_count = "${var.cluster_master_count}" + node_count = "${var.cluster_node_count}" +} diff --git a/modules/kubernetes_cluster/outputs.tf b/modules/vpc/kubernetes_cluster/outputs.tf similarity index 100% rename from modules/kubernetes_cluster/outputs.tf rename to modules/vpc/kubernetes_cluster/outputs.tf diff --git a/modules/vpc/kubernetes_cluster/vars.tf b/modules/vpc/kubernetes_cluster/vars.tf new file mode 100644 index 0000000..8e2c04c --- /dev/null +++ b/modules/vpc/kubernetes_cluster/vars.tf @@ -0,0 +1,91 @@ +variable "os_user_name" {} + +variable "os_project_name" {} + +variable "os_user_password" {} + +variable "os_domain_name" {} + +variable "os_auth_url" {} + +variable "os_region" {} + +variable cluster_master_vcpus { + default = 2 +} + +variable cluster_master_ram { + default = 2048 +} + +variable cluster_node_vcpus { + default = 2 +} + +variable cluster_node_ram { + default = 2048 +} + +variable external_net_name { + default = "external-network" +} + +variable cluster_image_name { + default = "Fedora Atomic 27 64-bit" +} + +variable cluster_ssh_key {} + +variable cluster_ssh_key_user {} + +variable cluster_name { + default = "tf_cluster" +} + +variable cluster_kube_version { + default = "v1.12.4" +} + +variable cluster_zone { + default = "ru-3a" +} + +variable cluster_master_count { + default = 1 +} + +variable cluster_node_count { + default = 2 +} + +variable cluster_master_lb_enabled { + default = false +} + +variable cluster_floating_ip_enabled { + default = false +} + +variable cluster_kube_dashboard_enabled { + default = "true" +} + +variable cluster_prometheus_monitoring { + default = "true" +} + +variable cluster_influx_grafana_dashboard_enabled { + default = "true" +} + +variable cluster_docker_volume_size { + default = 10 +} + +variable cluster_etcd_volume_size { + default = "10" +} + +variable cluster_master_floating_ip { + default = "false" +} \ No newline at end of file diff --git a/modules/vpc/license/README.md b/modules/vpc/license/README.md new file mode 100644 index 0000000..d6c4809 --- /dev/null +++ b/modules/vpc/license/README.md @@ -0,0 +1,15 @@ +# License + +Terraform module for creating a single Selectel VPC License. + +## Variables + + * `license_project_id` - Project of the Selectel VPC License. + + * `license_region` - Region of the Selectel VPC License. + + * `license_type` - Type of the Selectel VPC License. + +## Outputs + + * `license_id` - ID of the created Selectel VPC License. \ No newline at end of file diff --git a/modules/license/main.tf b/modules/vpc/license/main.tf similarity index 70% rename from modules/license/main.tf rename to modules/vpc/license/main.tf index 411bf7f..bc94fc5 100644 --- a/modules/license/main.tf +++ b/modules/vpc/license/main.tf @@ -1,4 +1,4 @@ -resource "selvpc_resell_license_v2" "license_1" { +resource "selectel_vpc_license_v2" "license_1" { project_id = "${var.license_project_id}" region = "${var.license_region}" type = "${var.license_type}" diff --git a/modules/vpc/license/outputs.tf b/modules/vpc/license/outputs.tf new file mode 100644 index 0000000..56f3c38 --- /dev/null +++ b/modules/vpc/license/outputs.tf @@ -0,0 +1,3 @@ +output "license_id" { + value = "${selectel_vpc_license_v2.license_1.id}" +} diff --git a/modules/vpc/license/vars.tf b/modules/vpc/license/vars.tf new file mode 100644 index 0000000..4bf6b9b --- /dev/null +++ b/modules/vpc/license/vars.tf @@ -0,0 +1,5 @@ +variable "license_project_id" {} + +variable "license_region" {} + +variable "license_type" {} diff --git a/modules/vpc/nat/README.md b/modules/vpc/nat/README.md new file mode 100644 index 0000000..f7bbe91 --- /dev/null +++ b/modules/vpc/nat/README.md @@ -0,0 +1,21 @@ +# NAT + +Terraform module to create a NAT objects in project + +## Variables + + * `router_external_net_name` - OpenStack Networking external Network reference (Default: "external-network"). + + * `router_name` - OpenStack Networking Router name (Default: "router_1"). + + * `network_name` - OpenStack Networking Network name (Default: "network_1"). + + * `subnet_cidr` - OpenStack Networking Subnet CIDR (Default: "192.168.0.0/24"). + +## Outputs + + * `router_id` - UUID of the created router. + + * `network_id` - UUID of the created network. + + * `subnet_id` - UUID of the created subnet. \ No newline at end of file diff --git a/modules/vpc/nat/main.tf b/modules/vpc/nat/main.tf new file mode 100644 index 0000000..fba8072 --- /dev/null +++ b/modules/vpc/nat/main.tf @@ -0,0 +1,23 @@ +data "openstack_networking_network_v2" "external_net" { + name = "${var.router_external_net_name}" +} + +resource "openstack_networking_router_v2" "router_1" { + name = "${var.router_name}" + external_network_id = "${data.openstack_networking_network_v2.external_net.id}" +} + +resource "openstack_networking_network_v2" "network_1" { + name = "${var.network_name}" +} + +resource "openstack_networking_subnet_v2" "subnet_1" { + network_id = "${openstack_networking_network_v2.network_1.id}" + name = "${var.subnet_cidr}" + cidr = "${var.subnet_cidr}" +} + +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}" +} \ No newline at end of file diff --git a/modules/vpc/nat/outputs.tf b/modules/vpc/nat/outputs.tf new file mode 100644 index 0000000..05dcfa4 --- /dev/null +++ b/modules/vpc/nat/outputs.tf @@ -0,0 +1,11 @@ +output "router_id" { + value = "${openstack_networking_router_v2.router_1.id}" +} + +output "network_id" { + value = "${openstack_networking_network_v2.network_1.id}" +} + +output "subnet_id" { + value = "${openstack_networking_subnet_v2.subnet_1.id}" +} \ No newline at end of file diff --git a/modules/vpc/nat/vars.tf b/modules/vpc/nat/vars.tf new file mode 100644 index 0000000..b7a25fb --- /dev/null +++ b/modules/vpc/nat/vars.tf @@ -0,0 +1,15 @@ +variable "router_external_net_name" { + default = "external-network" +} + +variable "router_name" { + default = "router_1" +} + +variable "network_name" { + default = "network_1" +} + +variable "subnet_cidr" { + default = "192.168.0.0/24" +} \ No newline at end of file diff --git a/modules/vpc/project/README.md b/modules/vpc/project/README.md new file mode 100644 index 0000000..fdaf6ba --- /dev/null +++ b/modules/vpc/project/README.md @@ -0,0 +1,11 @@ +# Project + +Terraform module for creating a single Selectel project. + +## Variables + + * `project_name` - Name of the Selectel project (Default: "project_1") + +## Outputs + + * `project_id` - ID of the created Selectel project. \ No newline at end of file diff --git a/modules/project/main.tf b/modules/vpc/project/main.tf similarity index 54% rename from modules/project/main.tf rename to modules/vpc/project/main.tf index 6a57557..23533a0 100644 --- a/modules/project/main.tf +++ b/modules/vpc/project/main.tf @@ -1,4 +1,4 @@ -resource "selvpc_resell_project_v2" "project_1" { +resource "selectel_vpc_project_v2" "project_1" { name = "${var.project_name}" auto_quotas = true } diff --git a/modules/vpc/project/outputs.tf b/modules/vpc/project/outputs.tf new file mode 100644 index 0000000..40f633d --- /dev/null +++ b/modules/vpc/project/outputs.tf @@ -0,0 +1,3 @@ +output "project_id" { + value = "${selectel_vpc_project_v2.project_1.id}" +} diff --git a/modules/vpc/project/vars.tf b/modules/vpc/project/vars.tf new file mode 100644 index 0000000..9731a92 --- /dev/null +++ b/modules/vpc/project/vars.tf @@ -0,0 +1,3 @@ +variable "project_name" { + default = "project_1" +} diff --git a/modules/vpc/project_token/README.md b/modules/vpc/project_token/README.md new file mode 100644 index 0000000..89a05dc --- /dev/null +++ b/modules/vpc/project_token/README.md @@ -0,0 +1,11 @@ +# Project token + +Terraform module for creating a single Selectel VPC Project-scoped token. + +## Variables + + * `token_project_id` - Project of the Selectel VPC Token. + +## Outputs + + * `token_id` - ID of the created Selectel VPC Token. \ No newline at end of file diff --git a/modules/vpc/project_token/main.tf b/modules/vpc/project_token/main.tf new file mode 100644 index 0000000..e2dbf8c --- /dev/null +++ b/modules/vpc/project_token/main.tf @@ -0,0 +1,3 @@ +resource "selectel_vpc_token_v2" "token_1" { + project_id = "${var.token_project_id}" +} diff --git a/modules/vpc/project_token/outputs.tf b/modules/vpc/project_token/outputs.tf new file mode 100644 index 0000000..dc124b2 --- /dev/null +++ b/modules/vpc/project_token/outputs.tf @@ -0,0 +1,3 @@ +output "token_id" { + value = "${selectel_vpc_token_v2.token_1.id}" +} diff --git a/modules/vpc/project_token/vars.tf b/modules/vpc/project_token/vars.tf new file mode 100644 index 0000000..965aa45 --- /dev/null +++ b/modules/vpc/project_token/vars.tf @@ -0,0 +1 @@ +variable "token_project_id" {} diff --git a/modules/vpc/project_with_user/README.md b/modules/vpc/project_with_user/README.md new file mode 100644 index 0000000..6f1b5f3 --- /dev/null +++ b/modules/vpc/project_with_user/README.md @@ -0,0 +1,19 @@ +# Project with user + +Terraform module for creating a Selectel project with user. + +## Variables + + * `project_name` - Name of the project. + + * `user_name` - Name of the user. + + * `user_password` - Password of the user. + +## Outputs + + * `project_id` - ID of the created project. + + * `user_id` - ID of the created user. + + * `role_id` - ID of the created role. diff --git a/modules/vpc/project_with_user/main.tf b/modules/vpc/project_with_user/main.tf new file mode 100644 index 0000000..47c7d43 --- /dev/null +++ b/modules/vpc/project_with_user/main.tf @@ -0,0 +1,16 @@ +module "project" { + source = "../project" + project_name = "${var.project_name}" +} + +module "user" { + source = "../user" + user_name = "${var.user_name}" + user_password = "${var.user_password}" +} + +module "role" { + source = "../role" + role_project_id = "${module.project.project_id}" + role_user_id = "${module.user.user_id}" +} \ No newline at end of file diff --git a/modules/vpc/project_with_user/outputs.tf b/modules/vpc/project_with_user/outputs.tf new file mode 100644 index 0000000..b8ac738 --- /dev/null +++ b/modules/vpc/project_with_user/outputs.tf @@ -0,0 +1,11 @@ +output "project_id" { + value = "${module.project.project_id}" +} + +output "user_id" { + value = "${module.user.user_id}" +} + +output "role_id" { + value = "${module.role.role_id}" +} diff --git a/modules/vpc/project_with_user/vars.tf b/modules/vpc/project_with_user/vars.tf new file mode 100644 index 0000000..4dfaceb --- /dev/null +++ b/modules/vpc/project_with_user/vars.tf @@ -0,0 +1,9 @@ +variable "project_name" { + default = "tf_project" +} + +variable "user_name" { + default = "tf_user" +} + +variable "user_password" {} diff --git a/modules/vpc/role/README.md b/modules/vpc/role/README.md new file mode 100644 index 0000000..b9eda8e --- /dev/null +++ b/modules/vpc/role/README.md @@ -0,0 +1,13 @@ +# Role + +Terraform module for creating a single Selectel VPC role. + +## Variables + + * `role_project_id` - Project of the Selectel VPC role. + + * `role_user_id` - User of the Selectel VPC role. + +## Outputs + + * `role_id` - ID of the created Selectel VPC Role. \ No newline at end of file diff --git a/modules/role/main.tf b/modules/vpc/role/main.tf similarity index 64% rename from modules/role/main.tf rename to modules/vpc/role/main.tf index faeb9f9..a5f4028 100644 --- a/modules/role/main.tf +++ b/modules/vpc/role/main.tf @@ -1,4 +1,4 @@ -resource "selvpc_resell_role_v2" "role_1" { +resource "selectel_vpc_role_v2" "role_1" { project_id = "${var.role_project_id}" user_id = "${var.role_user_id}" } diff --git a/modules/vpc/role/outputs.tf b/modules/vpc/role/outputs.tf new file mode 100644 index 0000000..59444dc --- /dev/null +++ b/modules/vpc/role/outputs.tf @@ -0,0 +1,3 @@ +output "role_id" { + value = "${selectel_vpc_role_v2.role_1.id}" +} diff --git a/modules/vpc/role/vars.tf b/modules/vpc/role/vars.tf new file mode 100644 index 0000000..7dd01ca --- /dev/null +++ b/modules/vpc/role/vars.tf @@ -0,0 +1,3 @@ +variable "role_project_id" {} + +variable "role_user_id" {} diff --git a/modules/vpc/server_local_and_remote_disks/README.md b/modules/vpc/server_local_and_remote_disks/README.md new file mode 100644 index 0000000..ec325e2 --- /dev/null +++ b/modules/vpc/server_local_and_remote_disks/README.md @@ -0,0 +1,44 @@ +# Server local and remote disks + +Terraform module for creating a single OpenStack Compute V2 Instance with a +local root volume with additional remote disk attached. + +## Variables + + * `os_user_name` - OpenStack username. + + * `os_project_name` - OpenStack username. + + * `os_user_password` - OpenStack username. + + * `os_domain_name` - OpenStack username. + + * `os_auth_url` - OpenStack username. + + * `os_region` - OpenStack username. + + * `server_vcpus` - Server virtual CPUs (Default: 4). + + * `server_ram_mb` - Server RAM (MB) (Default: 8192). + + * `server_volume_type` - Server remote root disk type (Default: "fast.ru-3a") + + * `server_root_disk_gb` - Size of the root disk (GB) (Default: 8). + + * `server_name` - Name of the server (Default: "server_1") + + * `server_image_name` - Name of the image to find to create a server. + + * `server_zone` - Server availability zone. + + * `server_ssh_key` - SSH keypair name. + + * `server_ssh_key_user` - Owner of the SSH keypair. + +## Outputs + + * `server_id` - ID of the created OpenStack Server. + + * `server_port_id` - ID of the Server's port. + + * `server_root_volume_id` - ID of the Server's root volume. \ No newline at end of file diff --git a/modules/vpc/server_local_and_remote_disks/main.tf b/modules/vpc/server_local_and_remote_disks/main.tf new file mode 100644 index 0000000..ad5193f --- /dev/null +++ b/modules/vpc/server_local_and_remote_disks/main.tf @@ -0,0 +1,100 @@ +provider "openstack" { + user_name = "${var.os_user_name}" + tenant_name = "${var.os_project_name}" + password = "${var.os_user_password}" + project_domain_name = "${var.os_domain_name}" + user_domain_name = "${var.os_domain_name}" + auth_url = "${var.os_auth_url}" + region = "${var.os_region}" +} + +resource "random_string" "random_name" { + length = 5 + special = false +} + +module "flavor" { + source = "../flavor" + flavor_name = "flavor-${random_string.random_name.result}" + flavor_vcpus = "${var.server_vcpus}" + flavor_ram_mb = "${var.server_ram_mb}" + flavor_local_disk_gb = "${var.server_root_disk_gb}" + lifecycle { + create_before_destroy = false + } +} + +module "nat" { + source = "../nat" +} + +resource "openstack_networking_port_v2" "port_1" { + name = "${var.server_name}-eth0" + network_id = "${module.nat.network_id}" + fixed_ip { + subnet_id = "${module.nat.subnet_id}" + } +} + +module "image_datasource" { + source = "../image_datasource" + image_name = "${var.server_image_name}" +} + +module "keypair" { + source = "../keypair" + keypair_name = "keypair-${random_string.random_name.result}" + keypair_public_key = "${var.server_ssh_key}" + keypair_user_id = "${var.server_ssh_key_user}" +} + +resource "openstack_blockstorage_volume_v3" "volume_1" { + name = "volume-for-${var.server_name}" + size = "${var.server_second_disk_gb}" + image_id = "${module.image_datasource.image_id}" + volume_type = "${var.server_second_volume_type}" + availability_zone = "${var.server_zone}" + + lifecycle { + ignore_changes = ["image_id"] + } +} + +resource "openstack_compute_instance_v2" "instance_1" { + name = "${var.server_name}" + image_id = "${module.image_datasource.image_id}" + flavor_id = "${module.flavor.flavor_id}" + key_pair = "${module.keypair.keypair_name}" + availability_zone = "${var.server_zone}" + + network { + port = "${openstack_networking_port_v2.port_1.id}" + } + + block_device { + uuid = "${module.image_datasource.image_id}" + source_type = "image" + destination_type = "local" + boot_index = 0 + } + + block_device { + uuid = "${openstack_blockstorage_volume_v3.volume_1.id}" + source_type = "volume" + destination_type = "volume" + boot_index = -1 + } + + vendor_options { + ignore_resize_confirmation = true + } +} + +module "floatingip" { + source = "../floatingip" +} + +resource "openstack_networking_floatingip_associate_v2" "association_1" { + port_id = "${openstack_networking_port_v2.port_1.id}" + floating_ip = "${module.floatingip.floatingip_address}" +} \ No newline at end of file diff --git a/modules/server_remote_root_disk/outputs.tf b/modules/vpc/server_local_and_remote_disks/outputs.tf similarity index 100% rename from modules/server_remote_root_disk/outputs.tf rename to modules/vpc/server_local_and_remote_disks/outputs.tf diff --git a/modules/vpc/server_local_and_remote_disks/vars.tf b/modules/vpc/server_local_and_remote_disks/vars.tf new file mode 100644 index 0000000..ac5d62a --- /dev/null +++ b/modules/vpc/server_local_and_remote_disks/vars.tf @@ -0,0 +1,45 @@ +variable "os_user_name" {} + +variable "os_project_name" {} + +variable "os_user_password" {} + +variable "os_domain_name" {} + +variable "os_auth_url" {} + +variable "os_region" {} + +variable "server_vcpus" { + default = 4 +} + +variable "server_ram_mb" { + default = 8192 +} + +variable "server_root_disk_gb" { + default = 8 +} + +variable "server_second_disk_gb" { + default = 5 +} + +variable "server_second_volume_type" { + default = "fast.ru-3a" +} + +variable "server_name" { + default = "server_1" +} + +variable "server_image_name" {} + +variable "server_zone" { + default = "ru-3a" +} + +variable "server_ssh_key" {} + +variable "server_ssh_key_user" {} \ No newline at end of file diff --git a/modules/vpc/server_local_root_disk/README.md b/modules/vpc/server_local_root_disk/README.md new file mode 100644 index 0000000..e5edf99 --- /dev/null +++ b/modules/vpc/server_local_root_disk/README.md @@ -0,0 +1,40 @@ +# Server local root disk + +Terraform module for creating a single OpenStack Compute V2 Instance with a +local root volume. + +## Variables + + * `os_user_name` - OpenStack username. + + * `os_project_name` - OpenStack username. + + * `os_user_password` - OpenStack username. + + * `os_domain_name` - OpenStack username. + + * `os_auth_url` - OpenStack username. + + * `os_region` - OpenStack username. + + * `server_vcpus` - Server virtual CPUs (Default: 4). + + * `server_ram_mb` - Server RAM (MB) (Default: 8192). + + * `server_root_disk_gb` - Size of the root disk (GB) (Default: 8). + + * `server_name` - Name of the server (Default: "server_1") + + * `server_image_name` - Name of the image to find to create a server. + + * `server_zone` - Server availability zone. + + * `server_ssh_key` - SSH keypair name. + + * `server_ssh_key_user` - Owner of the SSH keypair. + +## Outputs + + * `server_id` - ID of the created OpenStack Server. + + * `server_port_id` - ID of the Server's port. \ No newline at end of file diff --git a/modules/vpc/server_local_root_disk/main.tf b/modules/vpc/server_local_root_disk/main.tf new file mode 100644 index 0000000..d93b7c0 --- /dev/null +++ b/modules/vpc/server_local_root_disk/main.tf @@ -0,0 +1,75 @@ +provider "openstack" { + user_name = "${var.os_user_name}" + tenant_name = "${var.os_project_name}" + password = "${var.os_user_password}" + project_domain_name = "${var.os_domain_name}" + user_domain_name = "${var.os_domain_name}" + auth_url = "${var.os_auth_url}" + region = "${var.os_region}" +} + +resource "random_string" "random_name" { + length = 5 + special = false +} + +module "flavor" { + source = "../flavor" + flavor_name = "flavor-${random_string.random_name.result}" + flavor_vcpus = "${var.server_vcpus}" + flavor_ram_mb = "${var.server_ram_mb}" + flavor_local_disk_gb = "${var.server_root_disk_gb}" +} + +module "nat" { + source = "../nat" +} + +resource "openstack_networking_port_v2" "port_1" { + name = "${var.server_name}-eth0" + network_id = "${module.nat.network_id}" + fixed_ip { + subnet_id = "${module.nat.subnet_id}" + } +} + +module "image_datasource" { + source = "../image_datasource" + image_name = "${var.server_image_name}" +} + +module "keypair" { + source = "../keypair" + keypair_name = "keypair-${random_string.random_name.result}" + keypair_public_key = "${var.server_ssh_key}" + keypair_user_id = "${var.server_ssh_key_user}" +} + +resource "openstack_compute_instance_v2" "instance_1" { + name = "${var.server_name}" + image_id = "${module.image_datasource.image_id}" + flavor_id = "${module.flavor.flavor_id}" + key_pair = "${module.keypair.keypair_name}" + availability_zone = "${var.server_zone}" + + network { + port = "${openstack_networking_port_v2.port_1.id}" + } + + lifecycle { + ignore_changes = ["image_id"] + } + + vendor_options { + ignore_resize_confirmation = true + } +} + +module "floatingip" { + source = "../floatingip" +} + +resource "openstack_networking_floatingip_associate_v2" "association_1" { + port_id = "${openstack_networking_port_v2.port_1.id}" + floating_ip = "${module.floatingip.floatingip_address}" +} diff --git a/modules/server_local_root_disk/outputs.tf b/modules/vpc/server_local_root_disk/outputs.tf similarity index 100% rename from modules/server_local_root_disk/outputs.tf rename to modules/vpc/server_local_root_disk/outputs.tf diff --git a/modules/vpc/server_local_root_disk/vars.tf b/modules/vpc/server_local_root_disk/vars.tf new file mode 100644 index 0000000..8371962 --- /dev/null +++ b/modules/vpc/server_local_root_disk/vars.tf @@ -0,0 +1,37 @@ +variable "os_user_name" {} + +variable "os_project_name" {} + +variable "os_user_password" {} + +variable "os_domain_name" {} + +variable "os_auth_url" {} + +variable "os_region" {} + +variable "server_vcpus" { + default = 4 +} + +variable "server_ram_mb" { + default = 8192 +} + +variable "server_root_disk_gb" { + default = 8 +} + +variable "server_name" { + default = "server_1" +} + +variable "server_image_name" {} + +variable "server_zone" { + default = "ru-3a" +} + +variable "server_ssh_key" {} + +variable "server_ssh_key_user" {} \ No newline at end of file diff --git a/modules/vpc/server_remote_root_disk/README.md b/modules/vpc/server_remote_root_disk/README.md new file mode 100644 index 0000000..74970e0 --- /dev/null +++ b/modules/vpc/server_remote_root_disk/README.md @@ -0,0 +1,44 @@ +# Server local root disk + +Terraform module for creating a single OpenStack Compute V2 Instance with a +remote root volume. + +## Variables + + * `os_user_name` - OpenStack username. + + * `os_project_name` - OpenStack username. + + * `os_user_password` - OpenStack username. + + * `os_domain_name` - OpenStack username. + + * `os_auth_url` - OpenStack username. + + * `os_region` - OpenStack username. + + * `server_vcpus` - Server virtual CPUs (Default: 4). + + * `server_ram_mb` - Server RAM (MB) (Default: 8192). + + * `server_volume_type` - Server remote root disk type (Default: "fast.ru-3a") + + * `server_root_disk_gb` - Size of the root disk (GB) (Default: 8). + + * `server_name` - Name of the server (Default: "server_1") + + * `server_image_name` - Name of the image to find to create a server. + + * `server_zone` - Server availability zone. + + * `server_ssh_key` - SSH keypair name. + + * `server_ssh_key_user` - Owner of the SSH keypair. + +## Outputs + + * `server_id` - ID of the created OpenStack Server. + + * `server_port_id` - ID of the Server's port. + + * `server_root_volume_id` - ID of the Server's root volume. \ No newline at end of file diff --git a/modules/vpc/server_remote_root_disk/main.tf b/modules/vpc/server_remote_root_disk/main.tf new file mode 100644 index 0000000..2560e51 --- /dev/null +++ b/modules/vpc/server_remote_root_disk/main.tf @@ -0,0 +1,88 @@ +provider "openstack" { + user_name = "${var.os_user_name}" + tenant_name = "${var.os_project_name}" + password = "${var.os_user_password}" + project_domain_name = "${var.os_domain_name}" + user_domain_name = "${var.os_domain_name}" + auth_url = "${var.os_auth_url}" + region = "${var.os_region}" +} + +resource "random_string" "random_name" { + length = 5 + special = false +} + +module "flavor" { + source = "../flavor" + flavor_name = "flavor-${random_string.random_name.result}" + flavor_vcpus = "${var.server_vcpus}" + flavor_ram_mb = "${var.server_ram_mb}" +} + +module "nat" { + source = "../nat" +} + +resource "openstack_networking_port_v2" "port_1" { + name = "${var.server_name}-eth0" + network_id = "${module.nat.network_id}" + fixed_ip { + subnet_id = "${module.nat.subnet_id}" + } +} + +module "image_datasource" { + source = "../image_datasource" + image_name = "${var.server_image_name}" +} + +module "keypair" { + source = "../keypair" + keypair_name = "keypair-${random_string.random_name.result}" + keypair_public_key = "${var.server_ssh_key}" + keypair_user_id = "${var.server_ssh_key_user}" +} + +resource "openstack_blockstorage_volume_v3" "volume_1" { + name = "volume-for-${var.server_name}" + size = "${var.server_root_disk_gb}" + image_id = "${module.image_datasource.image_id}" + volume_type = "${var.server_volume_type}" + availability_zone = "${var.server_zone}" + + lifecycle { + ignore_changes = ["image_id"] + } +} + +resource "openstack_compute_instance_v2" "instance_1" { + name = "${var.server_name}" + flavor_id = "${module.flavor.flavor_id}" + key_pair = "${module.keypair.keypair_name}" + availability_zone = "${var.server_zone}" + + network { + port = "${openstack_networking_port_v2.port_1.id}" + } + + block_device { + uuid = "${openstack_blockstorage_volume_v3.volume_1.id}" + source_type = "volume" + destination_type = "volume" + boot_index = 0 + } + + vendor_options { + ignore_resize_confirmation = true + } +} + +module "floatingip" { + source = "../floatingip" +} + +resource "openstack_networking_floatingip_associate_v2" "association_1" { + port_id = "${openstack_networking_port_v2.port_1.id}" + floating_ip = "${module.floatingip.floatingip_address}" +} \ No newline at end of file diff --git a/modules/server_two_remote_disks/outputs.tf b/modules/vpc/server_remote_root_disk/outputs.tf similarity index 72% rename from modules/server_two_remote_disks/outputs.tf rename to modules/vpc/server_remote_root_disk/outputs.tf index b0e1687..f15695a 100644 --- a/modules/server_two_remote_disks/outputs.tf +++ b/modules/vpc/server_remote_root_disk/outputs.tf @@ -9,7 +9,3 @@ output "server_port_id" { output "server_root_volume_id" { value = "${openstack_blockstorage_volume_v3.volume_1.id}" } - -output "server_second_volume_id" { - value = "${openstack_blockstorage_volume_v3.volume_2.id}" -} diff --git a/modules/vpc/server_remote_root_disk/vars.tf b/modules/vpc/server_remote_root_disk/vars.tf new file mode 100644 index 0000000..29ead15 --- /dev/null +++ b/modules/vpc/server_remote_root_disk/vars.tf @@ -0,0 +1,41 @@ +variable "os_user_name" {} + +variable "os_project_name" {} + +variable "os_user_password" {} + +variable "os_domain_name" {} + +variable "os_auth_url" {} + +variable "os_region" {} + +variable "server_vcpus" { + default = 4 +} + +variable "server_ram_mb" { + default = 8192 +} + +variable "server_root_disk_gb" { + default = 8 +} + +variable "server_volume_type" { + default = "fast.ru-3a" +} + +variable "server_name" { + default = "server_1" +} + +variable "server_image_name" {} + +variable "server_zone" { + default = "ru-3a" +} + +variable "server_ssh_key" {} + +variable "server_ssh_key_user" {} \ No newline at end of file diff --git a/modules/vpc/server_remote_root_disk_two_ports/README.md b/modules/vpc/server_remote_root_disk_two_ports/README.md new file mode 100644 index 0000000..8123821 --- /dev/null +++ b/modules/vpc/server_remote_root_disk_two_ports/README.md @@ -0,0 +1,44 @@ +# Server local root disk + +Terraform module for creating a single OpenStack Compute V2 Instance with two +remote volumes. + +## Variables + + * `os_user_name` - OpenStack username. + + * `os_project_name` - OpenStack username. + + * `os_user_password` - OpenStack username. + + * `os_domain_name` - OpenStack username. + + * `os_auth_url` - OpenStack username. + + * `os_region` - OpenStack username. + + * `server_vcpus` - Server virtual CPUs (Default: 4). + + * `server_ram_mb` - Server RAM (MB) (Default: 8192). + + * `server_volume_type` - Server remote root disk type (Default: "fast.ru-3a") + + * `server_root_disk_gb` - Size of the root disk (GB) (Default: 8). + + * `server_name` - Name of the server (Default: "server_1") + + * `server_image_name` - Name of the image to find to create a server. + + * `server_zone` - Server availability zone. + + * `server_ssh_key` - SSH keypair name. + + * `server_ssh_key_user` - Owner of the SSH keypair. + +## Outputs + + * `server_id` - ID of the created OpenStack Server. + + * `server_port_id` - ID of the Server's port. + + * `server_root_volume_id` - ID of the Server's root volume. \ No newline at end of file diff --git a/modules/vpc/server_remote_root_disk_two_ports/main.tf b/modules/vpc/server_remote_root_disk_two_ports/main.tf new file mode 100644 index 0000000..c7bee04 --- /dev/null +++ b/modules/vpc/server_remote_root_disk_two_ports/main.tf @@ -0,0 +1,111 @@ +provider "openstack" { + user_name = "${var.os_user_name}" + tenant_name = "${var.os_project_name}" + password = "${var.os_user_password}" + project_domain_name = "${var.os_domain_name}" + user_domain_name = "${var.os_domain_name}" + auth_url = "${var.os_auth_url}" + region = "${var.os_region}" +} + +resource "random_string" "random_name" { + length = 5 + special = false +} + +module "flavor" { + source = "../flavor" + flavor_name = "flavor-${random_string.random_name.result}" + flavor_vcpus = "${var.server_vcpus}" + flavor_ram_mb = "${var.server_ram_mb}" +} + +module "nat" { + source = "../nat" +} + +resource "openstack_networking_subnet_v2" "subnet_2" { + cidr = "10.0.0.0/24" + network_id = "${module.nat.network_id}" + + dns_nameservers = ["188.93.16.19", "188.93.17.19", "109.234.159.91"] +} + +resource "openstack_networking_port_v2" "port_1" { + name = "${var.server_name}-eth0" + network_id = "${module.nat.network_id}" + fixed_ip { + subnet_id = "${module.nat.subnet_id}" + } +} + +resource "openstack_networking_port_v2" "port_2" { + name = "${var.server_name}-eth1" + network_id = "${module.nat.network_id}" + fixed_ip { + subnet_id = "${openstack_networking_subnet_v2.subnet_2.id}" + } +} + +module "image_datasource" { + source = "../image_datasource" + image_name = "${var.server_image_name}" +} + +module "keypair" { + source = "../keypair" + keypair_name = "keypair-${random_string.random_name.result}" + keypair_public_key = "${var.server_ssh_key}" + keypair_user_id = "${var.server_ssh_key_user}" +} + +resource "openstack_blockstorage_volume_v3" "volume_1" { + name = "volume-for-${var.server_name}" + size = "${var.server_root_disk_gb}" + image_id = "${module.image_datasource.image_id}" + volume_type = "${var.server_volume_type}" + availability_zone = "${var.server_zone}" + + lifecycle { + ignore_changes = ["image_id"] + } +} + +resource "openstack_compute_instance_v2" "instance_1" { + name = "${var.server_name}" + flavor_id = "${module.flavor.flavor_id}" + key_pair = "${module.keypair.keypair_name}" + availability_zone = "${var.server_zone}" + + network { + port = "${openstack_networking_port_v2.port_1.id}" + } + + network { + port = "${openstack_networking_port_v2.port_2.id}" + } + + block_device { + uuid = "${openstack_blockstorage_volume_v3.volume_1.id}" + source_type = "volume" + destination_type = "volume" + boot_index = 0 + } + + metadata { + x_sel_server_default_addr = "{\"ipv4\":\"${openstack_networking_port_v2.port_1.all_fixed_ips.0}\"}" + } + + vendor_options { + ignore_resize_confirmation = true + } +} + +module "floatingip" { + source = "../floatingip" +} + +resource "openstack_networking_floatingip_associate_v2" "association_1" { + port_id = "${openstack_networking_port_v2.port_1.id}" + floating_ip = "${module.floatingip.floatingip_address}" +} \ No newline at end of file diff --git a/modules/server_remote_root_disk_two_ports/outputs.tf b/modules/vpc/server_remote_root_disk_two_ports/outputs.tf similarity index 100% rename from modules/server_remote_root_disk_two_ports/outputs.tf rename to modules/vpc/server_remote_root_disk_two_ports/outputs.tf diff --git a/modules/vpc/server_remote_root_disk_two_ports/vars.tf b/modules/vpc/server_remote_root_disk_two_ports/vars.tf new file mode 100644 index 0000000..f8e7683 --- /dev/null +++ b/modules/vpc/server_remote_root_disk_two_ports/vars.tf @@ -0,0 +1,41 @@ +variable "os_user_name" {} + +variable "os_project_name" {} + +variable "os_user_password" {} + +variable "os_domain_name" {} + +variable "os_auth_url" {} + +variable "os_region" {} + +variable "server_vcpus" { + default = 4 +} + +variable "server_ram_mb" { + default = 8192 +} + +variable "server_volume_type" { + default = "fast.ru-3a" +} + +variable "server_root_disk_gb" { + default = 8 +} + +variable "server_name" { + default = "server_1" +} + +variable "server_image_name" {} + +variable "server_zone" { + default = "ru-3a" +} + +variable "server_ssh_key" {} + +variable "server_ssh_key_user" {} \ No newline at end of file diff --git a/modules/vpc/subnet/README.md b/modules/vpc/subnet/README.md new file mode 100644 index 0000000..540d4b0 --- /dev/null +++ b/modules/vpc/subnet/README.md @@ -0,0 +1,17 @@ +# Subnet + +Terraform module for creating a single Selectel VPC Subnet. + +## Variables + + * `subnet_project_id` - Project of the Selectel VPC Subnet. + + * `subnet_region` - Region of the Selectel VPC Subnet. + + * `subnet_prefix_length` - Prefix length of the Selectel VPC Subnet. + + * `subnet_ip_version` - IP version of the Selectel VPC Subnet. + +## Outputs + + * `subnet_id` - ID of the created Selectel VPC Subnet. \ No newline at end of file diff --git a/modules/subnet/main.tf b/modules/vpc/subnet/main.tf similarity index 79% rename from modules/subnet/main.tf rename to modules/vpc/subnet/main.tf index 8dd0a84..36c2e01 100644 --- a/modules/subnet/main.tf +++ b/modules/vpc/subnet/main.tf @@ -1,4 +1,4 @@ -resource "selvpc_resell_subnet_v2" "subnet_1" { +resource "selectel_vpc_subnet_v2" "subnet_1" { project_id = "${var.subnet_project_id}" region = "${var.subnet_region}" prefix_length = "${var.subnet_prefix_length}" diff --git a/modules/vpc/subnet/outputs.tf b/modules/vpc/subnet/outputs.tf new file mode 100644 index 0000000..b39df12 --- /dev/null +++ b/modules/vpc/subnet/outputs.tf @@ -0,0 +1,3 @@ +output "subnet_id" { + value = "${selectel_vpc_subnet_v2.subnet_1.id}" +} diff --git a/modules/vpc/subnet/vars.tf b/modules/vpc/subnet/vars.tf new file mode 100644 index 0000000..b87e9af --- /dev/null +++ b/modules/vpc/subnet/vars.tf @@ -0,0 +1,11 @@ +variable "subnet_project_id" {} + +variable "subnet_region" {} + +variable "subnet_prefix_length" { + default = 29 +} + +variable "subnet_ip_version" { + default = "ipv4" +} diff --git a/modules/vpc/user/README.md b/modules/vpc/user/README.md new file mode 100644 index 0000000..36fd004 --- /dev/null +++ b/modules/vpc/user/README.md @@ -0,0 +1,13 @@ +# User + +Terraform module for creating a single Selectel VPC User. + +## Variables + + * `user_name` - Name of the Selectel VPC User (Default: "user_1"). + + * `user_password` - Password of the Selectel VPC User. + +## Outputs + + * `user_id` - ID of the created Selectel VPC User. \ No newline at end of file diff --git a/modules/user/main.tf b/modules/vpc/user/main.tf similarity index 61% rename from modules/user/main.tf rename to modules/vpc/user/main.tf index 077abac..099169c 100644 --- a/modules/user/main.tf +++ b/modules/vpc/user/main.tf @@ -1,4 +1,4 @@ -resource "selvpc_resell_user_v2" "user_1" { +resource "selectel_vpc_user_v2" "user_1" { name = "${var.user_name}" password = "${var.user_password}" } diff --git a/modules/vpc/user/outputs.tf b/modules/vpc/user/outputs.tf new file mode 100644 index 0000000..396dd81 --- /dev/null +++ b/modules/vpc/user/outputs.tf @@ -0,0 +1,3 @@ +output "user_id" { + value = "${selectel_vpc_user_v2.user_1.id}" +} diff --git a/modules/vpc/user/vars.tf b/modules/vpc/user/vars.tf new file mode 100644 index 0000000..a61b8d4 --- /dev/null +++ b/modules/vpc/user/vars.tf @@ -0,0 +1,5 @@ +variable "user_name" { + default = "user_1" +} + +variable "user_password" {} diff --git a/modules/vpc/vrrp_subnet/README.md b/modules/vpc/vrrp_subnet/README.md new file mode 100644 index 0000000..e983c2c --- /dev/null +++ b/modules/vpc/vrrp_subnet/README.md @@ -0,0 +1,17 @@ +# VRRP Subnet + +Terraform module for creating a single Selectel VPC VRRP Subnet. + +## Variables + + * `vrrp_subnet_project_id` - Project of the Selectel VPC VRRP Subnet. + + * `vrrp_subnet_region` - Region of the Selectel VPC VRRP Subnet. + + * `vrrp_subnet_prefix_length` - Prefix length of the Selectel VPC VRRP Subnet. + + * `vrrp_subnet_ip_version` - IP version of the Selectel VPC VRRP Subnet. + +## Outputs + + * `vrrp_subnet_id` - ID of the created Selectel VPC VRRP Subnet. \ No newline at end of file diff --git a/modules/vrrp_subnet/main.tf b/modules/vpc/vrrp_subnet/main.tf similarity index 81% rename from modules/vrrp_subnet/main.tf rename to modules/vpc/vrrp_subnet/main.tf index d1bc5c3..16f8b72 100644 --- a/modules/vrrp_subnet/main.tf +++ b/modules/vpc/vrrp_subnet/main.tf @@ -1,4 +1,4 @@ -resource "selvpc_resell_vrrp_subnet_v2" "vrrp_subnet_1" { +resource "selectel_vpc_vrrp_subnet_v2" "vrrp_subnet_1" { project_id = "${var.vrrp_subnet_project_id}" master_region = "${var.vrrp_subnet_master_region}" slave_region = "${var.vrrp_subnet_slave_region}" diff --git a/modules/vpc/vrrp_subnet/outputs.tf b/modules/vpc/vrrp_subnet/outputs.tf new file mode 100644 index 0000000..c2ad237 --- /dev/null +++ b/modules/vpc/vrrp_subnet/outputs.tf @@ -0,0 +1,3 @@ +output "vrrp_subnet_id" { + value = "${selectel_vpc_vrrp_subnet_v2.vrrp_subnet_1.id}" +} diff --git a/modules/vpc/vrrp_subnet/vars.tf b/modules/vpc/vrrp_subnet/vars.tf new file mode 100644 index 0000000..e689339 --- /dev/null +++ b/modules/vpc/vrrp_subnet/vars.tf @@ -0,0 +1,13 @@ +variable "vrrp_subnet_project_id" {} + +variable "vrrp_subnet_master_region" {} + +variable "vrrp_subnet_slave_region" {} + +variable "vrrp_subnet_prefix_length" { + default = 29 +} + +variable "vrrp_subnet_ip_version" { + default = "ipv4" +} diff --git a/modules/vrrp_subnet/README.md b/modules/vrrp_subnet/README.md deleted file mode 100644 index b763683..0000000 --- a/modules/vrrp_subnet/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# VRRP Subnet - -Terraform module for creating a single SelVPC V2 VRRP Subnet. - -## Variables - - * `vrrp_subnet_project_id` - Project of the SelVPC V2 VRRP Subnet. - - * `vrrp_subnet_region` - Region of the SelVPC V2 VRRP Subnet. - - * `vrrp_subnet_prefix_length` - Prefix length of the SelVPC V2 VRRP Subnet. - - * `vrrp_subnet_ip_version` - IP version of the SelVPC V2 VRRP Subnet. - -## Outputs - - * `vrrp_subnet_id` - ID of the created SelVPC V2 VRRP Subnet. \ No newline at end of file diff --git a/modules/vrrp_subnet/outputs.tf b/modules/vrrp_subnet/outputs.tf deleted file mode 100644 index 410f7a8..0000000 --- a/modules/vrrp_subnet/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "vrrp_subnet_id" { - value = "${selvpc_resell_vrrp_subnet_v2.vrrp_subnet_1.id}" -} diff --git a/modules/vrrp_subnet/vars.tf b/modules/vrrp_subnet/vars.tf deleted file mode 100644 index a8c46ff..0000000 --- a/modules/vrrp_subnet/vars.tf +++ /dev/null @@ -1,21 +0,0 @@ -variable "vrrp_subnet_project_id" { - description = "Project of the SelVPC V2 VRRP Subnet" -} - -variable "vrrp_subnet_master_region" { - description = "Master region of the SelVPC V2 VRRP Subnet" -} - -variable "vrrp_subnet_slave_region" { - description = "Slave region of the SelVPC V2 VRRP Subnet" -} - -variable "vrrp_subnet_prefix_length" { - description = "Prefix length of the SelVPC V2 VRRP Subnet" - default = 29 -} - -variable "vrrp_subnet_ip_version" { - description = "IP version of the SelVPC V2 VRRP Subnet" - default = "ipv4" -}