Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/OctopusSamples/IaC
Browse files Browse the repository at this point in the history
  • Loading branch information
twerthi committed Aug 16, 2023
2 parents 68e7cef + 1b63290 commit 5110309
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 2.93.1" # example: 0.7.62
#version = ">= 2.93.1" # example: 0.7.62
version = ">=3.5.0"
}
}

Expand Down
26 changes: 23 additions & 3 deletions octopus-samples-instances/shared-workers-terraform/azure/azure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ resource "azurerm_subnet" "octopus-samples-workers-subnet" {
]
}

// Define user managed identity
resource "azurerm_user_assigned_identity" "database-admin" {
location = var.octopus_azure_location
resource_group_name = var.octopus_azure_resourcegroup_name

name = "samples-database-admin"

depends_on = [ azurerm_resource_group.octopus-samples-azure-workers ]
}

// Define azure scale set
resource "azurerm_linux_virtual_machine_scale_set" "samples-azure-workers" {
name = var.octopus_azure_scaleset_name
Expand All @@ -42,12 +52,14 @@ resource "azurerm_linux_virtual_machine_scale_set" "samples-azure-workers" {
user_data = "${base64encode(file("../configure-tentacle.sh"))}"

identity {
type = "SystemAssigned"
#type = "SystemAssigned"
type = "UserAssigned"
identity_ids = [azurerm_user_assigned_identity.database-admin.id]
}

source_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
offer = "0001-com-ubuntu-server-jammy"
sku = var.octopus_azure_vm_sku
version = "latest"
}
Expand All @@ -68,6 +80,8 @@ resource "azurerm_linux_virtual_machine_scale_set" "samples-azure-workers" {
}
}
tags = var.tags

depends_on = [ azurerm_user_assigned_identity.database-admin ]
}

# Create Windows worker
Expand All @@ -82,6 +96,8 @@ resource "azurerm_network_interface" "windows-worker-nic" {
}
}



resource "azurerm_windows_virtual_machine" "samples-windows-worker" {
name = var.octopus_azure_windows_worker_name
location = var.octopus_azure_location
Expand Down Expand Up @@ -109,10 +125,14 @@ resource "azurerm_windows_virtual_machine" "samples-windows-worker" {
#custom_data = "${base64encode(file("../configure-tentacle.ps1"))}"

identity {
type = "SystemAssigned"
#type = "SystemAssigned"
type = "UserAssigned"
identity_ids = [azurerm_user_assigned_identity.database-admin.id]
}

tags = var.tags

depends_on = [ azurerm_user_assigned_identity.database-admin ]
}

resource "azurerm_virtual_machine_extension" "bootstrap-script" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ catch
}

# Install .net 4.8
choco install dotnetfx
#choco install dotnetfx -y

# Use chocolaty to install tentacle
choco install octopusdeploy.tentacle -y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ sudo apt-get install awscli -y
# Install .NET 6
sudo apt-get install dotnet-sdk-6.0 -y

# Install az CLI
sudo apt-get update
sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg

sudo mkdir -p /etc/apt/keyrings
curl -sLS https://packages.microsoft.com/keys/microsoft.asc |
gpg --dearmor |
sudo tee /etc/apt/keyrings/microsoft.gpg > /dev/null
sudo chmod go+r /etc/apt/keyrings/microsoft.gpg

AZ_REPO=$(lsb_release -cs)
echo "deb [arch=`dpkg --print-architecture` signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" |
sudo tee /etc/apt/sources.list.d/azure-cli.list

sudo apt-get update
sudo apt-get install azure-cli

# Pull worker tools image
sudo docker pull #{Project.Docker.WorkerToolImage}:#{Project.Docker.WorkerToolImageTag}

Expand Down

0 comments on commit 5110309

Please sign in to comment.