SETUP PROJECT 0

DevOps Workstation Setup

Establish the baseline virtualization sandbox running Ubuntu Server 22.04 LTS on VirtualBox to enable local development, SSH integrations, and file sharing.

Environment
VirtualBox / Local VM
Difficulty
Beginner
Course Module
Pre-requisites
Deliverables
VM Verification & SSH Proof
1. System Architecture & Workflow

This layout outlines how your physical Host computer interfaces with the virtual Linux Guest environment. All networking packets route through a NAT Adapter with port-forwarding mappings, and shared filesystem mounts bridge the OS storage scopes.

Windows/macOS Host OS VS Code / Terminal (SSH Client) ssh -p 2222 devops@127.0.0.1 Shared Work Folder C:\devops_share VirtualBox Hypervisor Ubuntu Server Guest VM SSH Service (Port 22) Hostname: devops-node Mount Path: /media/sf_devops_share Group: vboxsf Port Forward 2222 -> 22 Shared Mount
2. Part 1: Step-by-Step Action Items & Key Execution Steps
STEP 1

Install Host Software Packages

Prepare your host operating system environment with the primary local utilities required to download, configure, and connect to virtualized infrastructure.

Install the required software depending on your host operating system:

Option A: Windows Host (via native winget utility)

PS> winget install Oracle.VirtualBox PS> winget install Microsoft.VisualStudioCode PS> winget install Git.Git PS> winget install Postman.Postman PS> winget install 7zip.7zip
This command invokes the native Windows Package Manager (winget) to install VirtualBox, VS Code, Git, Postman, and 7-Zip directly on a fresh Windows system.

Option B: macOS Host (via Homebrew)

$ brew install --cask virtualbox visual-studio-code git postman 7-zip
This command uses the macOS Homebrew package manager to download and configure the virtualization hypervisor, source editor, VCS client, API tool, and file archiving software.

Option C: Manual Web Downloads

STEP 2

Provision the Ubuntu Server Virtual Machine

Download the Ubuntu Server ISO and initialize it inside the VirtualBox hypervisor console.

  1. Download the Ubuntu Server 22.04 LTS ISO from the official Ubuntu release portal.
  2. Open VirtualBox, click New, and configure:
    • Name: devops-node
    • Folder: Choose a path with plenty of space (minimum 20GB free)
    • ISO Image: Select the downloaded Ubuntu ISO
    • Memory: 2048 MB (2 GB)
    • Processors: 2 vCPUs
    • Virtual Disk: 25 GB Dynamically Allocated
  3. Go to VM Settings -> Network -> Adapter 1. Set to NAT, open Advanced, and click Port Forwarding. Add a rule:
    • Name: SSH, Protocol: TCP, Host Port: 2222, Guest Port: 22 (leave IPs blank).
  4. Enable Nested Virtualization (VT-x/AMD-V): With the VM powered off, open your physical host terminal (PowerShell/Command Prompt on Windows, Terminal on macOS) and execute:
    PS> VBoxManage modifyvm "devops-node" --nested-hw-virt on
    This command enables nested hardware virtualization in VirtualBox for the VM, allowing the Ubuntu Guest OS to run its own virtual containers (like Docker and Kubernetes) inside the guest kernel.
  5. Start the VM and follow the installer. Select default options, check Install OpenSSH Server, and complete installation. Reboot the VM.
STEP 3

Configure System Identity, Hostname, and Timezone

Log in directly inside the VirtualBox VM console and execute the configuration steps to set identity attributes.

$ sudo hostnamectl set-hostname devops-node
This command modifies the static system hostname inside the Linux system files, aligning the operating system identifier with the expected node classification in later configurations.
$ sudo timedatectl set-timezone UTC
This command updates the system timezone file links to point to Coordinated Universal Time, establishing a standard chronological reference frame across all servers, logging nodes, and databases.
$ sudo usermod -aG sudo $USER
This command appends the current user account record to the system administration sudo group, granting administrative credentials to execute commands requiring root permissions.
STEP 4

Install VirtualBox Guest Additions & Configure Shared Folders

To access files stored on your local physical machine, compile Guest Additions modules and configure a Shared folder path mapping.

$ sudo apt update && sudo apt install -y build-essential dkms linux-headers-$(uname -r)
This command retrieves updated software index files and installs compilation tooling and system headers corresponding to the running kernel version to permit the building of Guest Additions modules.

1. In the VirtualBox window menu, select Devices -> Insert Guest Additions CD Image.

$ sudo mount /dev/cdrom /media && sudo /media/VBoxLinuxAdditions.run
This command mounts the virtual Guest Additions ISO file to the local media directory and runs the installer script to build and link kernel drivers for guest-host resource sharing.

2. Shut down the VM. In VirtualBox VM settings, select Shared Folders. Click Add Shared Folder:

$ sudo usermod -aG vboxsf $USER
This command registers the current user account with the virtual folder vboxsf group, granting the user permission to read and write files within the shared host directory without requiring root credentials.
STEP 5

Validate Network Interfaces, Package Management, and SSH Connectivity

Test the host-to-guest ssh mapping and check access to the network.

$ ssh -p 2222 devops@127.0.0.1
This command, executed on your physical host terminal, initiates an SSH protocol session targeting the localhost IP address on mapped port 2222, validating the port forwarding rule bridging host and guest.
$ sudo apt update && sudo apt upgrade -y
This command fetches current package database files from remote software mirrors and installs security revisions and system patches, ensuring the environment is up to date.
3. Operational Pipeline Architecture

The system validation pipeline automates checking your VM configuration. The script inspects the running host interfaces, processes, filesystems, and writes a unified JSON validation report back to the shared folder.

1. OS Hostname Target: devops-node hostnamectl 2. Group Access Target: vboxsf, sudo groups $USER 3. Shared Dir Check mount paths df -h | grep sf_ 4. JSON Report Output to Share report.json
4. Part 2: Complete Deliverable Assets & Production Templates

To automate the verification of the guest workstation nodes, we will design a validation script. Follow the steps below to understand how the components are built up, and then combine them into a single executable script.

Step-by-Step Script Construction

Step 1

Define Shebang and Shell Script Safety Flags

Every script must declare its interpreter and configure immediate exit flags on errors to prevent syntax bugs from cascading silently.

#!/usr/bin/env bash set -euo pipefail
This declaration registers the bash shell environment as the execution driver, while -e exits immediately on any command errors, -u flags unset variable calls as bugs, and -o pipefail propagates pipeline exit codes.
Step 2

Declare Directory variables

Setup paths where files will be scanned and reports generated.

REPORT_DIR="/media/sf_devops_share" REPORT_FILE="${REPORT_DIR}/workstation_report.json"
This allocates the directory mount path and output file destination string inside shell memory.
Step 3

Audit Hostname and Group Memberships

Query variables using built-in system checks to verify hostname and credentials.

ACTUAL_HOSTNAME=$(hostname) USER_GROUPS=$(groups) [[ "${ACTUAL_HOSTNAME}" == "devops-node" ]] && HOSTNAME_STATUS="PASS" || HOSTNAME_STATUS="FAIL" [[ "${USER_GROUPS}" =~ "sudo" ]] && SUDO_STATUS="PASS" || SUDO_STATUS="FAIL" [[ "${USER_GROUPS}" =~ "vboxsf" ]] && VBOXSF_STATUS="PASS" || VBOXSF_STATUS="FAIL"
This code block reads the hostname value and checks group privileges, assigning PASS/FAIL status based on whether 'sudo' (admin privileges) and 'vboxsf' (shared folder permissions) are detected.
Step 4

Check Network Resolution and Folder Mounts

Audit internet gateways and confirm the presence of guest addition shared mounts.

curl -s --connect-timeout 3 https://www.google.com > /dev/null && NET_STATUS="PASS" || NET_STATUS="FAIL" mountpoint -q "/media/sf_devops_share" && MOUNT_STATUS="PASS" || MOUNT_STATUS="FAIL"
This code queries google.com with a connection timeout to verify internet connectivity, and uses mountpoint to check if the shared directory is mounted.
Step 5

Output Audit Results as JSON Reports

Write results in structured JSON format back to the shared folder path.

cat <<EOF > "${REPORT_FILE}" { "timestamp": "$(date -u +'%Y-%m-%dT%H:%M:%SZ')", "hostname": "${ACTUAL_HOSTNAME}", "audits": { "hostname_correct": "${HOSTNAME_STATUS}", "sudo_group_access": "${SUDO_STATUS}", "vboxsf_group_access": "${VBOXSF_STATUS}", "internet_resolved": "${NET_STATUS}", "shared_folder_mounted": "${MOUNT_STATUS}" } } EOF
This constructs a JSON file using HEREDOC input syntax, writing timestamps, hostname parameters, and status checks to the shared folder report file.

Combined Automated Script

Save the consolidated blocks above as /home/devops/validate_workstation.sh inside the VM, make it executable with chmod +x validate_workstation.sh, and run it:

#!/usr/bin/env bash # validate_workstation.sh - Workstation Configuration Validation Engine set -euo pipefail REPORT_DIR="/media/sf_devops_share" REPORT_FILE="${REPORT_DIR}/workstation_report.json" echo "Starting Workstation System Auditing..." ACTUAL_HOSTNAME=$(hostname) EXPECTED_HOSTNAME="devops-node" HOSTNAME_STATUS="FAIL" [[ "${ACTUAL_HOSTNAME}" == "${EXPECTED_HOSTNAME}" ]] && HOSTNAME_STATUS="PASS" USER_GROUPS=$(groups) SUDO_STATUS="FAIL" [[ "${USER_GROUPS}" =~ "sudo" ]] && SUDO_STATUS="PASS" VBOXSF_STATUS="FAIL" [[ "${USER_GROUPS}" =~ "vboxsf" ]] && VBOXSF_STATUS="PASS" NET_STATUS="FAIL" if curl -s --connect-timeout 3 https://www.google.com > /dev/null; then NET_STATUS="PASS" fi MOUNT_STATUS="FAIL" if mountpoint -q "/media/sf_devops_share"; then MOUNT_STATUS="PASS" fi if [ -d "${REPORT_DIR}" ]; then cat <<EOF > "${REPORT_FILE}" { "timestamp": "$(date -u +'%Y-%m-%dT%H:%M:%SZ')", "hostname": "${ACTUAL_HOSTNAME}", "audits": { "hostname_correct": "${HOSTNAME_STATUS}", "sudo_group_access": "${SUDO_STATUS}", "vboxsf_group_access": "${VBOXSF_STATUS}", "internet_resolved": "${NET_STATUS}", "shared_folder_mounted": "${MOUNT_STATUS}" } } EOF echo "Success: Report generated at ${REPORT_FILE}" else echo "Warning: Shared directory ${REPORT_DIR} not detected. Outputting to stdout:" cat <<EOF { "hostname": "${ACTUAL_HOSTNAME}", "audits": { "hostname_correct": "${HOSTNAME_STATUS}", "sudo_group_access": "${SUDO_STATUS}", "vboxsf_group_access": "${VBOXSF_STATUS}", "internet_resolved": "${NET_STATUS}" } } EOF fi
5. Deliverables Summary

Review the components that must be created or compiled to successfully complete this setup project.

Created Files / Templates

  • /home/devops/validate_workstation.sh - System configuration validator bash script.
  • C:\devops_share\workstation_report.json - Generated execution report mapping system test statuses.

Verification Artifacts / Execution Proof

  • Screenshot of the VirtualBox terminal console showing system hostname set to devops-node.
  • Screenshot of successful SSH connection from the local physical host terminal client targeting port 2222.
  • Presence of the validation JSON output showing a "PASS" status across all audits.
6. Closing Explanation: Why We Did This & What It Accomplishes

Architectural Intent & Operational Impact

Why We Did This

What This Accomplishes