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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ tf/
# build artifacts
version.go
build/
.idea
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ BUILDDIR ?= $(abspath build)
# docker doesn't allow "+" in image tags: https://github.com/docker/distribution/issues/1201
export ROBOTEST_DOCKER_VERSION ?= $(subst +,-,$(VERSION))
export ROBOTEST_DOCKER_TAG ?=
export ROBOTEST_DOCKER_ARGS ?= --pull
export ROBOTEST_DOCKER_ARGS ?=
DOCKERFLAGS := --rm=true $(NOROOT) -v $(PWD):$(SRCDIR) -v $(BUILDDIR):$(SRCDIR)/build -w $(SRCDIR)
BUILDBOX := robotest:buildbox
BUILDBOX_IIDFILE := $(BUILDDIR)/.robotest-buildbox.iid
Expand Down
26 changes: 26 additions & 0 deletions assets/terraform/vsphere/bootstrap/redhat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
#
# Copyright 2020 Gravitational, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# VM bootstrap script for CentOS/RHEL
#

sudo sysctl -w net.bridge.bridge-nf-call-iptables=1
sudo sysctl -w net.bridge.bridge-nf-call-ip6tables=1
echo 'net.bridge.bridge-nf-call-iptables = 1' | sudo tee -a /etc/sysctl.conf
echo 'net.bridge.bridge-nf-call-ip6tables = 1' | sudo tee -a /etc/sysctl.conf
sudo sysctl -system
echo "Done"
87 changes: 87 additions & 0 deletions assets/terraform/vsphere/config.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
variable "vsphere_user" {
description = "vSphere username"
type = string
}

variable "vsphere_password" {
description = "vSphere password"
type = string
}

variable "vsphere_server" {
description = "vSphere server"
type = string
}

variable "datacenter" {
description = "The vSphere datacenter where resources will be created"
type = string
}

variable "cluster" {
description = "The vSphere cluster where resources will be created"
type = string
}

variable "datastore" {
description = "The vSphere datastore where VM disks will be stored"
type = string
}

variable "vm_folder" {
description = "The vSphere folder where VMs will be created"
type = string
}

variable "network" {
description = "Network for VM NIC."
type = string
}

variable "template" {
description = "Template to clone VMs from"
type = string
}

variable "node_tag" {
description = "vSphere-friendly cluster name to use as a prefix for resources."
type = string
}

variable "vm_type" {
description = "Type of VM to provision"
type = string
}

variable "os_user" {
description = "SSH user to login onto nodes"
type = string
}

variable "ssh_pub_key_path" {
description = "Path to the public SSH key."
type = string
}

variable "nodes" {
description = "Number of nodes to provision"
type = number
default = 1
}

provider "vsphere" {
user = var.vsphere_user
password = var.vsphere_password
vsphere_server = var.vsphere_server

allow_unverified_ssl = true
}

data "vsphere_datacenter" "dc" {
name = var.datacenter
}

data "vsphere_compute_cluster" "cluster" {
name = var.cluster
datacenter_id = data.vsphere_datacenter.dc.id
}
8 changes: 8 additions & 0 deletions assets/terraform/vsphere/network.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Network
#

data "vsphere_network" "network" {
name = var.network
datacenter_id = data.vsphere_datacenter.dc.id
}
46 changes: 46 additions & 0 deletions assets/terraform/vsphere/node.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#
# Virtual Machine node
#

resource "vsphere_virtual_machine" "node" {
#TODO: Move to vars!!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a jira?

guest_id = "rhel7_64Guest"
count = var.nodes
name = "${var.node_tag}-node-${count.index}"
folder = var.vm_folder

resource_pool_id = data.vsphere_compute_cluster.cluster.resource_pool_id

num_cpus = 4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 4? Is there some component which requires this many minimum cpus?

memory = 8192

network_interface {
network_id = data.vsphere_network.network.id
}

disk {
label = "disk0"
size = 64
thin_provisioned = false #TODO(ag): Update the template to true and change here
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: jira please. which template?

}

clone {
template_uuid = data.vsphere_virtual_machine.template.id

}

extra_config = {
"guestinfo.ssh_user" = var.os_user
"guestinfo.ssh_public_key_data" = file(var.ssh_pub_key_path)
}
}

data "vsphere_datastore" "datastore" {
name = var.datastore
datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_virtual_machine" "template" {
name = var.template
datacenter_id = data.vsphere_datacenter.dc.id
}
23 changes: 23 additions & 0 deletions assets/terraform/vsphere/os.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# OS configuration
#

variable "oss" {
description = "Map of supported Linux distributions"
type = "map"

default = {
"redhat:7.9" = "toTemplate1"
"redhat7.9" = "toTemplate1"
}
}

#variable "os" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

# description = "Map of supported Linux distributions"
# type = "map"
#
# default = {
# "redhat:7.9" = "toTemplate1"
# "redhat7.9" = "toTemplate1"
# }
#}
11 changes: 11 additions & 0 deletions assets/terraform/vsphere/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Output Variables
#

output "private_ips" {
value = vsphere_virtual_machine.node.*.default_ip_address
}

output "public_ips" {
value = vsphere_virtual_machine.node.*.default_ip_address
}
3 changes: 3 additions & 0 deletions assets/terraform/vsphere/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.12"
}
5 changes: 3 additions & 2 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ DOCKER_REPO := quay.io/gravitational
ROBOTEST_DOCKER_VERSION ?=
# An empty tag will be ignored
ROBOTEST_DOCKER_TAG ?=
ROBOTEST_DOCKER_ARGS ?= --pull
ROBOTEST_DOCKER_ARGS ?=

GRAVITY_VERSION := 5.5.50
TERRAFORM_VERSION := 0.12.9
Expand All @@ -27,9 +27,10 @@ TERRAFORM_PROVIDER_AZURERM_VERSION := 1.5.0
TERRAFORM_PROVIDER_GOOGLE_VERSION := 2.15.0
TERRAFORM_PROVIDER_RANDOM_VERSION := 2.2.0
TERRAFORM_PROVIDER_TEMPLATE_VERSION := 2.1.2
TERRAFORM_PROVIDER_VSPHERE_VERSION := 1.14.0
export

providers := AZURERM AWS GOOGLE RANDOM TEMPLATE
providers := AZURERM AWS GOOGLE RANDOM TEMPLATE VSPHERE
provider_args := $(foreach provider,$(providers),--build-arg TERRAFORM_PROVIDER_$(provider)_VERSION=$$TERRAFORM_PROVIDER_$(provider)_VERSION)

BUILD_ARGS := \
Expand Down
2 changes: 1 addition & 1 deletion docker/build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM quay.io/gravitational/debian-venti:go1.16.6-buster
FROM quay.io/gravitational/debian-venti:go1.17.5-stretch
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change the repo right now itself? We have put those in our gcr right?


ARG UID
ARG GID
Expand Down
6 changes: 5 additions & 1 deletion docker/e2e/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM quay.io/gravitational/debian-grande:stretch
FROM quay.io/gravitational/debian-grande:buster

ARG TERRAFORM_VERSION
ARG CHROMEDRIVER_VERSION
Expand Down Expand Up @@ -59,6 +59,10 @@ RUN mkdir -p /robotest
WORKDIR /robotest
COPY entrypoint.sh /entrypoint.sh
COPY build/robotest-e2e /usr/bin/robotest-e2e
COPY polaris.pub /robotest/polaris.pub
COPY polaris.pem /robotest/polaris.pem
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the path of polaris.pem and pub right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is this the same polaris.pem, or a new one. I think it might be better to use a different one here.

RUN chmod 0644 /robotest/polaris.pem
#TODO: Change the user on the template and the SSH keys. polaris is not meant for this

RUN chmod +x /usr/bin/robotest-e2e && \
chmod +x /entrypoint.sh
Expand Down
12 changes: 10 additions & 2 deletions docker/suite/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM quay.io/gravitational/debian-grande:stretch
FROM quay.io/gravitational/debian-grande:buster

RUN apt-get update && \
apt-get install -y curl unzip gnupg2 dirmngr
Expand All @@ -23,6 +23,7 @@ ARG TERRAFORM_PROVIDER_AWS_VERSION
ARG TERRAFORM_PROVIDER_GOOGLE_VERSION
ARG TERRAFORM_PROVIDER_TEMPLATE_VERSION
ARG TERRAFORM_PROVIDER_RANDOM_VERSION
ARG TERRAFORM_PROVIDER_VSPHERE_VERSION
ENV TF_TARBALL https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip

ENV TF_PLUGINS \
Expand All @@ -33,7 +34,10 @@ ENV TF_PLUGINS \
# Google Compute Engine
https://releases.hashicorp.com/terraform-provider-google/${TERRAFORM_PROVIDER_GOOGLE_VERSION}/terraform-provider-google_${TERRAFORM_PROVIDER_GOOGLE_VERSION}_linux_amd64.zip \
https://releases.hashicorp.com/terraform-provider-template/${TERRAFORM_PROVIDER_TEMPLATE_VERSION}/terraform-provider-template_${TERRAFORM_PROVIDER_TEMPLATE_VERSION}_linux_amd64.zip \
https://releases.hashicorp.com/terraform-provider-random/${TERRAFORM_PROVIDER_RANDOM_VERSION}/terraform-provider-random_${TERRAFORM_PROVIDER_RANDOM_VERSION}_linux_amd64.zip
https://releases.hashicorp.com/terraform-provider-random/${TERRAFORM_PROVIDER_RANDOM_VERSION}/terraform-provider-random_${TERRAFORM_PROVIDER_RANDOM_VERSION}_linux_amd64.zip \
# vSphere
https://releases.hashicorp.com/terraform-provider-vsphere/${TERRAFORM_PROVIDER_VSPHERE_VERSION}/terraform-provider-vsphere_1.14.0_linux_amd64.zip


RUN curl ${TF_TARBALL} -o terraform.zip && \
unzip terraform.zip -d /usr/bin && \
Expand All @@ -59,5 +63,9 @@ WORKDIR /robotest
COPY build/robotest-suite /usr/bin/robotest-suite
COPY terraform /robotest/terraform
COPY run_suite.sh /usr/bin/run_suite.sh
COPY polaris.pub /robotest/polaris.pub
COPY polaris.pem /robotest/polaris.pem
RUN chmod 0660 /robotest/polaris.pem
#TODO: Change the user on the template and the SSH keys. polaris is not meant for this

RUN chmod +x /usr/bin/robotest-suite
16 changes: 15 additions & 1 deletion infra/gravity/cluster_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,21 @@ func (c *TestContext) OfflineInstall(nodes []Gravity, param InstallParam) error
defer cancel()

param.CloudProvider = c.provisionerCfg.CloudProvider
master := nodes[0].(*gravity)

// Before the typecast, log the details of `nodes`
c.Logger().Infof("Nodes slice: %v", nodes)
for i, node := range nodes {
c.Logger().Infof("Node[%d]: type=%T, value=%v", i, node, node)
}

// Attempt the typecast
master, ok := nodes[0].(*gravity)
if !ok {
c.Logger().Fatalf("Failed to typecast nodes[0] to *gravity. Actual type: %T", nodes[0])
}

// If the typecast is successful, proceed with the rest of your code
c.Logger().Infof("Typecast successful. master: %v", master)
if param.Token == "" {
param.Token = "ROBOTEST"
}
Expand Down
Loading