I Tested an AI That Deploys and Verifies Nginx on Real VMs
Source: Dev.to
Infrastructure Automation – Beyond Code Generation
Infrastructure automation is a core part of the DevOps role. However, most AI‑based tools still stop at one stage: code generation. Execution, monitoring, and validation are often left to the engineer.
I tested an AI‑driven DevOps solution that takes a different approach: it generates a script, executes it on a real virtual machine, and automatically verifies the result. This article shares a hands‑on experience based on a concrete and realistic scenario.
The Scenario I Tested
The test focuses on a common system‑administration / DevOps task:
- Setting up Nginx with Basic Authentication on Ubuntu using a Bash script.
- Installing Nginx.
- Creating users with
htpasswd. - Protecting a specific path with basic authentication.
- Testing access with and without credentials.
- Verifying that unauthorized requests return HTTP 401.
Even though this setup looks simple, it involves multiple layers: system configuration, security, services, and validation.
Execution Triggered by a Prompt
The entire workflow is launched with a single natural‑language prompt. Once the prompt is submitted, the tool automatically:
- Starts a real Ubuntu VM.
- Generates a Bash script tailored to the scenario.
- Executes the script on the VM.
- Provides a Grafana link to visualize the execution in real time.
The Grafana dashboard shows each phase: VM startup, script generation, execution, and final validation.
Execution Visibility & Metrics
The dashboard gives clear visibility into how the scenario runs. It lets you track:
| Metric | Observed Value |
|---|---|
| VM startup time | /dev/null 2>&1; do |
| sleep 2 | |
| done |
1. Update package cache
echo -e “\nStep 1: Updating package cache…” sudo apt-get update echo ”✓ Package cache updated”
2. Install nginx package
echo -e “\nStep 2: Installing Nginx…” sudo apt-get install -y nginx echo ”✓ Nginx installed”
3. Install apache2-utils package (provides htpasswd)
echo -e “\nStep 3: Installing apache2-utils…” sudo apt-get install -y apache2-utils echo ”✓ apache2-utils installed”
4. Start and enable nginx service
echo -e “\nStep 4: Starting Nginx service…” sudo systemctl start nginx sudo systemctl enable nginx echo ”✓ Nginx service started and enabled”
5. Create protected directory
echo -e “\nStep 5: Creating protected directory…” sudo mkdir -p /var/www/html/protected echo ”✓ Protected directory created”
6. Create index.html in protected directory
echo -e “\nStep 6: Creating index.html in protected directory…” sudo tee /var/www/html/protected/index.html > /dev/null
Protected Content
Welcome to Protected Area
This content is protected by basic authentication.
If you can see this, you have successfully authenticated.
EOF echo ”✓ index.html created”
7. Create htpasswd file with test user
echo -e “\nStep 7: Creating htpasswd file…” sudo htpasswd -bc /etc/nginx/.htpasswd testuser testpass123 echo ”✓ htpasswd file created with testuser:testpass123”
8. Configure nginx with basic authentication
echo -e “\nStep 8: Configuring Nginx with basic authentication…” sudo tee /etc/nginx/sites-available/default > /dev/null <<‘EOF’ server { listen 80 default_server; listen [::]:80 default_server;
server_name _;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ =404;
}
location /protected {
auth_basic "Restricted Area";
auth_basic_user_file /etc/nginx/.htpasswd;
}
} EOF echo ”✓ Nginx configuration updated”
9. Test nginx configuration syntax
echo -e “\nStep 9: Testing Nginx configuration syntax…” sudo nginx -t echo ”✓ Nginx configuration is valid”
10. Restart nginx service
echo -e “\nStep 10: Restarting Nginx service…” sudo systemctl restart nginx echo ”✓ Nginx service restarted”
-------------------------------------------------
Verification
-------------------------------------------------
echo -e “\n==========================================” echo “Verification Tests” echo ”==========================================“
Wait for nginx to be ready
sleep 2
Test 1: Access without credentials (should return 401)
echo -e “\nTest 1: Accessing /protected without credentials…” HTTP_CODE=$(curl -s -o /dev/null -w ”%{http_code}” http://localhost/protected/) if [ “$HTTP_CODE” = “401” ]; then echo ”✓ Got HTTP 401 (Unauthorized) – correct behavior” else echo ”✗ Expected HTTP 401, got HTTP $HTTP_CODE” exit 1 fi
Test 2: Access with valid credentials (should return 200)
echo -e “\nTest 2: Accessing /protected with valid credentials…” HTTP_CODE=$(curl -s -o /dev/null -w ”%{http_code}” -u testuser:testpass123 http://localhost/protected/) if [ “$HTTP_CODE” = “200” ]; then echo ”✓ Got HTTP 200 (OK) – authentication successful” else echo ”✗ Expected HTTP 200, got HTTP $HTTP_CODE” exit 1 fi
Test 3: Retrieve protected content with valid credentials
echo -e “\nTest 3: Retrieving protected content with valid credentials…” curl -s -u testuser:testpass123 http://localhost/protected/ | head -n 10 echo -e “\n✓ Content retrieved successfully”
echo -e “\nAll verification steps passed.”
---
### Takeaways
- **End‑to‑end automation**: The AI‑driven tool handled VM provisioning, script generation, execution, monitoring, and validation without manual intervention.
- **Rapid feedback**: With a total runtime of ~ 23 seconds, engineers can iterate quickly on infrastructure changes.
- **Observability**: Real‑time Grafana dashboards make it easy to spot bottlenecks (e.g., VM startup vs. script execution).
- **Reliability**: Automatic verification ensures the desired state is achieved before the workflow is marked as successful.
This approach demonstrates how moving beyond pure code generation can bring true **infrastructure‑as‑code** pipelines closer to a “push‑button” experience.
## Test Script Output
```bash
# Retrieve protected page
echo "---"
curl -s -u testuser:testpass123 http://localhost/protected/index.html
echo ""
echo "---"
echo ""
echo "=========================================="
echo "✓ All tests passed!"
echo "=========================================="
echo ""
echo "Summary:"
echo "- Nginx installed and running"
echo "- Basic authentication configured"
echo "- Protected directory: /var/www/html/protected"
echo "- Credentials: testuser / testpass123"
echo "- Test with: curl -u testuser:testpass123 http://localhost/protected/"
What This Changes for DevOps Work
This approach reshapes how automation tasks are handled.
- Instead of spending time writing scripts, fixing errors, rerunning commands, and manually testing each step, DevOps engineers can focus directly on the final outcome.
- The real behavior of the infrastructure becomes the central concern: does the service work as expected, is security correctly applied, and does the result match the requirements?
This workflow is especially effective for use cases such as:
- Proofs of concept
- Test environments
- Technical demonstrations
- Learning scenarios
In these contexts, the time savings are tangible, and the value lies in validation rather than script authoring.
Final Thoughts
- This test shows that AI can now go beyond simple script generation and deliver functional, observable, and verified infrastructure.
- For DevOps teams, this opens the door to a new way of working, where the focus shifts from automation mechanics to rapid validation of real infrastructure outcomes.
Check it out at antrieb.sh.
Discord: @antrieb‑sh.