aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryoonsoonjahng <yoonsoon.jahng@yoppworks.com>2020-09-10 12:12:40 -0400
committerNeil Derraugh <neil.derraugh@yoppworks.com>2020-09-14 21:25:17 +0000
commitc0987507209cdfa232b5113dbb386bfc3cf87805 (patch)
tree8214fa05f75253a10f01d06dfcb99ae788ddc408
parent8e49e9261a4aa68670937f88d44b26a129ec2b4f (diff)
Added terragrunt script pulling integration/terraform.
Issue-ID: INT-1719 Change-Id: I0282f010d07e0a1cc1259133f4237ea7e1d72126 Signed-off-by: yoonsoonjahng <yoonsoon.jahng@yoppworks.com>
-rw-r--r--.gitignore1
-rw-r--r--terragrunt/openlab/RegionOne/region.hcl5
-rw-r--r--terragrunt/openlab/RegionOne/stage/compute/control/control-plane.sh33
-rw-r--r--terragrunt/openlab/RegionOne/stage/compute/control/terragrunt.hcl35
-rw-r--r--terragrunt/openlab/RegionOne/stage/compute/nfsserver/nfs-server.sh20
-rw-r--r--terragrunt/openlab/RegionOne/stage/compute/nfsserver/terragrunt.hcl35
-rw-r--r--terragrunt/openlab/RegionOne/stage/compute/worker/terragrunt.hcl35
-rw-r--r--terragrunt/openlab/RegionOne/stage/compute/worker/worker-node.sh36
-rw-r--r--terragrunt/openlab/RegionOne/stage/env.hcl22
-rw-r--r--terragrunt/openlab/RegionOne/stage/keypair/terragrunt.hcl22
-rw-r--r--terragrunt/openlab/RegionOne/stage/kubernetes/terragrunt.hcl47
-rw-r--r--terragrunt/openlab/RegionOne/stage/network/terragrunt.hcl22
-rw-r--r--terragrunt/openlab/RegionOne/stage/rancher/terragrunt.hcl42
-rw-r--r--terragrunt/openlab/RegionOne/stage/securitygroup/terragrunt.hcl20
-rw-r--r--terragrunt/openlab/account.hcl11
-rw-r--r--terragrunt/openlab/terragrunt.hcl64
16 files changed, 450 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 67b480a..ccf751a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
.tox/
.terraform/
+.terragrunt-cache/
diff --git a/terragrunt/openlab/RegionOne/region.hcl b/terragrunt/openlab/RegionOne/region.hcl
new file mode 100644
index 0000000..5f664ae
--- /dev/null
+++ b/terragrunt/openlab/RegionOne/region.hcl
@@ -0,0 +1,5 @@
+# Set common variables for the region. This is automatically pulled in in the root terragrunt.hcl configuration to
+# configure the remote state bucket and pass forward to the child modules as inputs.
+locals {
+ region = ""
+} \ No newline at end of file
diff --git a/terragrunt/openlab/RegionOne/stage/compute/control/control-plane.sh b/terragrunt/openlab/RegionOne/stage/compute/control/control-plane.sh
new file mode 100644
index 0000000..881f651
--- /dev/null
+++ b/terragrunt/openlab/RegionOne/stage/compute/control/control-plane.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+DOCKER_VERSION=18.09.5
+
+export DEBIAN_FRONTEND=noninteractive
+
+apt-get update
+
+curl https://releases.rancher.com/install-docker/$DOCKER_VERSION.sh | sh
+mkdir -p /etc/systemd/system/docker.service.d/
+cat > /etc/systemd/system/docker.service.d/docker.conf << EOF
+[Service]
+ExecStart=
+ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry=nexus3.onap.org:10001
+EOF
+
+sudo usermod -aG docker ubuntu
+
+systemctl daemon-reload
+systemctl restart docker
+apt-mark hold docker-ce
+
+IP_ADDR=`ip address |grep ens|grep inet|awk '{print $2}'| awk -F / '{print $1}'`
+HOSTNAME=`hostname`
+
+echo "$IP_ADDR $HOSTNAME" >> /etc/hosts
+
+docker login -u docker -p docker nexus3.onap.org:10001
+
+sudo apt-get install make -y
+
+
+exit 0 \ No newline at end of file
diff --git a/terragrunt/openlab/RegionOne/stage/compute/control/terragrunt.hcl b/terragrunt/openlab/RegionOne/stage/compute/control/terragrunt.hcl
new file mode 100644
index 0000000..46a2c24
--- /dev/null
+++ b/terragrunt/openlab/RegionOne/stage/compute/control/terragrunt.hcl
@@ -0,0 +1,35 @@
+locals {
+ # Automatically load account-level variables
+ region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+ env_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+
+ region = local.region_vars.locals.region
+ environment = local.env_vars.locals.environment
+ network = local.env_vars.locals.network
+}
+
+terraform {
+ source = "git::https://gerrit.onap.org/r/integration/terraform/openlab/modules/openstack/compute"
+}
+
+include {
+ path = find_in_parent_folders()
+}
+
+dependencies {
+ paths = ["../../keypair", "../../network", "../../securitygroup"]
+}
+
+inputs = {
+
+ environment = local.environment
+ cluster_name = "${local.region}-${local.environment}"
+
+ node_name = "worker-node"
+ image = "ubuntu-18.04"
+ flavor = "m1.xlarge"
+ floating_ip_pool = "external"
+ # Read as File stream
+ user_data = file("control-plane.sh")
+ node_count = 3
+}
diff --git a/terragrunt/openlab/RegionOne/stage/compute/nfsserver/nfs-server.sh b/terragrunt/openlab/RegionOne/stage/compute/nfsserver/nfs-server.sh
new file mode 100644
index 0000000..127a554
--- /dev/null
+++ b/terragrunt/openlab/RegionOne/stage/compute/nfsserver/nfs-server.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+export DEBIAN_FRONTEND=noninteractive
+
+apt-get update
+
+IP_ADDR=`ip address |grep ens|grep inet|awk '{print $2}'| awk -F / '{print $1}'`
+HOSTNAME=`hostname`
+
+echo "$IP_ADDR $HOSTNAME" >> /etc/hosts
+
+sudo apt-get install make -y
+
+# nfs server
+sudo apt-get install nfs-kernel-server -y
+
+sudo mkdir -p /nfs_share
+sudo chown nobody:nogroup /nfs_share/
+
+exit 0 \ No newline at end of file
diff --git a/terragrunt/openlab/RegionOne/stage/compute/nfsserver/terragrunt.hcl b/terragrunt/openlab/RegionOne/stage/compute/nfsserver/terragrunt.hcl
new file mode 100644
index 0000000..4e7f83f
--- /dev/null
+++ b/terragrunt/openlab/RegionOne/stage/compute/nfsserver/terragrunt.hcl
@@ -0,0 +1,35 @@
+locals {
+ # Automatically load account-level variables
+ region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+ env_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+
+ region = local.region_vars.locals.region
+ environment = local.env_vars.locals.environment
+ network = local.env_vars.locals.network
+}
+
+terraform {
+ source = "git::https://gerrit.onap.org/r/integration/terraform/openlab/modules/openstack/compute"
+}
+
+include {
+ path = find_in_parent_folders()
+}
+
+dependencies {
+ paths = ["../../keypair", "../../network", "../../securitygroup"]
+}
+
+inputs = {
+
+ environment = local.environment
+ cluster_name = "${local.region}-${local.environment}"
+
+ node_name = "nfsserver"
+ image = "ubuntu-18.04"
+ flavor = "m1.xlarge"
+ floating_ip_pool = "external"
+ # Read as File stream
+ user_data = file("nfs-server.sh")
+ node_count = 1
+}
diff --git a/terragrunt/openlab/RegionOne/stage/compute/worker/terragrunt.hcl b/terragrunt/openlab/RegionOne/stage/compute/worker/terragrunt.hcl
new file mode 100644
index 0000000..8d33ae4
--- /dev/null
+++ b/terragrunt/openlab/RegionOne/stage/compute/worker/terragrunt.hcl
@@ -0,0 +1,35 @@
+locals {
+ # Automatically load account-level variables
+ region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+ env_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+
+ region = local.region_vars.locals.region
+ environment = local.env_vars.locals.environment
+ network = local.env_vars.locals.network
+}
+
+terraform {
+ source = "git::https://gerrit.onap.org/r/integration/terraform/openlab/modules/openstack/compute"
+}
+
+include {
+ path = find_in_parent_folders()
+}
+
+dependencies {
+ paths = ["../../keypair", "../../network", "../../securitygroup"]
+}
+
+inputs = {
+
+ environment = local.environment
+ cluster_name = "${local.region}-${local.environment}"
+
+ node_name = "worker-node"
+ image = "ubuntu-18.04"
+ flavor = "m1.xlarge"
+ floating_ip_pool = "external"
+ # Read as File stream
+ user_data = file("worker-node.sh")
+ node_count = 3
+}
diff --git a/terragrunt/openlab/RegionOne/stage/compute/worker/worker-node.sh b/terragrunt/openlab/RegionOne/stage/compute/worker/worker-node.sh
new file mode 100644
index 0000000..4c0d52a
--- /dev/null
+++ b/terragrunt/openlab/RegionOne/stage/compute/worker/worker-node.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+DOCKER_VERSION=18.09.5
+
+export DEBIAN_FRONTEND=noninteractive
+
+apt-get update
+
+curl https://releases.rancher.com/install-docker/$DOCKER_VERSION.sh | sh
+mkdir -p /etc/systemd/system/docker.service.d/
+cat > /etc/systemd/system/docker.service.d/docker.conf << EOF
+[Service]
+ExecStart=
+ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry=nexus3.onap.org:10001
+EOF
+
+sudo usermod -aG docker ubuntu
+
+systemctl daemon-reload
+systemctl restart docker
+apt-mark hold docker-ce
+
+IP_ADDR=`ip address |grep ens|grep inet|awk '{print $2}'| awk -F / '{print $1}'`
+HOSTNAME=`hostname`
+
+echo "$IP_ADDR $HOSTNAME" >> /etc/hosts
+
+docker login -u docker -p docker nexus3.onap.org:10001
+
+sudo apt-get install make -y
+
+# install nfs
+sudo apt-get install nfs-common -y
+
+
+exit 0 \ No newline at end of file
diff --git a/terragrunt/openlab/RegionOne/stage/env.hcl b/terragrunt/openlab/RegionOne/stage/env.hcl
new file mode 100644
index 0000000..b3208c8
--- /dev/null
+++ b/terragrunt/openlab/RegionOne/stage/env.hcl
@@ -0,0 +1,22 @@
+# Set common variables for the environment. This is automatically pulled in in the root terragrunt.hcl configuration to
+# feed forward to the child modules.
+locals {
+ environment = "" # name of the environment you use. e.g stage, prod or qa
+ network = "" # name of the network to connect with the Internet
+
+ # Rancher and Kubernetes
+ # To access a VM, 'ssh -i ssh_private_key_path kubernetes_user@one-of-the-external-ips'
+ # a key pair for accessing VMs
+ ssh_public_key = "" # OpenSSH formated string is required
+ ssh_private_key_path = "" # e.g ~/.ssh/id_rsa
+
+ kubernetes_version = "v1.15.11-rancher1-2"
+ kubernetes_user = "ubuntu"
+ kubernetes_cluster_name = "rke_cluster"
+
+ kubernetes_home = "${get_parent_terragrunt_dir()}"
+
+ # Helm
+ service_account = "tiller"
+ namespace = "kube-system"
+} \ No newline at end of file
diff --git a/terragrunt/openlab/RegionOne/stage/keypair/terragrunt.hcl b/terragrunt/openlab/RegionOne/stage/keypair/terragrunt.hcl
new file mode 100644
index 0000000..35e02ee
--- /dev/null
+++ b/terragrunt/openlab/RegionOne/stage/keypair/terragrunt.hcl
@@ -0,0 +1,22 @@
+locals {
+ # Automatically load account-level variables
+ region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+ env_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+
+ region = local.region_vars.locals.region
+ environment = local.env_vars.locals.environment
+ ssh_public_key = local.env_vars.locals.ssh_public_key
+}
+
+terraform {
+ source = "git::https://gerrit.onap.org/r/integration/terraform/openlab/modules/openstack/keypair"
+}
+
+include {
+ path = find_in_parent_folders()
+}
+
+inputs = {
+ cluster_name = "${local.region}-${local.environment}"
+ ssh_public_key = local.ssh_public_key
+}
diff --git a/terragrunt/openlab/RegionOne/stage/kubernetes/terragrunt.hcl b/terragrunt/openlab/RegionOne/stage/kubernetes/terragrunt.hcl
new file mode 100644
index 0000000..e6c0abb
--- /dev/null
+++ b/terragrunt/openlab/RegionOne/stage/kubernetes/terragrunt.hcl
@@ -0,0 +1,47 @@
+locals {
+ # Automatically load account-level variables
+ account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
+ region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+ env_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+
+ backend = local.account_vars.locals.backend
+ backend_state = local.account_vars.locals.backend_state
+ region = local.region_vars.locals.region
+ environment = local.env_vars.locals.environment
+ ssh_private_key_path = local.env_vars.locals.ssh_private_key_path
+
+ kubernetes_user = local.env_vars.locals.kubernetes_user
+ kubernetes_cluster_name = local.env_vars.locals.kubernetes_cluster_name
+ kubernetes_home = local.env_vars.locals.kubernetes_home
+
+ # Helm
+ service_account = local.env_vars.locals.service_account
+ namespace = local.env_vars.locals.namespace
+}
+
+terraform {
+ source = "git::https://gerrit.onap.org/r/integration/terraform/openlab/modules/kubernetes/kubernetes"
+}
+
+include {
+ path = find_in_parent_folders()
+}
+
+dependencies {
+ paths = ["../rancher"]
+}
+
+inputs = {
+ backend = local.backend
+ backend_state = local.backend_state
+ region = local.region
+ environment = local.environment
+ ssh_private_key_path = local.ssh_private_key_path
+
+ kubernetes_user = local.kubernetes_user
+ kubernetes_cluster_name = local.kubernetes_cluster_name
+ kubernetes_home = local.kubernetes_home
+
+ service_account = local.service_account
+ namespace = local.namespace
+} \ No newline at end of file
diff --git a/terragrunt/openlab/RegionOne/stage/network/terragrunt.hcl b/terragrunt/openlab/RegionOne/stage/network/terragrunt.hcl
new file mode 100644
index 0000000..31ff4f7
--- /dev/null
+++ b/terragrunt/openlab/RegionOne/stage/network/terragrunt.hcl
@@ -0,0 +1,22 @@
+locals {
+ # Automatically load account-level variables
+ region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+ env_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+
+ region = local.region_vars.locals.region
+ environment = local.env_vars.locals.environment
+ network = local.env_vars.locals.network
+}
+
+terraform {
+ source = "git::https://gerrit.onap.org/r/integration/terraform/openlab/modules/openstack/network"
+}
+
+include {
+ path = find_in_parent_folders()
+}
+
+inputs = {
+ cluster_name = "${local.region}-${local.environment}"
+ network = local.network
+}
diff --git a/terragrunt/openlab/RegionOne/stage/rancher/terragrunt.hcl b/terragrunt/openlab/RegionOne/stage/rancher/terragrunt.hcl
new file mode 100644
index 0000000..1d01e11
--- /dev/null
+++ b/terragrunt/openlab/RegionOne/stage/rancher/terragrunt.hcl
@@ -0,0 +1,42 @@
+locals {
+ # Automatically load account-level variables
+ account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
+ region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+ env_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+
+ backend = local.account_vars.locals.backend
+ backend_state = local.account_vars.locals.backend_state
+ region = local.region_vars.locals.region
+ environment = local.env_vars.locals.environment
+ ssh_private_key_path = local.env_vars.locals.ssh_private_key_path
+
+ kubernetes_version = local.env_vars.locals.kubernetes_version
+ kubernetes_user = local.env_vars.locals.kubernetes_user
+ kubernetes_cluster_name = local.env_vars.locals.kubernetes_cluster_name
+ kubernetes_home = local.env_vars.locals.kubernetes_home
+
+}
+
+terraform {
+ source = "git::https://gerrit.onap.org/r/integration/terraform/openlab/modules/kubernetes/rancher"
+}
+
+include {
+ path = find_in_parent_folders()
+}
+
+dependencies {
+ paths = ["../compute/control"]
+}
+
+inputs = {
+ backend = local.backend
+ backend_state = local.backend_state
+ region = local.region
+ environment = local.environment
+ ssh_private_key_path = local.ssh_private_key_path
+ kubernetes_version = local.kubernetes_version
+ kubernetes_user = local.kubernetes_user
+ kubernetes_cluster_name = local.kubernetes_cluster_name
+ kubernetes_home = local.kubernetes_home
+} \ No newline at end of file
diff --git a/terragrunt/openlab/RegionOne/stage/securitygroup/terragrunt.hcl b/terragrunt/openlab/RegionOne/stage/securitygroup/terragrunt.hcl
new file mode 100644
index 0000000..3ebbb09
--- /dev/null
+++ b/terragrunt/openlab/RegionOne/stage/securitygroup/terragrunt.hcl
@@ -0,0 +1,20 @@
+locals {
+ # Automatically load account-level variables
+ region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+ env_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+
+ region = local.region_vars.locals.region
+ environment = local.env_vars.locals.environment
+}
+
+terraform {
+ source = "git::https://gerrit.onap.org/r/integration/terraform//openlab/modules/openstack/securitygroup"
+}
+
+include {
+ path = find_in_parent_folders()
+}
+
+inputs = {
+ cluster_name = "${local.region}-${local.environment}"
+}
diff --git a/terragrunt/openlab/account.hcl b/terragrunt/openlab/account.hcl
new file mode 100644
index 0000000..19d1b8c
--- /dev/null
+++ b/terragrunt/openlab/account.hcl
@@ -0,0 +1,11 @@
+# Set account-wide variables. These are automatically pulled in to configure the remote state bucket in the root
+# terragrunt.hcl configuration.
+# For Openstack, please fill in the values below
+locals {
+ user_name = "${get_env("user_name", "")}" # Expose environmental variables for your account
+ password = "${get_env("password", "")}"
+ project_id = "${get_env("project_id", "")}"
+ auth_url = "${get_env("auth_url","")}"
+ backend = "" # Remote state backend. gcs for google or s3 for Amazon
+ backend_state = "" # GCP storage bucket or AWS S3
+}
diff --git a/terragrunt/openlab/terragrunt.hcl b/terragrunt/openlab/terragrunt.hcl
new file mode 100644
index 0000000..7c55ea3
--- /dev/null
+++ b/terragrunt/openlab/terragrunt.hcl
@@ -0,0 +1,64 @@
+locals {
+ # Automatically load account-level variables
+ account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
+
+ # Automatically load region-level variables
+ region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
+
+ # Automatically load environment-level variables
+ environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
+
+ # Extract the variables we need for easy access
+ user_name = local.account_vars.locals.user_name
+ password = local.account_vars.locals.password
+ auth_url = local.account_vars.locals.auth_url
+ project_id = local.account_vars.locals.project_id
+ backend = local.account_vars.locals.backend
+ backend_state = local.account_vars.locals.backend_state
+ region = local.region_vars.locals.region
+ environment = local.environment_vars.locals.environment
+}
+
+remote_state {
+ backend = local.backend
+
+ generate = {
+ path = "backend.tf"
+ if_exists = "overwrite_terragrunt"
+ }
+
+ config = {
+ bucket = "${local.backend_state}"
+ prefix = "${path_relative_to_include()}/terraform.tfstate"
+ }
+}
+
+# test/terragrunt.hcl
+generate "provider" {
+ path = "provider.tf"
+ if_exists = "overwrite_terragrunt"
+ contents = <<EOF
+provider "openstack" {
+ user_name = "${local.user_name}"
+ tenant_name = "${local.user_name}"
+ password = "${local.password}"
+ auth_url = "${local.auth_url}"
+ tenant_id = "${local.project_id}"
+ region = "${local.region}"
+}
+EOF
+}
+
+# ---------------------------------------------------------------------------------------------------------------------
+# GLOBAL PARAMETERS
+# These variables apply to all configurations in this subfolder. These are automatically merged into the child
+# `terragrunt.hcl` config via the include block.
+# ---------------------------------------------------------------------------------------------------------------------
+
+# Configure root level variables that all resources can inherit. This is especially helpful with multi-account configs
+# where terraform_remote_state data sources are placed directly into the modules.
+inputs = merge(
+local.account_vars.locals,
+local.region_vars.locals,
+local.environment_vars.locals,
+)