From 4d9ec613d288fe99ae1315a994331967f1b78f85 Mon Sep 17 00:00:00 2001 From: erzetpe Date: Tue, 22 Mar 2022 08:22:56 +0100 Subject: [PATCH] Define additional disks with defined sizes to VMs for Azure (#2953) * Additional disks for azure DRAFT * Simplify config * add changelog note * Change starting index value in names * Change value of lun attribute to alling with disks indexing --- docs/changelogs/CHANGELOG-2.0.md | 1 + .../infrastructure/virtual-machine.yml | 5 ++++- .../azure/infrastructure/virtual-machine.j2 | 22 +++++++++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/changelogs/CHANGELOG-2.0.md b/docs/changelogs/CHANGELOG-2.0.md index f797ddeae4..e22782eaad 100644 --- a/docs/changelogs/CHANGELOG-2.0.md +++ b/docs/changelogs/CHANGELOG-2.0.md @@ -18,6 +18,7 @@ - [#2975](https://github.com/epiphany-platform/epiphany/issues/2975) - Copy only required files - [#2991](https://github.com/epiphany-platform/epiphany/issues/2991) - Add automatic backup creation for download requirements - [#2448](https://github.com/epiphany-platform/epiphany/issues/2448) - Passwordless SSH communication for postgres user between DB nodes +- [#2888](https://github.com/epiphany-platform/epiphany/issues/2888) - Define additional disks with defined sizes to VMs for Azure ### Fixed diff --git a/schema/azure/defaults/infrastructure/virtual-machine.yml b/schema/azure/defaults/infrastructure/virtual-machine.yml index 9ce95b5d8b..2adb93fc8c 100644 --- a/schema/azure/defaults/infrastructure/virtual-machine.yml +++ b/schema/azure/defaults/infrastructure/virtual-machine.yml @@ -11,7 +11,7 @@ specification: network_interface_name: SET_BY_AUTOMATION availability_set_name: SET_BY_AUTOMATION # Please don't change this default value, keep it "SET_BY_AUTOMATION" use_network_security_groups: SET_BY_AUTOMATION - security_group_association_name: SET_BY_AUTOMATION + security_group_association_name: SET_BY_AUTOMATION tags: [] os_type: linux size: Standard_DS1_v2 @@ -28,6 +28,9 @@ specification: create_option: FromImage disk_size_gb: 32 managed_disk_type: Premium_LRS + additional_disks: [] + # - storage_account_type: Premium_LRS + # disk_size_gb: 32 network_interface: enable_accelerated_networking: false private_ip: diff --git a/terraform/azure/infrastructure/virtual-machine.j2 b/terraform/azure/infrastructure/virtual-machine.j2 index dec4e7eb8b..ea5c222887 100644 --- a/terraform/azure/infrastructure/virtual-machine.j2 +++ b/terraform/azure/infrastructure/virtual-machine.j2 @@ -82,6 +82,24 @@ resource "azurerm_virtual_machine" "{{ specification.name }}" { depends_on = [azurerm_network_interface_security_group_association.{{ specification.security_group_association_name }}] {%- endif %} - #TODO: - # storage_data_disk } + +{%- if specification.additional_disks is defined %} + {%- for disk in specification.additional_disks %} +resource "azurerm_managed_disk" "{{ specification.name }}-data-disk-{{ loop.index0 }}" { + name = "{{ specification.name }}-data-disk-{{ loop.index0 }}" + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + storage_account_type = "{{ disk.storage_account_type }}" + create_option = "Empty" + disk_size_gb = "{{ disk.disk_size_gb }}" +} + +resource "azurerm_virtual_machine_data_disk_attachment" "{{ specification.name }}-disk-attachment-{{ loop.index0 }}" { + managed_disk_id = azurerm_managed_disk.{{ specification.name }}-data-disk-{{ loop.index0 }}.id + virtual_machine_id = azurerm_virtual_machine.{{ specification.name }}.id + lun = "{{ loop.index0 }}" + caching = "ReadWrite" +} + {%- endfor %} +{%- endif %}