Skip to main content

GitLab CI/CD Pipeline

Reference Azure

DOCUMENT CATEGORY: Reference SCOPE: GitLab CI/CD pipeline configuration PURPOSE: Document the primary GitLab delivery pipeline for Azure Local deployments MASTER REFERENCE: GitLab CI/CD Documentation

Status: Active


Overview​

GitLab CI/CD is the primary pipeline platform for Azure Local deployments. The pipeline uses modular stage includes, manual approval gates between phases, and artifact passing between jobs. No value of a deployment is written in a pipeline file: every value a job needs is a key of infrastructure.yml, and Task 05 of the CI/CD setup sets it on the project as a CI/CD variable (Task 05). Run Task 05 again after you change the file.

Pipeline Architecture​

validate → plan → deploy-foundation → configure-onprem → configure-operations
StageToolRunnerTrigger
validateTerraform validate, Ansible lint, config validationThe tag in AZL_RUNNER_LABELAutomatic
planTerraform planThe tag in AZL_RUNNER_LABELAutomatic
deploy-foundationTerraform apply, output exportThe tag in AZL_RUNNER_LABELManual approval
configure-onpremAnsible playbooks 05, 01, 02, 03 (domain controllers, AD preparation, OS configuration, Arc registration)Self-hostedManual, in the approval environment of AZL_ENVIRONMENT_TERRAFORM_DEPLOYMENT
configure-operationsAnsible playbook 04 (monitoring)Self-hostedManual, in the approval environment of AZL_ENVIRONMENT_TERRAFORM_DEPLOYMENT

The Ansible plays change machines, so the configure stages use the same protected environment as terraform:apply, the same as on GitHub. While AZL_ENVIRONMENT_TERRAFORM_DEPLOYMENT is empty their jobs are not created, and configure-onprem-approval-environment-not-set and configure-operations-approval-environment-not-set fail and say why.

The Azure Local cluster itself is deployed by the ARM Validate and Deploy pipeline below, not by this chain. The earlier deploy-cluster stage is gone.

Pipeline Structure​

pipelines/gitlab/
├── .gitlab-ci.yml # Master pipeline definition (includes stages/*.yml)
├── Use-AzlGitLabTool.ps1 # Installs the tool versions of devops.pipelines.tool_versions
├── os-configuration.gitlab-ci.yml # OS configuration (plan, manual confirm of a wipe, manual apply)
└── stages/
├── validate.yml # Terraform validate, Ansible lint, infrastructure file check, Terraform plan
├── deploy-foundation.yml # Terraform apply, outputs
├── configure-onprem.yml # Playbooks 05, 01, 02, 03
├── configure-operations.yml # Playbook 04
├── deploy-cicd-infra.yml # The runners (runs with CICD_INFRA=true)
├── discovery.yml # Discovery (a pipeline of its own)
├── pre-cluster-verification.yml # The gate before the ARM Validate (a pipeline of its own)
├── arm-deployment.yml # ARM Validate and Deploy (a pipeline of its own)
├── post-deployment.yml # Post-deployment, Phase 06 (a pipeline of its own)
├── validation.yml # Validation before the handover (a pipeline of its own)
├── day2-check-updates.yml # Day 2: check for updates, on a schedule (a pipeline of its own)
├── day2-update.yml # Day 2: start the solution update (a pipeline of its own)
├── day2-node-maintenance.yml # Day 2: one node through maintenance (a pipeline of its own)
└── day2-cluster-operations.yml # Day 2: cluster operations (a pipeline of its own)

.gitlab-ci.yml includes only the stages of the Terraform and Ansible chain and deploy-cicd-infra.yml. discovery.yml, pre-cluster-verification.yml, arm-deployment.yml, post-deployment.yml, validation.yml and the four day2-*.yml files declare their own stages, so they are not included from .gitlab-ci.yml: include each from a pipeline file of its own (include: local: pipelines/gitlab/stages/<file>), or copy it.

The reusable templates templates/terraform-plan-apply.yml and templates/ansible-playbook.yml are gone: each job is one pwsh block of its own.

Configuration​

CI/CD Variables​

Task 05 sets each variable below from its key as a project CI/CD variable (scope *; the sign-in values also per environment). The pipeline files hold no runner tag, environment name, tool version, infrastructure file path or sign-in method of their own.

VariableKey in infrastructure.yml
ARM_CLIENT_IDazure.automation_identity.client_id (else the app registration Task 01 made)
ARM_TENANT_IDazure.tenant_id
ARM_SUBSCRIPTION_IDazure.subscription_id
AZL_AUTH_METHODdevops.authentication.method (oidc or client_secret)
ARM_CLIENT_SECRET (masked, only with client_secret)devops.authentication.client_secret (a secret reference; Task 05 reads it from Key Vault)
TF_BACKEND_RG, TF_BACKEND_SA, TF_BACKEND_CONTAINER, TF_BACKEND_KEYdevops.state.resource_group, .storage_account, .container, .azure_local_key
AZL_RUNNER_LABELdevops.pipelines.runner_label (one of devops.runners[].labels of the general runner)
AZL_ENVIRONMENT_OS_CONFIGURATION, AZL_ENVIRONMENT_ARM_DEPLOYMENT, AZL_ENVIRONMENT_CICD_INFRA, AZL_ENVIRONMENT_TERRAFORM_DEPLOYMENT, AZL_ENVIRONMENT_OPERATIONSdevops.pipelines.environments.* (operations gates every validation and day 2 job that changes the cluster)
AZL_INFRASTRUCTURE_FILEdevops.pipelines.infrastructure_file
AZL_HANDOFF_PATHdevops.pipelines.handoff_path
AZL_TERRAFORM_VERSION, AZL_PYTHON_VERSION, AZL_ANSIBLE_CORE_VERSION, AZL_ANSIBLE_LINT_VERSION, AZL_AZ_POWERSHELL_VERSION, AZL_POWERSHELL_YAML_VERSION, AZL_AZ_KEYVAULT_VERSIONdevops.pipelines.tool_versions.terraform, .python, .ansible_core, .ansible_lint, .az_powershell, .powershell_yaml, .az_keyvault
AZL_RUNNER_SSH_PUBLIC_KEYdevops.runners[].admin_ssh_public_key of the Linux runner

Nothing else is set by hand: the earlier DOMAIN_ADMIN_PASSWORD, CLUSTER_NAME and CLUSTER_RESOURCE_GROUP variables are gone. The Ansible roles read the LCM and DSRM passwords from Key Vault on the controller, and the cluster values come from the infrastructure file.

No change without an approval environment. Every job of the toolkit's pipelines that changes something runs in the protected environment named by an AZL_ENVIRONMENT_* variable. While that variable is empty, the job does not run without an approval. Instead a refusal job runs: <pipeline>-approval-environment-not-set (for example day2-update-approval-environment-not-set or arm-approval-environment-not-set). It fails with a message that names the variable and its devops.pipelines.environments.* key, and nothing is sent to any machine. This holds for the OS configuration, CI/CD infrastructure, Terraform, ARM deployment, validation (the storage load test) and day 2 pipelines. The read-only jobs run as before. It is the same rule as the Azure DevOps stage ApprovalEnvironmentNotSet.

Sign-in. With oidc each job signs in with the GitLab ID token ARM_OIDC_TOKEN (id_tokens, audience api://AzureADTokenExchange, the federated credential Task 01 made): Connect-AzAccount -FederatedToken, Terraform ARM_USE_OIDC=true. With client_secret the jobs use the masked ARM_CLIENT_SECRET: Connect-AzAccount -Credential, Terraform ARM_CLIENT_SECRET. A managed identity of the runner is not a sign-in method of the pipelines.

State. Every terraform init passes the four TF_BACKEND_* variables to the azurerm backend, with Microsoft Entra sign-in to the storage account (use_azuread_auth=true). The state stays in the backend: the apply job keeps no terraform.tfstate as an artifact, because a state file holds secrets.

Variable files. Every Terraform and Ansible job writes its inputs from the infrastructure file first, with config/variables/scripts/New-IacVariableFiles.ps1 -InfrastructureFile <file> -OutputDirectory $IAC_DIRECTORY (a directory outside the checkout, removed after the job). Terraform plans with -var-file=$IAC_DIRECTORY/terraform/azure-local/terraform.tfvars.json; the Ansible jobs copy hosts.yml, group_vars and host_vars into src/ansible/inventory (git-ignored there) and run with -i inventory/hosts.yml. The files hold subscription IDs and names, so they are never committed or kept as artifacts.

Tool versions​

GitLab has no installer action or task, so each job dot-sources pipelines/gitlab/Use-AzlGitLabTool.ps1 at the start of its pwsh block:

. ./pipelines/gitlab/Use-AzlGitLabTool.ps1 -Tool Terraform -TerraformVersion $env:AZL_TERRAFORM_VERSION
-ToolWhat it does
TerraformUses terraform from PATH when it is that version; otherwise downloads that release from releases.hashicorp.com and puts it first in PATH
AnsibleCreates a virtual environment with python<PythonVersion>, installs ansible-core==<AnsibleCoreVersion> and, when given, ansible-lint==<AnsibleLintVersion>
ModulesInstalls each PowerShell module whose version is given (powershell-yaml, Az, Az.KeyVault) from the PowerShell Gallery, unless that version is there

The script holds no version of its own; a missing version or a failed download or install fails the job.

Runner Requirements​

The configure-onprem and configure-operations stages require the general self-hosted GitLab Runner (the one in devops.runners[], tagged with AZL_RUNNER_LABEL) with:

  • Network access: WinRM (5986), LDAP (389), Kerberos (88) to on-premises infrastructure
  • Software: PowerShell 7 (every job script is a pwsh block) and Python at the version devops.pipelines.tool_versions.python (python<version> on PATH)
  • Outbound HTTPS to the PowerShell Gallery, PyPI and releases.hashicorp.com, unless the tool versions are already installed

Stage Details​

Validate Stage​

  • terraform:validate — terraform init -backend=false, terraform validate and terraform fmt -check
  • ansible:lint — ansible-lint playbooks/ roles/ and ansible-playbook --syntax-check playbooks/site.yml
  • config:validate — Checks the infrastructure file in AZL_INFRASTRUCTURE_FILE with scripts/common/infrastructure/Test-InfrastructureFile.ps1 before anything is generated from it

Plan Stage​

  • terraform:plan — Writes the variable files, then terraform plan -out=tfplan with the generated terraform.tfvars.json; the plan is passed to the apply job

Deploy Foundation Stage​

  • terraform:apply — Applies the plan, manual job in the environment in AZL_ENVIRONMENT_TERRAFORM_DEPLOYMENT
  • terraform:outputs — Exports outputs as a JSON artifact for downstream stages

Configure On-Prem Stage (sequential with manual gates)​

  • management:vms — playbooks/05-management-vms.yml (the domain controllers, first)
  • ad:preparation — playbooks/01-ad-preparation.yml (on the first domain controller)
  • os:configuration — playbooks/02-os-configuration.yml, which runs Invoke-AzureLocalOsConfiguration.ps1 on the runner with -e azurelocal_os_configuration_infrastructure_file=<AZL_INFRASTRUCTURE_FILE> (PowerShell 7, powershell-yaml, Az and Az.KeyVault)
  • arc:registration — playbooks/03-arc-registration.yml

Configure Operations Stage​

  • monitoring:setup — playbooks/04-monitoring-setup.yml

The chain ends at Configure Operations, as on GitHub and Azure DevOps. The GitLab-only Validate Deployment stage (a policy and Defender for Cloud summary no other platform had) is removed: one design on the three platforms (owner directive D126). The post-deployment checks are the validation pipeline below.

Started by hand. Every GitLab pipeline file of the toolkit has workflow: rules: - if: '$CI_PIPELINE_SOURCE =~ /^(web|api)$/': GitLab creates a pipeline only from the web form or the API, never from a push or a merge request, as GitHub starts it with workflow_dispatch and Azure DevOps with trigger: none and pr: none. The one exception is the check for updates, whose rule is /^(schedule|web|api)$/ so that its project schedule can start it.

OS Configuration Pipeline​

File: pipelines/gitlab/os-configuration.gitlab-ci.yml (include it from .gitlab-ci.yml, or copy it). It runs Invoke-AzureLocalOsConfiguration.ps1 and nothing else.

StageJob typeDescription
planAutomaticRead only. Publishes the plan report and the wipe list (the disks that would be wiped on each node when os_configuration.clear_storage is true) as artifacts
confirmManualThe second approval of a storage wipe: os-configuration-confirm-storage-wipe, in the protected environment of AZL_ENVIRONMENT_OS_CONFIGURATION_CLEAR_STORAGE (devops.pipelines.environments.os_configuration_clear_storage). GitLab creates the jobs before the plan runs, so the job exists in every run that can apply; when os_configuration.clear_storage is false it says nothing is wiped and ends. While that variable is empty, os-configuration-storage-wipe-approval-environment-not-set takes its place and fails when the master file would wipe. The same two approvals as GitHub and Azure DevOps (D126)
applyManualSomeone allowed to run protected jobs reads the plan job's log and artifacts, then plays it, after the second approval of a wipe. resource_group keeps two runs from working on the cluster at once

Variables: ARM_CLIENT_ID, ARM_TENANT_ID, ARM_SUBSCRIPTION_ID, AZL_AUTH_METHOD (oidc through id_tokens, or client_secret with the masked ARM_CLIENT_SECRET), AZL_RUNNER_LABEL, AZL_ENVIRONMENT_OS_CONFIGURATION (the approval environment of the apply job), AZL_INFRASTRUCTURE_FILE, AZL_HANDOFF_PATH (a handoff file or a directory of *.ztp-handoff.json, or the artifact of the ZTP pipeline through needs:) and the tool versions AZL_POWERSHELL_YAML_VERSION, AZL_AZ_POWERSHELL_VERSION, AZL_AZ_KEYVAULT_VERSION, all set by Task 05. The transport and the storage wipe come from the master file (os_configuration.remoting.transport, os_configuration.clear_storage); the pipeline overrides neither. No secret is stored in the file: the nodes' local administrator password is read from the Key Vault named by identity.local_admin.password. The runner needs a route to the nodes' management network for PowerShell remoting (WinRM), or -Transport ArcRunCommand for a site with no route. See Automated OS configuration.

Discovery Pipeline​

File: pipelines/gitlab/stages/discovery.yml. It declares its own stage (discovery), so include it from a pipeline file of its own, not from .gitlab-ci.yml. It runs scripts/common/discovery/Invoke-AzlDiscoveryRun.ps1 and nothing else.

JobStageDescription
discoverydiscoveryRead only, no approval job: nothing in the run changes a BMC, a node, Azure or Active Directory. resource_group allows one discovery at a time

Run variables (the web form offers them):

VariableMeaning
DISCOVERY_SCOPEall (default: hardware inventory, Azure tenant and Active Directory), hardware (any maker, standard Redfish API), dell (Dell iDRAC only, with the proposal for nodes[]), tenant or directory
DISCOVERY_MANAGEMENT_PORTScope dell: the management port of every node, by suggested name or MAC. Empty: the MAC already in the file
DISCOVERY_WRITE_BACKtrue, scope dell: put the serial numbers and MAC addresses found into a copy of the master file, in the artifacts (write-back/). The file in the repository is not changed and nothing is committed: review the copy and commit it through a merge request
DISCOVERY_INCLUDE_RBACtrue, scope tenant: also record the role assignments

The job keeps discovery-report.json, summary.md and a folder per step as artifacts (when: always, so also when a step fails; kept for 30 days) and prints summary.md in the log. The job fails when a step fails.

Project CI/CD variables set by Task 05: ARM_CLIENT_ID, ARM_TENANT_ID, ARM_SUBSCRIPTION_ID, AZL_AUTH_METHOD (and the masked ARM_CLIENT_SECRET with client_secret), AZL_RUNNER_LABEL, AZL_INFRASTRUCTURE_FILE, AZL_POWERSHELL_YAML_VERSION, AZL_AZ_POWERSHELL_VERSION, AZL_AZ_KEYVAULT_VERSION. The identity needs Reader on the subscriptions of the tenant inventory and Get on the Key Vault secrets of the BMC login. The BMC login is never in the file or in a project variable: it is the secret reference in infrastructure.yml (hardware.bmc, or nodes[].bmc), read from Key Vault at run time with the Azure sign-in of the job. The runner needs a route to the BMC addresses (HTTPS, TCP 443) and, for the directory step, the ActiveDirectory module (RSAT) on a domain-joined runner.

Pre-cluster Verification Pipeline​

File: pipelines/gitlab/stages/pre-cluster-verification.yml. It declares its own stage (pre-cluster-verification), so include it from a pipeline file of its own, not from .gitlab-ci.yml. It runs scripts/deploy/04-cluster-deployment/phase-05-cluster-deployment/Invoke-AzureLocalPreClusterVerification.ps1 and nothing else. Run it after the OS configuration and before the ARM Validate: the ARM run refuses to go on without a passing, current result of it for the same master file.

JobDescription
pre-cluster-verifyRead only. PRECLUSTER_MODE Plan (what would be checked, offline) or Verify (every check, against Azure, Active Directory and the nodes)
pre-cluster-verify-changesRuns instead of the first when PRECLUSTER_FIX or PRECLUSTER_INSTALL_ENVIRONMENT_CHECKER is true. A manual job in the protected environment in AZL_ENVIRONMENT_ARM_DEPLOYMENT (devops.pipelines.environments.arm_deployment): someone allowed to run jobs there plays it. PRECLUSTER_FIX registers the mandatory resource providers that are not registered (Azure side only). PRECLUSTER_INSTALL_ENVIRONMENT_CHECKER puts the Environment Checker on the nodes for this run and removes it again

Run variables: PRECLUSTER_MODE (default Plan), OS_CONFIGURATION_REPORT (GitLab fetches another pipeline's artifact only through needs: pipeline: or needs: project:, so add that to the jobs), HANDOFF_FILE, PRECLUSTER_ACCEPT_SKIPPED (ids of checks that may stay Skipped, comma separated; the report records that you accepted them), PRECLUSTER_ALLOW_REVALIDATE, PRECLUSTER_FIX, PRECLUSTER_INSTALL_ENVIRONMENT_CHECKER. Project CI/CD variables: the same as the discovery pipeline, plus AZL_ENVIRONMENT_ARM_DEPLOYMENT. The identity needs Reader for the checks (Owner or Contributor for PRECLUSTER_FIX).

Keep the approval environment out of reach of the run form

A person who starts a GitLab pipeline by hand can override a variable in the run form, AZL_ENVIRONMENT_ARM_DEPLOYMENT included. Restrict who may set pipeline variables (project Settings > CI/CD > Variables, the minimum role to use pipeline variables) and protect the environment.

The job fails when the verdict is not Pass (exit code 1: a Failed or Skipped check blocks; 3: a partial run). It keeps report.json, summary.md and the event feed as artifacts (kept for 30 days) and prints summary.md in the log.

The ARM run reads a folder, not the artifact

The job passes no -ReportDirectory. The script writes its result where the ARM run reads it: deployment.pre_cluster_verification_report_directory, else arm-report/verification/live in the environment data folder of the master file. The artifact is only a copy. Run the ARM pipeline on the same runner, or set deployment.pre_cluster_verification_report_directory to a folder both runs reach.

The runner needs a route to the nodes (WinRM, TCP 5985 or 5986), to a domain controller (LDAP, TCP 389) and to the DNS servers of the file. A check the runner cannot ask is Skipped with its reason, and a Skipped check blocks the verdict until you accept its id. Details: Pre-cluster verification gate.

ARM Validate and Deploy Pipeline​

File: pipelines/gitlab/stages/arm-deployment.yml. It declares its own stages (arm-plan, arm-validate, arm-deploy), so include it from a pipeline file of its own, not from .gitlab-ci.yml, whose stage list belongs to the Terraform and Ansible pipeline above.

JobStageDescription
arm-preconditionsarm-planRead only. Parameters and every precondition. Always runs
arm-validatearm-validateRuns when ARM_MODE is Validate or ValidateAndDeploy
arm-deployarm-deployManual job in the protected environment in AZL_ENVIRONMENT_ARM_DEPLOYMENT (devops.pipelines.environments.arm_deployment). It re-checks every precondition and that these parameters validated. ARM_RESUME=true resubmits a failed Deploy

Project CI/CD variables set by Task 05: ARM_CLIENT_ID, ARM_TENANT_ID, ARM_SUBSCRIPTION_ID, AZL_AUTH_METHOD (and the masked ARM_CLIENT_SECRET with client_secret), AZL_RUNNER_LABEL, AZL_ENVIRONMENT_ARM_DEPLOYMENT, AZL_INFRASTRUCTURE_FILE, AZL_POWERSHELL_YAML_VERSION, AZL_AZ_POWERSHELL_VERSION, AZL_AZ_KEYVAULT_VERSION. Run variables (the web form offers them): ARM_MODE (Plan, Validate, ValidateAndDeploy, Deploy; default Plan), OS_CONFIGURATION_REPORT (GitLab fetches another pipeline's artifact only through needs: pipeline: or needs: project:), HANDOFF_FILE, ARM_ACKNOWLEDGE. The Validate and Deploy jobs have a fixed upper bound of 1500 minutes (the registry maximum of deployment.validate_timeout_minutes and deployment.deploy_timeout_minutes, 1440, plus 60); the runner's own maximum job timeout must allow it. Details: ARM Validate and Deploy automation.

Post-Deployment Pipeline​

File: pipelines/gitlab/stages/post-deployment.yml. It declares its own stages (post-deployment-validate, post-deployment-plan, post-deployment-apply), so include it from a pipeline file of its own, not from .gitlab-ci.yml. Run it after the ARM deployment succeeded. It runs Invoke-AzureLocalPostDeployment.ps1, the eleven tasks of Phase 06 in one run, and nothing else.

JobStageDescription
post-deployment-validatepost-deployment-validateRead only. Test-InfrastructureFile.ps1 checks the master file. Always runs
post-deployment-planpost-deployment-planRead only. -Mode Plan: every selected step with -WhatIf. Always runs after the validate job; the person who plays the apply job reads its report
post-deployment-applypost-deployment-applyManual job for POST_DEPLOYMENT_MODE Apply, in the protected environment in AZL_ENVIRONMENT_OPERATIONS (devops.pipelines.environments.operations). -Mode Apply, the same selection. It holds the resource_group azure-local-day2-changes with the update, the node maintenance and the other changes to the cluster
post-deployment-approval-environment-not-setpost-deployment-applyRuns for Apply while AZL_ENVIRONMENT_OPERATIONS is empty, instead of the apply job: it fails with a message that names the variable, and nothing is changed

Run variables (the web form offers them): POST_DEPLOYMENT_MODE (Plan or Apply, default Plan), POST_DEPLOYMENT_ONLY (steps or tasks, comma-separated, for example task-05 or storage-paths), POST_DEPLOYMENT_FROM and POST_DEPLOYMENT_TO (a range), POST_DEPLOYMENT_CONTINUE_ON_WARNING (false or true). Empty selection variables run every step the file turns on. Project CI/CD variables set by Task 05: ARM_CLIENT_ID, ARM_TENANT_ID, ARM_SUBSCRIPTION_ID, AZL_AUTH_METHOD (and the masked ARM_CLIENT_SECRET with client_secret), AZL_RUNNER_LABEL, AZL_ENVIRONMENT_OPERATIONS, AZL_INFRASTRUCTURE_FILE, AZL_POWERSHELL_YAML_VERSION, AZL_AZ_POWERSHELL_VERSION, AZL_AZ_KEYVAULT_VERSION. The artifacts are post-deployment-plan and post-deployment-report. How to run one task, the SDN gate and the exit codes: Post-Deployment Pipeline.

Validation and Day 2 Pipelines​

Five pipelines run the scripts of Part 7 and Part 8 of the implementation guide, each the command an operator runs by hand and nothing else. Each file declares its own stage: include it from a pipeline file of its own (include: local: pipelines/gitlab/stages/<file>), not from .gitlab-ci.yml. How to run each script by hand and in a pipeline: Run the Validation in a Pipeline and Run Day 2 Operations in a Pipeline.

FileRead-only job (no approval)Manual job (approval)Run variables
pipelines/gitlab/stages/validation.ymlvalidation-read-only: the four validation scripts; the storage script without its load testvalidation-storage-performance: Test-StoragePerformance.ps1 -RunPerformanceTest, only when asked, after the read-only job passedVALIDATION_RUN_PERFORMANCE_TEST (default false)
pipelines/gitlab/stages/day2-check-updates.ymlday2-check-updates-azure (Azure CLI, no node access) or day2-check-updates-cluster (PowerShell remoting)noneUPDATECHECK_SOURCE (azure, the default, or cluster)
pipelines/gitlab/stages/day2-update.ymlday2-update-plan: Start-AzureLocalSolutionUpdate.ps1 -WhatIfday2-update-apply: PrepareOnly or InstallDAY2UPDATE_ACTION (Plan, PrepareOnly, Install), DAY2UPDATE_MODE (AfterDeployment, OnDemand)
pipelines/gitlab/stages/day2-node-maintenance.ymlday2-node-maintenance-plan: the node is checked against nodes[] with -RequireNodeInFile, then -WhatIfday2-node-maintenance-apply: Reboot or Resume (-ResumeOnly)MAINTENANCE_NODE (one node), MAINTENANCE_ACTION (Plan, Reboot, Resume)
pipelines/gitlab/stages/day2-cluster-operations.ymlday2-cluster-operations-read (HealthCheck, Alerts, Capacity), or day2-cluster-operations-plan (-WhatIf) for a changeday2-cluster-operations-apply: MaintenanceMode, LiveMigrate or RebalanceOPERATIONS_ACTION, OPERATIONS_NODE, OPERATIONS_ENABLE
  • Plan first. The manual job needs the read-only job and is offered only when it succeeded.
  • One approval environment. Every manual job runs in the protected environment named by AZL_ENVIRONMENT_OPERATIONS (devops.pipelines.environments.operations). Someone allowed to run jobs there plays it. Approval rules on a protected environment need GitLab Premium or above.
  • One change at a time. Every manual job has the resource_group azure-local-day2-changes, so two changes never run on the cluster together. The read-only jobs hold no lock.
  • One node per run. The node variable is checked against nodes[] with -RequireNodeInFile. A name the file does not list ends the job with exit code 2 before anything is sent.
  • A failed script fails the job. The report, plan or log is kept as an artifact even then (when: always).
  • Start. The jobs start only from the web form or the API (the check for updates also from its project schedule), never from a push or a merge request (workflow: rules:).

Project CI/CD variables set by Task 05: AZL_RUNNER_LABEL, AZL_ENVIRONMENT_OPERATIONS, AZL_INFRASTRUCTURE_FILE, AZL_POWERSHELL_YAML_VERSION. The check for updates (source azure) and the node maintenance also sign in to Azure (ARM_CLIENT_ID, ARM_TENANT_ID, ARM_SUBSCRIPTION_ID, AZL_AUTH_METHOD, and the masked ARM_CLIENT_SECRET with client_secret); the node maintenance also reads AZL_AZ_POWERSHELL_VERSION and AZL_AZ_KEYVAULT_VERSION. The other pipelines do not sign in to Azure.

The account. The scripts connect to the cluster as the account the runner runs as, which must be an administrator of the cluster. No pipeline passes -Credential or holds a password. The node maintenance reads the node login from its secret reference in infrastructure.yml (identity.local_admin), from Key Vault, with the Azure sign-in of the job. The validation needs the Failover Clustering PowerShell module (RSAT Failover Clustering Tools) on the runner, so a Windows runner. The Azure view of the check for updates needs the Azure CLI on the runner.

The schedule. GitLab keeps a schedule in the project, not in the file (CI/CD > Schedules). Task 05 creates or updates the schedule Azure Local day 2: check for updates for the default branch, with the cron expression of devops.pipelines.schedules.check_for_updates (UTC, default 17 4 * * *: every day at 04:17), and deactivates it when the key is empty. The same key schedules GitHub and Azure DevOps (D126). A scheduled pipeline takes the Azure view, the default of UPDATECHECK_SOURCE. The job fails when the cluster needs attention (exit code 1), so GitLab's notification of a failed pipeline is the alert. The report is the artifact day2-update-check.

While AZL_ENVIRONMENT_OPERATIONS is empty, nothing is changed. A run that would change something fails in the refusal job of its pipeline (post-deployment-approval-environment-not-set, validation-approval-environment-not-set, day2-update-approval-environment-not-set, day2-node-maintenance-approval-environment-not-set or day2-cluster-operations-approval-environment-not-set), with a message that names the variable, and nothing is sent to any machine.

Keep the approval environment out of reach of the run form

A person who starts a pipeline by hand can override a variable in the run form, AZL_ENVIRONMENT_OPERATIONS included. Restrict who may set pipeline variables (project Settings > CI/CD > Variables, the minimum role to use pipeline variables) and protect the environment.

Repository​

Source: azurelocal-toolkit/pipelines/gitlab/


PreviousUpNext
Part 2: CI/CD PipelinesPart 2: CI/CD PipelinesGitHub Actions