From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp10.mail.ru (smtp10.mail.ru [94.100.181.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id C4FDD469719 for ; Fri, 18 Sep 2020 17:20:26 +0300 (MSK) Date: Fri, 18 Sep 2020 17:20:21 +0300 From: "Alexander V. Tikhonov" Message-ID: <20200918142021.GA27064@hpalx> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Tarantool-patches] [PATCH 1/4] extra: add Terraform config files List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: sergeyb@tarantool.org Cc: tarantool-patches@dev.tarantool.org Hi Sergey, patch has only configuration data and enough comments, so patch LGTM. On Wed, Sep 16, 2020 at 10:07:19AM +0300, sergeyb@tarantool.org wrote: > From: Sergey Bronnikov > > For testing Tarantool with Jepsen we use virtual machines as they provides > better resource isolation in comparison to containers. Jepsen tests may need a > single instance or a set of instances for testing cluster. To setup virtual > machines we use Terraform [1]. Patch adds a set of configuration files for > Terraform that can create required number of virtual machines in MCS and output > IP addresses to stdout. > > Terraform needs some parameters before run. They are: > > - id, identificator of a test stand that should be specific for this run, id > also is a part of virtual machine name > - keypair_name, name of keypair used in a cloud, public SSH key of that key pair > will be placed to virtual machine > - instance_count, number of virtual machines in a test stand > - ssh_key, SSH private key, used to access to a virtual machine > - user_name > - password > - tenant_id > - user_domain_id > > These parameters can be passed via enviroment variables with TF_VAR_ prefix > (like TF_VAR_id) or via command-line parameters. > > To demonstrate full lifecycle of a test stand with Terraform one needs to > perform these commands: > > terraform init extra/tf > terraform apply extra/tf > terraform output instance_names > terraform output instance_ips > terraform destroy extra/tf > > 1. https://www.terraform.io/ > > Part of #5277 > --- > extra/tf/main.tf | 43 ++++++++++++++++++++++++++++++++++++++ > extra/tf/outputs.tf | 10 +++++++++ > extra/tf/provider.tf | 49 ++++++++++++++++++++++++++++++++++++++++++++ > extra/tf/versions.tf | 8 ++++++++ > 4 files changed, 110 insertions(+) > create mode 100644 extra/tf/main.tf > create mode 100644 extra/tf/outputs.tf > create mode 100644 extra/tf/provider.tf > create mode 100644 extra/tf/versions.tf > > diff --git a/extra/tf/main.tf b/extra/tf/main.tf > new file mode 100644 > index 000000000..0b760884e > --- /dev/null > +++ b/extra/tf/main.tf > @@ -0,0 +1,43 @@ > +resource "openstack_compute_instance_v2" "instance" { > + count = var.instance_count > + > + name = "tarantool_testing-${count.index + 1}-${var.id}" > + > + image_name = "Ubuntu-18.04-202003" > + > + image_id = "3f03b393-d45b-455d-bdf5-0ac4399ecf42" > + > + flavor_name = "Basic-1-2-20" > + > + key_pair = var.keypair_name > + > + config_drive = true > + > + availability_zone = "DP1" > + > + security_groups = [ > + "default", > + "allow-ssh", > + "allow-tarantool" > + ] > + > + network { > + name = "ext-net" > + } > + > + provisioner "remote-exec" { > + inline = [ > + "sudo hostnamectl set-hostname n${count.index + 1}", > + "sudo apt-get update" > + ] > + } > + > + connection { > + host = self.access_ip_v4 > + type = "ssh" > + user = "ubuntu" > + timeout = "5m" > + agent = true > + private_key = file(var.ssh_key_path) > + } > +} > diff --git a/extra/tf/outputs.tf b/extra/tf/outputs.tf > new file mode 100644 > index 000000000..5690d6b0d > --- /dev/null > +++ b/extra/tf/outputs.tf > @@ -0,0 +1,10 @@ > +output "instance_names" { > + description = "List of names assigned to the instances." > + value = openstack_compute_instance_v2.instance.*.name > +} > + > +output "instance_ips" { > + description = "List of public IP addresses assigned to the instances." > + value = openstack_compute_instance_v2.instance.*.access_ip_v4 > + sensitive = true > +} > diff --git a/extra/tf/provider.tf b/extra/tf/provider.tf > new file mode 100644 > index 000000000..cd9488ce5 > --- /dev/null > +++ b/extra/tf/provider.tf > @@ -0,0 +1,49 @@ > +variable "user_name" { > + type = string > +} > + > +variable "password" { > + type = string > +} > + > +variable "tenant_id" { > + type = string > +} > + > +variable "user_domain_id" { > + type = string > +} > + > +variable "keypair_name" { > + type = string > +} > + > +variable "ssh_key_path" { > + type = string > +} > + > +variable "instance_count" { > + type = number > + default = 1 > + description = "Number of instances." > + > + validation { > + condition = var.instance_count > 0 > + error_message = "The instance_count value must be greater than zero." > + } > +} > + > +variable "id" { > + type = string > + default = null > +} > + > +provider "openstack" { > + user_name = var.user_name > + password = var.password > + tenant_id = var.tenant_id > + user_domain_id = var.user_domain_id > + auth_url = "https://infra.mail.ru/identity/v3/" > + region = "RegionOne" > + use_octavia = true > +} > diff --git a/extra/tf/versions.tf b/extra/tf/versions.tf > new file mode 100644 > index 000000000..5af3d608b > --- /dev/null > +++ b/extra/tf/versions.tf > @@ -0,0 +1,8 @@ > +terraform { > + required_providers { > + openstack = { > + source = "terraform-providers/openstack" > + } > + } > + required_version = ">= 0.13" > +} > -- > 2.25.1 >