Merge pull request #464 from amro-acc/fix.bootstrap_order

Upload Blob to Storage account to be used as VM extension
This commit is contained in:
lolorol 2023-05-11 16:54:37 +08:00 коммит произвёл GitHub
Родитель 4772b8edb1 b872b399ef
Коммит f31d6dfc0e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 25 добавлений и 14 удалений

Просмотреть файл

@ -14,18 +14,8 @@ resource "azurerm_virtual_machine_extension" "devops_selfhosted_agent" {
#timestamp: use this field only to trigger a re-run of the script by changing value of this field.
# Any integer value is acceptable; it must only be different than the previous value.
settings = jsonencode(
{
"timestamp" : each.value.version,
"fileUris" : concat(local.devops_selfhosted_agent.file_uris, local.devops_selfhosted_agent.storage_account_blobs_urls),
}
)
protected_settings = jsonencode(
{
"commandToExecute" : format("bash %s '%s' '%s' '%s' '%s' '%s' '%s' '%s'", var.extensions[each.key].agent_init_script, var.settings[each.key].azure_devops.url, var.settings[each.key].agent_pat, var.settings[each.key].azure_devops.agent_pool.name, var.settings[each.key].azure_devops.agent_pool.agent_name_prefix, var.settings[each.key].azure_devops.agent_pool.num_agents, var.settings[each.key].admin_username, var.settings[each.key].azure_devops.rover_version)
}
)
settings = jsonencode(local.settings)
protected_settings = jsonencode(local.protected_settings)
}
@ -41,4 +31,18 @@ locals {
storage_account_blobs_urls = try(var.settings.devops_selfhosted_agent.storage_account_blobs_urls, [])
}
}
settings = {
timestamp = var.extensions.devops_selfhosted_agent.version
fileUris = concat(local.devops_selfhosted_agent.file_uris, local.devops_selfhosted_agent.storage_account_blobs_urls)
}
protected_settings = {
commandToExecute = format("bash %s '%s' '%s' '%s' '%s' '%s' '%s' '%s'", var.extensions["devops_selfhosted_agent"].agent_init_script, var.settings["devops_selfhosted_agent"].azure_devops.url, var.settings["devops_selfhosted_agent"].agent_pat, var.settings["devops_selfhosted_agent"].azure_devops.agent_pool.name, var.settings["devops_selfhosted_agent"].azure_devops.agent_pool.agent_name_prefix, var.settings["devops_selfhosted_agent"].azure_devops.agent_pool.num_agents, var.settings["devops_selfhosted_agent"].admin_username, var.settings["devops_selfhosted_agent"].azure_devops.rover_version)
managedIdentity = can(var.settings.devops_selfhosted_agent.managed_identity) ? {
objectId = var.settings.devops_selfhosted_agent.managed_identity
} : {}
}
}

Просмотреть файл

@ -7,7 +7,7 @@ terraform {
}
random = {
source = "hashicorp/random"
version = "~> 2.2.1"
version = "~> 3.3.1"
}
null = {
source = "hashicorp/null"

Просмотреть файл

@ -61,6 +61,9 @@ variable "mssql_servers" {
variable "storage_accounts" {
default = {}
}
variable "storage_containers" {
default = {}
}
variable "storage_account_blobs" {
default = {}
}
@ -103,3 +106,6 @@ variable "dynamic_keyvault_secrets" {
variable "managed_identities" {
default = {}
}
variable "var_folder_path" {
default = null
}

Просмотреть файл

@ -33,6 +33,7 @@ module "vm_extensions" {
[
for key, value in try(var.storage_account_blobs, []) : module.caf.storage_account_blobs[key].url
])
managed_identity = can(each.value.virtual_machine_extensions.devops_selfhosted_agent.managed_identity.lz_key) ? local.remote.managed_identities[each.value.virtual_machine_extensions.devops_selfhosted_agent.managed_identity.lz_key][each.value.virtual_machine_extensions.devops_selfhosted_agent.managed_identity.key].rbac_id : module.caf.managed_identities[each.value.virtual_machine_extensions.devops_selfhosted_agent.managed_identity.key].rbac_id
}
}
}