Terraform and Ansible code to deploy and configure CockroachDB on vSphere 7.0 or above.
Terraform and Ansible projects to set up Cockroach DB environment and monitoring tools.
This is the linux system used to invoke Terraform and Ansible in order to create the test environment.
Install requirements.
sudo yum -y install python3 python3-pip git wget unzip
Install Terraform according to the instructions here
# Download terraform package # Note. The scripts are using features only available in version 0.13+ wget https://releases.hashicorp.com/terraform/0.13.2/terraform_0.13.2_linux_amd64.zip # Extract unzip terraform_*_linux_amd64.zip # Install sudo mv ./terraform /usr/bin/ # Remove zip file rm terraform_*_linux_amd64.zip
Clone git repository
# Change to home directory cd ~ # Clone git repository git clone https://github.com/cleeistaken/automation-cockroach.git # Change into git repository cd automation-cockroach
Create a Python virtual environment.
# Create virtual environment python3 -m venv $HOME/.python3-venv # Activate the virtual environment source $HOME/.python3-venv/bin/activate # (optional) Add VENV to login script echo "source $HOME/.python3-venv/bin/activate" >> $HOME/.bashrc
Install required python packages.
pip install --upgrade pip pip install --upgrade setuptools pip install -r python-requirements.txt
We create a template to address the following requirements and limitations.
Install the required packages for the Terraform customization.
sudo yum install open-vm-tools perl
From the orchestration system create and upload a ssh key to the template VM.
# Check and create a key if none exits if [ ! -f ~/.ssh/id_rsa ]; then ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N "" fi # Copy to the template VM ssh-copy-id root@<ip of the vm>
In vSphere convert the VM to a template to prevent any changes.
Initialize Terraform
# Change to Terraform folder cd ~/workload-automation/cockroach/terraform/ # Initialize terraform init
Configure environment settings
vi terraform.tfvars
Deploy Cockroach environment
terraform apply
Check and configure settings
cd ~/automation-cockroach/ansible/ vi settings.yml vi ansible.cfg
Deploy Cockroach DB
ansible-playbook -i settings.yml -i hosts.yml deploy.yml
Run tests
# YCSB test ansible-playbook -i settings.yml -i hosts.yml ycsb-init.yml ansible-playbook -i settings.yml -i hosts.yml ycsb-run.yml # TPCC test ansible-playbook -i settings.yml -i hosts.yml tpcc-init.yml ansible-playbook -i settings.yml -i hosts.yml tpcc-run.yml