Skip to content

Commit

Permalink
Merge pull request #13 from OctopusSamples/update-bootstrap-script
Browse files Browse the repository at this point in the history
Update bootstrap script
  • Loading branch information
twerthi authored Jul 31, 2023
2 parents 3bd2ba9 + e6bf552 commit 1b63290
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 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
25 changes: 18 additions & 7 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,12 +96,7 @@ resource "azurerm_network_interface" "windows-worker-nic" {
}
}

resource "azurerm_user_assigned_identity" "database-admin" {
location = var.octopus_azure_location
resource_group_name = var.octopus_azure_resourcegroup_name

name = "samples-database-admin"
}

resource "azurerm_windows_virtual_machine" "samples-windows-worker" {
name = var.octopus_azure_windows_worker_name
Expand Down Expand Up @@ -122,6 +131,8 @@ resource "azurerm_windows_virtual_machine" "samples-windows-worker" {
}

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

0 comments on commit 1b63290

Please sign in to comment.