Skip to content

Commit

Permalink
Add target version to update groups
Browse files Browse the repository at this point in the history
  • Loading branch information
danischm committed May 24, 2024
1 parent 286ee70 commit ec1b88b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
7 changes: 4 additions & 3 deletions aci_node_policies.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ module "aci_firmware_group" {
module "aci_maintenance_group" {
source = "./modules/terraform-aci-maintenance-group"

for_each = { for np in try(local.node_policies.update_groups, {}) : np.name => np if local.modules.aci_maintenance_group && var.manage_node_policies }
name = "${each.value.name}${local.defaults.apic.node_policies.update_groups.name_suffix}"
node_ids = [for node in try(local.node_policies.nodes, []) : node.id if try(node.update_group, "") == each.value.name]
for_each = { for np in try(local.node_policies.update_groups, {}) : np.name => np if local.modules.aci_maintenance_group && var.manage_node_policies }
name = "${each.value.name}${local.defaults.apic.node_policies.update_groups.name_suffix}"
target_version = try(each.value.target_version, "")
node_ids = [for node in try(local.node_policies.nodes, []) : node.id if try(node.update_group, "") == each.value.name]
}

module "aci_vpc_group" {
Expand Down
1 change: 1 addition & 0 deletions modules/terraform-aci-maintenance-group/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module "aci_maintenance_group" {
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_name"></a> [name](#input\_name) | Maintenance group name. | `string` | n/a | yes |
| <a name="input_target_version"></a> [target\_version](#input\_target\_version) | Target version. | `string` | `""` | no |
| <a name="input_node_ids"></a> [node\_ids](#input\_node\_ids) | List of node IDs. Minimum value: 1. Maximum value: 4000. | `list(number)` | `[]` | no |

## Outputs
Expand Down
1 change: 1 addition & 0 deletions modules/terraform-aci-maintenance-group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ resource "aci_rest_managed" "maintMaintP" {
graceful = "no"
notifCond = "notifyOnlyOnFailures"
runMode = "pauseOnlyOnFailures"
version = var.target_version != "" ? var.target_version : null
}
}

Expand Down
11 changes: 11 additions & 0 deletions modules/terraform-aci-maintenance-group/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ variable "name" {
}
}

variable "target_version" {
description = "Target version."
type = string
default = ""

validation {
condition = can(regex("n\\d+-\\d+\\.\\d+\\(\\w+\\)", var.name))
error_message = "Invalid version number."
}
}

variable "node_ids" {
description = "List of node IDs. Minimum value: 1. Maximum value: 4000."
type = list(number)
Expand Down

0 comments on commit ec1b88b

Please sign in to comment.