Skip to content

feat: on-demand Azure VM lifecycle with start/stop workflows#142

Merged
jschoedl merged 3 commits into
mainfrom
feat/azure-vm-lifecycle
Jul 19, 2026
Merged

feat: on-demand Azure VM lifecycle with start/stop workflows#142
jschoedl merged 3 commits into
mainfrom
feat/azure-vm-lifecycle

Conversation

@jschoedl

@jschoedl jschoedl commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

On-demand Azure VM lifecycle. The VM has no reserved public IP; Start/Stop GitHub Actions workflows (OIDC auth) create/delete the IP and arm an auto-shutdown timer, so idle cost is disk-only. All services now use restart: unless-stopped so the stack recovers on boot, and the deploy workflow resolves the dynamic IP at runtime.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Infrastructure / CI
  • Documentation

API changes

  • This PR does not affect the API
  • This PR changes the API → api/openapi.yaml updated and api/scripts/gen-all.sh re-run

Definition of Done

  • CI passes
  • Pre-commit hooks pass locally
  • Relevant tests added or updated

Summary by CodeRabbit

  • New Features

    • Added workflows to manually start and stop the Azure-hosted environment.
    • Starting the environment assigns a public IP, provides the VM URL, and schedules automatic shutdown.
    • Deployment now discovers the VM’s current public IP automatically.
  • Bug Fixes

    • Services now restart automatically unless explicitly stopped.
  • Infrastructure

    • Updated deployment location and improved dynamic network configuration.

Provision a VM with no reserved public IP; start/stop GitHub Actions
workflows (OIDC auth) create/delete the IP and arm an auto-shutdown timer
so idle cost is disk-only. Services now restart: unless-stopped so the
stack recovers on boot; deploy resolves the dynamic IP at runtime.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jschoedl, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4206f524-8218-4323-89a4-51940ec1b114

📥 Commits

Reviewing files that changed from the base of the PR and between fe64fec and 30b1a7d.

📒 Files selected for processing (2)
  • .github/workflows/vm-start.yml
  • README.md
📝 Walkthrough

Walkthrough

The PR adds manual Azure VM start and stop workflows, moves public IP management into runtime workflows, resolves the VM IP for Ansible deployment, updates Terraform networking, and adds restart policies to core Compose services.

Changes

Azure VM operations

Layer / File(s) Summary
Terraform networking baseline
infra/main.tf
Moves the resource group to spaincentral, removes the Terraform-managed public IP and output, and ignores externally managed NIC public IP changes.
VM start and stop workflows
.github/workflows/vm-start.yml, .github/workflows/vm-stop.yml
Adds manual Azure OIDC workflows that attach or remove the public IP, start or deallocate the VM, configure auto-shutdown, and publish status summaries.
Dynamic Ansible connectivity
.github/workflows/deploy-ansible.yml, infra/inventory.ini
Resolves the VM public IP at runtime, uses it for SSH host scanning, and generates the Ansible inventory with runtime connection settings.
Container restart policies
infra/docker-compose.yml
Adds restart: unless-stopped to five services.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GitHubActions
  participant AzureLogin
  participant AzureCLI
  participant PublicIP
  participant AzureVM
  GitHubActions->>AzureLogin: Authenticate with OIDC
  GitHubActions->>AzureCLI: Ensure and attach public IP
  AzureCLI->>PublicIP: Create or update public IP
  AzureCLI->>AzureVM: Start VM
  AzureCLI->>AzureVM: Configure auto-shutdown
  AzureCLI-->>GitHubActions: Return public IP and shutdown time
Loading

Possibly related PRs

Suggested reviewers: paulwiese, imol-ai

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding on-demand Azure VM lifecycle start/stop workflows.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/azure-vm-lifecycle

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/deploy-ansible.yml (1)

67-80: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the redundant ssh-keyscan step.

The ssh-keyscan command is unnecessary here because the generated Ansible inventory explicitly disables strict host key checking (-o StrictHostKeyChecking=no). Ansible will automatically accept the host key when it connects.

Furthermore, because this workflow runs shortly after the VM starts, the SSH service might not be fully ready yet. If ssh-keyscan runs before SSH is up, it will silently fail to gather the key anyway. Relying on Ansible's connection step (which can retry) alongside StrictHostKeyChecking=no is more robust for ephemeral IPs.

♻️ Proposed refactor
-      - name: Scan VM Host Key
-        run: ssh-keyscan -H "$VM_IP" >> ~/.ssh/known_hosts
-
       - name: Write inventory with the resolved IP
         run: |
           cat > infra/inventory.ini <<EOF
           [web]
           $VM_IP
 
           [all:vars]
           ansible_user=azureuser
           ansible_ssh_private_key_file=~/.ssh/id_rsa
           ansible_ssh_common_args='-o StrictHostKeyChecking=no'
           ansible_python_interpreter=/usr/bin/python3.10
           EOF
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/deploy-ansible.yml around lines 67 - 80, Remove the
ssh-keyscan step preceding “Write inventory with the resolved IP” in the
workflow, leaving the inventory’s StrictHostKeyChecking=no configuration and
Ansible connection flow unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/vm-start.yml:
- Around line 61-68: The vm-start workflow directly interpolates the
user-controlled hours input into shell scripts, enabling command injection. In
.github/workflows/vm-start.yml lines 61-68, add an HOURS environment variable to
the “Arm auto-shutdown timer” step and use $HOURS in the date command; apply the
same environment binding and shell-variable substitution in lines 70-83 for the
other affected step.

---

Nitpick comments:
In @.github/workflows/deploy-ansible.yml:
- Around line 67-80: Remove the ssh-keyscan step preceding “Write inventory with
the resolved IP” in the workflow, leaving the inventory’s
StrictHostKeyChecking=no configuration and Ansible connection flow unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8e6f7c2c-d0de-475e-a183-c3f428a5f3fd

📥 Commits

Reviewing files that changed from the base of the PR and between e519d82 and fe64fec.

⛔ Files ignored due to path filters (1)
  • infra/id_rsa.pub is excluded by !**/*.pub
📒 Files selected for processing (6)
  • .github/workflows/deploy-ansible.yml
  • .github/workflows/vm-start.yml
  • .github/workflows/vm-stop.yml
  • infra/docker-compose.yml
  • infra/inventory.ini
  • infra/main.tf

Comment thread .github/workflows/vm-start.yml Outdated

@paulwiese paulwiese left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

jschoedl and others added 2 commits July 19, 2026 16:24
…te-level timer

The hours input was interpolated directly into run: scripts (command
injection). Bind it via env and reference the shell var instead. Switch the
input to minutes (default 120) for finer auto-shutdown granularity.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jschoedl
jschoedl merged commit 821c9ff into main Jul 19, 2026
1 check was pending
@jschoedl
jschoedl deleted the feat/azure-vm-lifecycle branch July 19, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants