:exclamation: NB! |
---|
Due to the renaming of Company, the Github organization has changed name from "amestofortytwo" to "fortytwoservices". Pre-existing Terraform code would need to change that in code. |
This module deploys a virtual machine scale set for self hosted runners for Azure DevOps and GitHub.
provider "azurerm" {
features {}
}
module "vmss" {
source = "fortytwoservices/selfhostedrunnervmss/azurerm"
operating_system = "ubuntu" # windows or ubuntu
runner_platform = "azure_devops" # azure_devops or github
}
After deploying the virtual machine scale set, you need to configure the Azure DevOps or GitHub side of things according to our documentation:
The following requirements are needed by this module:
terraform {
required_version = ">=1.4.6"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">=3.100.0"
}
}
}
provider "azurerm" {
features {}
}
module "vmss" {
source = "fortytwoservices/selfhostedrunnervmss/azurerm"
version = "1.6.0"
operating_system = "ubuntu" # windows or ubuntu
runner_platform = "azure_devops" # azure_devops or github
deploy_load_balancer = true
}
output "password" {
value = nonsensitive(module.vmss.password)
}
terraform {
required_version = ">=1.4.6"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">=3.100.0"
}
}
}
provider "azurerm" {
features {}
}
# Create custom rg
resource "azurerm_resource_group" "rg" {
location = "westeurope"
name = "runners"
}
# Create custom vnet
resource "azurerm_virtual_network" "vmss" {
name = "runner-network"
address_space = ["10.0.0.0/24"]
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
}
resource "azurerm_subnet" "vmss" {
name = "vmss"
resource_group_name = azurerm_resource_group.rg.name
virtual_network_name = azurerm_virtual_network.vmss.name
address_prefixes = azurerm_virtual_network.vmss.address_space
}
module "vmss" {
source = "fortytwoservices/selfhostedrunnervmss/azurerm"
version = "1.6.0"
operating_system = "ubuntu" # windows or ubuntu
runner_platform = "azure_devops" # azure_devops or github
resource_group_name = azurerm_resource_group.rg.name
use_existing_resource_group = true
location = azurerm_resource_group.rg.location
virtual_machine_scale_set_name = "runners"
sku = "Standard_D2s_v3"
ssh_public_keys = ["ssh-rsa AAAAB3NzaC1yc2EAAAADA....QFv2PJ0= marius@42device"]
subnet_id = azurerm_subnet.vmss.id
use_custom_subnet = true
vmss_encryption_at_host_enabled = true
}
output "password" {
value = nonsensitive(module.vmss.password)
}
The following providers are used by this module:
The following resources are used by this module:
No required inputs.
The following input variables are optional (have default values):
Description: (Optional) When using the built-in network (use_custom_subnet is false), should we create a NAT gateway? This will be required in the future. Defaults to false.
Type: bool
Default: false
Description: (Optional) Does this Network Interface support Accelerated Networking? Possible values are true and false. Defaults to false.
Type: bool
Default: false
Description: Enable automatic instance repair for the VMSS. This will automatically repair instances that fail health checks.
Type: bool
Default: false
Description: Enable termination notifications for the VMSS. This will send a notification to the Azure Instance Metadata Service (IMDS) when the VMSS is scheduled for maintenance or when the VMSS is deleted.
Type: bool
Default: false
Description: (Optional) If SystemAssigned, UserAssigned or both should be enabled for the Virtual Machine Scale Set
Type:
object({
type = string
identity_ids = optional(list(string))
})
Default: null
Description: (Optional) Value of the backend address pool id to use for the load balancer. I.e. for static outbound NAT.
Type: string
Default: ""
Description: The Azure region to create the scale set in
Type: string
Default: "westeurope"
Description: (Optional) Use an existing network security group on the VMSS network interface card. Defaults to null.
Type: string
Default: null
Description: The OS of the runners
Type: string
Default: "ubuntu"
Description: Password of the local user acocunt
Type: string
Default: null
Description: The resource group name to create
Type: string
Default: "self-hosted-runners"
Description: Whether it is github or azure_devops used for runners
Type: string
Default: "azure_devops"
Description: object({
force_deletion_enabled = (Optional) If true, the VMSS will force delete the VM instance when it is being scaled in. Defaults to false.
rule = (Optional) Scale-in policy for the VMSS. If not provided, the default scale-in policy will be used. Possible values are Default, NewestVM, OldestVM, and Custom. Defaults to Default.
})
Type:
object({
force_deletion_enabled = optional(bool, false)
rule = optional(string, "Default")
})
Default: null
Description: The sku to create virtual machines with
Type: string
Default: "Standard_D2s_v3"
Description: n/a
Type: list(string)
Default: []
Description: When provided, this subnet will be used for the scale set, rather than creating a new virtual network and subnet
Type: string
Default: null
Description: n/a
Type: map(any)
Default: {}
Description: Set to true if subnet_id is provided in order to actually use it (works around a TF issue)
Type: bool
Default: false
Description: Whether to use an existing resource group or not
Type: bool
Default: false
Description: Username of the local user account
Type: string
Default: "runneradmin"
Description: n/a
Type: string
Default: "self-hosted-runners"
Description: Enables encryption at host for the VMSS virtual machines. In order to use this option, the EncryptionAtHost feature must be enabled for Microsoft.Compue resource provider must be enabled for the subscription. To enable, use this PowerShell command: Register-AzProviderFeature -FeatureName 'EncryptionAtHost' -ProviderNamespace 'Microsoft.Compute'.
Type: bool
Default: false
The following outputs are exported:
Description: n/a
Description: n/a
Description: n/a
Description: n/a
No modules.