Run cloud and on-prem init environment scripts¶
Purpose: Prepare Azure, GCP, and Proxmox so Terraform/Terragrunt and other tooling can consume consistent *.credentials.tfvars and evidence from the init--env scripts.
Owner: Platform engineering / HybridOps.Studio maintainer
Trigger: Before first Terraform apply in a new environment, after rotating cloud credentials, or after changing Proxmox API tokens.
Impact: Until this completes successfully, Terraform plans/applies may fail or use stale credentials.
Severity: P3 (blocking for new environments, non-urgent once steady-state is reached).
Pre-reqs: Git repo cloned, toolchain installed, Azure/GCP accounts with required privileges, Proxmox API token present.
Rollback strategy:* Rerun the script with corrected config; rotate or revoke generated credentials if a run is misconfigured.
Context¶
This runbook covers the one-time (and occasionally repeated) bootstrap of cloud and on-prem environments using:
init-azure-env.shinit-gcp-env.shinit-proxmox-env.sh
Each script:
- Validates CLI access (Azure CLI, gcloud, Proxmox API).
- Writes environment configuration for Terraform into
infra/env/*.credentials.tfvars. - Emits logs under
output/logs/platform/...and human-readable evidence underoutput/artifacts/platform/....
It does not cover:
- Terraform/Terragrunt plans or applies.
- Creating or funding cloud billing accounts.
- Day-2 lifecycle of service principals or service accounts (use separate security/compliance runbooks).
Preconditions and safety checks¶
Before running any init script:
- Repo and branch
git statusis clean or only has expected local changes.-
You are on the intended branch (for example
mainor a feature branch with reviewed changes). -
Tooling installed
- From platform repo root:
make prereq.check -
Confirm Azure CLI,
gcloud, and Python are listed as installed where required. -
Azure account
- You can authenticate interactively with
az login. -
Your account has permission to create and manage a service principal and assign roles in the target subscription.
-
GCP account
- You can authenticate with
gcloud auth login. -
Your account is Owner (or has equivalent IAM permissions) on the target project.
-
Proxmox
infra/env/proxmox.credentials.tfvars(or successor config) exists and contains a valid API token with least-privilege access to required nodes.-
You can reach the Proxmox API (for example from the control node).
-
Secrets hygiene
control/secrets.vault.envexists (or will be created/updated) and is excluded by.gitignore.control/tools/provision/init/.conf/keys.local/is present or creatable and is excluded by.gitignore.
Steps¶
1) Verify toolchain and environment¶
- From the platform repository root:
- Action: Confirm prerequisites and Python venv.
- Command:
cd ~/hybridops-studio/hybridops-platform make prereq.check - Expected result: Azure CLI, gcloud, Terraform, Packer, and Python3 are reported as installed;
.venvis present or can be created viamake prereq.python.env. - Evidence: Optional screenshot or terminal capture saved under
output/artifacts/decision/if this is part of a formal review.
2) Initialise Azure environment¶
- Run the Azure init script:
- Action: Log into Azure (if needed), ensure a bootstrap service principal, and write
azure.credentials.tfvarsand evidence. - Command:
cd ~/hybridops-studio/hybridops-platform ./control/tools/provision/init/init-azure-env.sh - Expected result:
- Azure CLI opens a login flow if not already authenticated.
- On success, the script reports:
Configuration: infra/env/azure.credentials.tfvarsSecrets: control/secrets.vault.envLog: output/logs/platform/cloud/azure/init-env/<timestamp>-init-azure.log
-
Evidence:
- Log:
output/logs/platform/cloud/azure/init-env/<timestamp>-init-azure.log - Proof bundle:
output/artifacts/platform/cloud/azure/init-env/<timestamp>/
(withlatestsymlink pointing to the most recent successful run).
- Log:
-
Sanity-check generated configuration:
- Command:
sed -n '1,20p' infra/env/azure.credentials.tfvars - Expected result: Subscription, tenant, client ID, client secret, and location fields present and non-empty (secrets remain only in local files, not committed).
3) Initialise GCP environment¶
- Run the GCP init script:
- Action: Log into GCP (if needed), ensure a Terraform service account, generate a JSON key, and write
gcp.credentials.tfvars. - Command:
cd ~/hybridops-studio/hybridops-platform ./control/tools/provision/init/init-gcp-env.sh -
Notes:
- If not authenticated,
gcloud auth login --no-launch-browserwill print a URL and verification code. - Copy the URL into a browser, complete sign-in, then paste the code back into the terminal prompt.
- Press
Ctrl+Cto cancel if you need to abort the login.
- If not authenticated,
-
Expected result:
- Service account
terraform-hybridops@<project>.iam.gserviceaccount.comexists (or is confirmed). - A credentials JSON is written to:
control/tools/provision/init/.conf/keys.local/terraform-hybridops.json- The script reports:
Configuration: infra/env/gcp.credentials.tfvarsLog: output/logs/platform/cloud/gcp/init-env/<timestamp>-init-gcp.log
- Service account
-
Evidence:
- Log:
output/logs/platform/cloud/gcp/init-env/<timestamp>-init-gcp.log - Proof bundle:
output/artifacts/platform/cloud/gcp/init-env/<timestamp>/
(withlatestsymlink for the most recent successful run).
- Log:
-
Sanity-check generated configuration and key file:
- Command:
sed -n '1,20p' infra/env/gcp.credentials.tfvars ls -l control/tools/provision/init/.conf/keys.local/ - Expected result:
project_id,region, andcredentials_fileentries present.- JSON key file exists with appropriate permissions (for example
600).
4) Initialise Proxmox environment¶
- Run the Proxmox init script:
- Action: Validate API connectivity, discover nodes/storage, and generate Proxmox env configuration and evidence.
- Command:
cd ~/hybridops-studio/hybridops-platform ./control/tools/provision/init/init-proxmox-env.sh - Expected result:
- Script completes without error.
- Proxmox-specific env/config files under
infra/env/are updated or confirmed. - Log is written under:
output/logs/platform/onprem/proxmox/init-env/<timestamp>-init-proxmox.log
-
Evidence:
- Proof bundle under:
output/artifacts/platform/onprem/proxmox/init-env/<timestamp>/
(withlatestsymlink pointing at the latest successful run).
-
Sanity-check Proxmox discovery output:
- Command:
sed -n '1,40p' infra/env/proxmox.credentials.tfvars 2>/dev/null || echo "Using new Proxmox env format; see infra/env/ for details." - Expected result: Node and storage settings match the intended Proxmox cluster (no hard-coded test values).
Verification¶
To confirm the init scripts completed successfully:
- Terraform env files exist and are non-empty
infra/env/azure.credentials.tfvarsinfra/env/gcp.credentials.tfvars-
Proxmox env files under
infra/env/ -
Evidence locations are populated
- Azure:
output/logs/platform/cloud/azure/init-env/latest-init-azure.log(via symlink)output/artifacts/platform/cloud/azure/init-env/latest/
- GCP:
output/logs/platform/cloud/gcp/init-env/latest-init-gcp.log(via symlink)output/artifacts/platform/cloud/gcp/init-env/latest/
-
Proxmox:
output/logs/platform/onprem/proxmox/init-env/latest-init-proxmox.log(naming may vary)output/artifacts/platform/onprem/proxmox/init-env/latest/
-
Dry-run a Terraform/Terragrunt call (optional but recommended)
- From a small stack (for example a dev or sandbox layer), run
terragrunt planorterraform planand confirm:- Backend initialises cleanly.
- No authentication or permission errors for Azure, GCP, or Proxmox.
Post-actions and clean-up¶
- Secrets and credentials
- Confirm
.gitignorecorrectly excludes:control/secrets.vault.envcontrol/tools/provision/init/.conf/keys.local/
-
Store any exported keys or
*.credentials.tfvarssnapshots only in approved, encrypted locations. -
Cloud sessions
-
Optionally sign out of interactive sessions after confirming init evidence:
az logout gcloud auth revoke --all -
Documentation and tickets
- If this run was part of a change or onboarding task, attach:
- Paths to the
latestevidence bundles for Azure, GCP, and Proxmox. - A note confirming Terraform/Terragrunt plan completed successfully against at least one stack.
- Paths to the
References¶
- HOWTOs and provisioning docs:
- HOWTO – Proxmox, Azure, and GCP init scripts
-
Evidence and outputs:
- Evidence Map
-
Output layout overview:
output/README.mdin thehybridops-platformrepository. -
Related ADRs:
-
Source and scripts:
control/tools/provision/init/