[ Part 1 ] Preparing the environment

Steps to be implemented:

  • Start the Cloud-Shell

  • Generate ssh keys

  • Clone the MdsReplication repository

  • Add the corresponding variables to file variables.tf

[ 1 ] Start the Cloud-Shell

Next to your region, in the upper right corner, there is a square that indicates a terminal (as marked with orange).

Click on it, and wait for a couple of minutes until the Cloud-Shell is prepared.

[ 2 ] Generate SSH keys

Generate the default files of ssh keys (~/.ssh/id_rsa and ~/.ssh/id_rsa.pub) under user's home directory with the help of command:

zack@cloudshell:~ (eu-frankfurt-1)$  ssh-keygen

Choose the default option, by pressing Enter to each requirement.

Practice example:

zack@cloudshell:~ (eu-frankfurt-1)$ pwd 
/home/zack
zack@cloudshell:ExampleMySqlDbAndInstance (eu-frankfurt-1)$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/zack/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/zack/.ssh/id_rsa
Your public key has been saved in home/zack/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:
The key's randomart image is:
+---[RSA 3072]----+
|..oo..o o. .o    |
|oo o.  + ..o.E   |
|* . .   .o..  .  |
|o. . . . .o .    |
|. o o o S  .     |
|   o = . .       |
|  o . = . .      |
|.=.+o+.. o o .   |
|.+Oo.+o.. . o    |
+----[SHA256]-----+

Check if the ssh keys have been generated under your home directory:

zack@cloudshell:~ (eu-frankfurt-1)$ ls ~/.ssh/id_*
/home/zack/.ssh/id_rsa  /home/zack/.ssh/id_rsa.pub

[ 3 ] Clone the Github repository

Clone the Github repository with the usual "git clone" command:

git clone  https://github.com/isaac-kami/MdsReplication.git

Access the directory MdsReplication:

zack@cloudshell:~ (eu-frankfurt-1)$ cd MdsReplication/
zack@cloudshell:MdsReplication (eu-frankfurt-1)$ 

[ 4 ] Test the variables

At this step, you will need to run the script test_env_variables.sh , that will generate a set of variables as output.

Make it executable and run it (you will need to wait for about 40 seconds):

zack@cloudshell:~ (eu-frankfurt-1)$ chmod +x test_env_variables.sh
zack@cloudshell:~ (eu-frankfurt-1)$ ./test_env_variables.sh

You will need to be very careful with the instance_image variable. If you get an output as follow:

variable "instance_image" {
   default = ""
}

... then, check page Troubleshooting image OS

Your output should be something of this kind (output per Dubai region):

zack@cloudshell:~ (me-dubai-1)$ ./test_env_variables.sh 
### variables added with generate_variables.sh script

variable "compartment_ocid" {
     default = "ocid1.tenancy.oc1..aaaaaaaa2efnorqencqozgznvr4ifnull4rfe52jbotludfu64cc3p6lrfea"
}


variable "ssh_public_key_path" {
   default = "/home/artforward/.ssh/id_rsa.pub"
}


variable "ssh_private_key_path" {
   default = "/home/artforward/.ssh/id_rsa"
}


variable "bucket_namespace" {
   default = "axx705ls0mwn"
}


variable "mysql_db_system_availability_domain" {
   default = "gvJq:ME-DUBAI-1-AD-1"
}


variable "instance_image" {
   default = "ocid1.image.oc1.me-dubai-1.aaaaaaaakymk4j6nkwer37kw2gsrzsbhoosqnckz6hmsmdpzr42ie5hlitga"
}

[ 5 ] Add the corresponding variables to file variables.tf

This step is implemented with the help of Bash script generate_variables.sh

zack@cloudshell:MdsReplication (eu-frankfurt-1)$ ls generate_variables*
generate_variables.sh

Make the script executable, and run it:

MdsReplication (eu-frankfurt-1)$ chmod +x generate_variables.sh  
MdsReplication (eu-frankfurt-1)$ ./generate_variables.sh

You will have to wait for an average of 45 seconds until all variables are generated and appended to the variables.tf file

Check the "variables.tf", and following lines should be appended - the user is changed accordingly to your environment and profile.

Possible output (according to your user, AD & OS Ubuntu 20.04 version per your region)

zack@cloudshell:MdsReplication (eu-frankfurt-1)$ tail -32 variables.tf

### variables added with generate_variables.sh script

variable "compartment_ocid" {
     default = "ocid1.tenancy.oc1..some0cidHere"
}


variable "ssh_public_key_path" {
   default = "/home/zack/.ssh/id_rsa.pub"
}


variable "ssh_private_key_path" {
   default = "/home/zack/.ssh/id_rsa"
}


variable "bucket_namespace" {
   default = "s0medatah3re"
}

variable "mysql_db_system_availability_domain" {
   default = "Aodz:EU-FRANKFURT-1-AD-2"
}


variable "instance_image" {
   default = "ocid1.image.oc1.eu-frankfurt-1.aaaaaaaa2fbceq23oofnxf4v23urfnfzui6n6det6ianoyvtmsbo5nzv2efq"
}

Last updated