This document outlines the process for creating a developer virtual machine (VM), installing the necessary tech stack, configuring the environment, and preparing the VM for deployment. The guide is tailored for the creation of a Dev Template VM
with specific configurations and is applicable to the Elitical
project.
To create the Dev Template VM, use the following command:
sudo virt-install \
--name elitical-dev-tmpl \
--os-variant ubuntu22.04 \
--vcpus 2 \
--memory 6144 \
--location /data1/os-iso/ubuntu-22.04.4-live-server-amd64.iso,kernel=casper/vmlinuz,initrd=casper/initrd \
--network bridge=virbr20,model=virtio,mac=0a:01:e9:20:de:03 \
--network network=virho10,model=virtio,mac=0a:01:e9:10:de:03 \
--disk size=30,pool=adm-images \
--uuid=00000000-0000-0000-0000-0a01e920de03 \
--graphics none \
--extra-args='console=ttyS0' \
--debug
<project> Developer Server
eev-in-dev1a-node01
, elitical-dev1a-node01
devopsadmin
1!Devops@dmin
visudo
to add the following line at the end of the file:
devopsadmin ALL=(ALL) NOPASSWD: ALL
Once the VM is created, clone the Devops Automation scripts
repository into the VM.
Navigate to the cloned directory and run the following command to install the tech stack:
python3 TechStackInstallation.py <project_name> java maven haproxy tomcat git scylla redpanda mysql
python3 TechStackInstallation.py eliticalDev java maven haproxy tomcat git scylla redpanda mysql
Devops Automation scripts
folder which provides the necessary inputs for the TechStackInstallation.py
script.The directory also contains configuration and database files. Any modifications required should be updated in this directory, which will reflect in the installation and configuration.
To configure the installed tech stack, run the following command:
python3 ConfigureScript.py <projectname> configuration
python3 ConfigureScript.py eliticalDev configuration
Load the base data into the VM by running:
python3 ConfigureScript.py <projectname> databases.conf
python3 ConfigureScript.py eliticalDev databases.conf
Check that all services are running correctly by using:
systemctl status <service_name>
Ensure that services that need to be disabled.
To ensure that all necessary services start sequentially on system startup, create a custom service by adding the following configuration:
Create a service unit file at /etc/systemd/system/start-services.service
with the following content:
[Unit]
Description=Start services sequentially on system startup
After=network.target
[Service]
Type=oneshot
ExecStart=/bin/bash /home/devopsadmin/.scripts/start-services.sh
User=devopsadmin
Group=devopsadmin
[Install]
WantedBy=multi-user.target
Create the script /home/devopsadmin/.scripts/start-services.sh
with the following content:
#!/bin/bash
service_running() {
systemctl is-active "$1" >/dev/null 2>&1
}
SERVICES=("apache2" "scylla-jmx" "scylla-server" "redpanda" "mysql@bootstrap" "tomcat-elitical" "haproxy")
for service in "${SERVICES[@]}"; do
echo "Starting $service..."
sudo systemctl start "$service"
while true; do
if service_running "$service"; then
echo "$service started successfully."
break
else
echo "$service failed to start. Retrying in 10 seconds..."
sleep 10
fi
done
done
echo "All services started successfully."
Enable the service to ensure it runs on system startup:
sudo systemctl enable start-services.service
Verify the service by rebooting the VM or manually starting the service:
sudo systemctl start start-services.service
To harden the VM, navigate to the Hardening
directory and run:
cd Hardening
bash ubuntu.sh
bash checkScore.sh
39195
.devbox
user was created with the password Dev$@YukthbOx
and added to the sudoers
group.
sudo adduser devbox
y
to confirm the information and complete the settings for the new user.usermod
command:
sudo usermod -aG sudo devbox
After the VM is created and hardened, Jenkins pipeline scripts are utilized to automate the deployment process of the project. This involves:
Project Deployment: A Jenkins pipeline script is responsible for deploying the project, ensuring that the application is built, tested, and deployed consistently and successfully.
Database Reset: An additional Jenkins pipeline script handles the resetting of the database, maintaining a clean and consistent state for development and testing purposes.
These pipeline scripts streamline the deployment workflow, reduce manual intervention, and enhance the reliability and efficiency of the deployment process.
After the successful execution of the Jenkins pipeline, verify that the website is properly deployed:
http://{vm_ip}
to check if the web application is accessible.http://{vm_ip}/apu/home
to check if the web server is working correctly.If any issues are encountered, check the following configuration files:
/etc/haproxy/haproxy.cfg
/etc/apache2/apache2.conf
Once all the steps are completed and verified, the dev template VM is ready for cloning. This template can now be used to create additional developer VMs as needed.