Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Fontana-Indico committed Mar 29, 2024
0 parents commit 0e427c1
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.terraform*
terraform.tfstate
terraform.tfstate.*
.env

37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

# To use a static_ip

external_ip = "xxx.yyy.zzz.qqq"

# Connecting

ip_address=$(terraform output cluster_manager_ip)
terraform output private_key
get the text between << EOT >>

Paste into $HOME/.ssh/machine_name.pem

ssh -i $HOME/.ssh/machine_name.pem indico@${ip_address}

# execute the setup script
source setup.sh

# Git clone the source
git clone https://github.com/IndicoDataSolutions/tf_cod.git
chmod 777 -R tf_cod
git checkout 6.7-customer-hotfix-1
cd tf_cod
cd=$(pwd)
docker run \
--cap-add=CAP_IPC_LOCK \
-e ARM_CLIENT_ID=${ARM_CLIENT_ID} \
-e ARM_TENANT_ID=${ARM_TENANT_ID} \
-e ARM_CLIENT_SECRET=${ARM_CLIENT_SECRET} \
-e ARM_SUBSCRIPTION_ID=${ARM_SUBSCRIPTION_ID} \
-e VAULT_USERNAME=${VAULT_USERNAME} \
-e VAULT_PASSWORD=${VAULT_PASSWORD} \
-it -v ${cd}:/app -v ${HOME}:/home/indico harbor.devops.indico.io/indico/indico-cod-install-azure:latest
cd azure
create overrides.tfvars
rake -f /src/Rakefile init
rake -f /src/Rakefile plan
68 changes: 68 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.95.0"
}
}
}

provider "azurerm" {
features {}
}

provider "http" {}


resource "azurerm_resource_group" "cod-network" {
name = var.resource_group_name
location = var.region
}


module "networking" {
depends_on = [azurerm_resource_group.cod-network]
source = "app.terraform.io/indico/indico-azure-network/mod"
version = "4.0.1"
network_type = "create"
label = var.label
vnet_cidr = var.vnet_cidr
subnet_cidrs = var.subnet_cidrs
resource_group_name = var.resource_group_name
region = var.region
allow_public = var.allow_public
}


data "http" "workstation-external-ip" {
url = "http://ipv4.icanhazip.com"
}

# Override with variable or hardcoded value if necessary
locals {
external-cidr = "${chomp(data.http.workstation-external-ip.body)}/32"
external_ip = coalesce(var.external_ip, local.external-cidr)
}

resource "tls_private_key" "pk" {
algorithm = "RSA"
rsa_bits = 4096
}


module "cluster-manager" {
source = "app.terraform.io/indico/indico-azure-cluster-manager/mod"
version = "3.0.3"

label = "${var.label}-dcm"

subnet_id = module.networking.subnet_id
external_ip = local.external_ip
public_key = tls_private_key.pk.public_key_openssh
resource_group_name = var.resource_group_name
region = var.region
vm_size = var.cluster_manager_vm_size
offer = "0001-com-ubuntu-server-focal"
publisher = "Canonical"
sku = "20_04-lts-gen2"
}
19 changes: 19 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@


output "cluster_manager_ip" {
value = module.cluster-manager.cluster_manager_ip
}

output "private_key" {
value = tls_private_key.pk.private_key_pem
sensitive = true
}

output "subnet_id" {
value = module.networking.subnet_id
}

output "vnet_id" {
value = module.networking.vnet_id
}

29 changes: 29 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo service docker start
sudo chmod 666 /var/run/docker.sock
sudo systemctl restart docker.service
sudo chmod 666 /var/run/docker.sock

touch $HOME/.indico

sudo chmod 777 -R /home/indico
sudo chmod 700 /home/indico/.ssh
sudo chmod 600 /home/indico/.ssh/*
sudo chmod 666 /var/run/docker.sock
sudo chmod 777 -R /home/indico/.docker


8 changes: 8 additions & 0 deletions user_vars.auto.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


# to set a static external IP address
# external_ip = "xxx.yyy.zzz.qqq"

resource_group_name = "bread-pre-existing"
label = "breadnetwork"
region = "eastus"
41 changes: 41 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@


variable "resource_group_name" {
type = string
}

variable "region" {
type = string
}

variable "label" {
type = string
}

variable "vnet_cidr" {
type = string
default = "192.168.0.0/20"
}

variable "subnet_cidrs" {
default = ["192.168.0.0/22"]
}

variable "allow_public" {
type = string
default = false
}

variable "external_ip" {
default = null # defaults to workstation's public IP address
type = string
}

variable "cluster_manager_vm_size" {
type = string
default = "Standard_DS2_v2"
description = "The cluster manager instance size"
}



0 comments on commit 0e427c1

Please sign in to comment.