Skip to content

Commit

Permalink
Adding new features for profile deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttyso committed Dec 21, 2022
1 parent 8955860 commit db7abeb
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 35 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ A comprehensive example using this module is available here: https://github.com/
| <a name="input_policies"></a> [policies](#input\_policies) | Policies Moids. | `any` | n/a | yes |
| <a name="input_pools"></a> [pools](#input\_pools) | Pool Moids. | `any` | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | List of Key/Value Pairs to Assign as Attributes to the Policy. | `list(map(string))` | `[]` | no |
| <a name="input_time_sleep"></a> [time\_sleep](#input\_time\_sleep) | This is just a dummy place holder to get around the challenge with depends\_on | `string` | n/a | yes |
## Outputs

| Name | Description |
|------|-------------|
| <a name="output_chassis"></a> [chassis](#output\_chassis) | Moid's of the UCS Chassis Profiles. |
| <a name="output_depoy_chassis"></a> [depoy\_chassis](#output\_depoy\_chassis) | n/a |
| <a name="output_server"></a> [server](#output\_server) | Moid's of the UCS Server Profiles. |
| <a name="output_depoy_servers"></a> [depoy\_servers](#output\_depoy\_servers) | n/a |
| <a name="output_chassis"></a> [chassis](#output\_chassis) | Moid and Policies for the Chassis Profiles |
| <a name="output_server"></a> [server](#output\_server) | Moid and Policies for the Server Profiles |
## Resources

| Name | Type |
Expand Down
9 changes: 9 additions & 0 deletions chassis.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ resource "intersight_chassis_profile" "chassis" {
target_platform = each.value.target_platform
type = "instance"
wait_for_completion = each.value.wait_for_completion
lifecycle {
ignore_changes = [
action,
additional_properties,
config_context,
mod_time,
wait_for_completion
]
}
organization {
moid = length(regexall(true, var.moids)
) > 0 ? local.orgs[each.value.organization
Expand Down
68 changes: 38 additions & 30 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,56 @@
# UCS Chassis Profile Outputs
#__________________________________________________________

output "chassis" {
description = "Moid's of the UCS Chassis Profiles."
value = length(local.chassis) > 0 ? { for v in sort(
keys(intersight_chassis_profile.chassis)
) : v => intersight_chassis_profile.chassis[v].moid } : {}
}
#output "chassis" {
# description = "Moid's of the UCS Chassis Profiles."
# value = length(local.chassis) > 0 ? { for v in sort(
# keys(intersight_chassis_profile.chassis)
# ) : v => intersight_chassis_profile.chassis[v].moid } : {}
#}

output "chassis_profiles" {
value = local.chassis
}

output "deploy_chassis" {
output "chassis" {
description = "Moid and Policies for the Chassis Profiles"
value = {
for v in sort(keys(intersight_chassis_profile.chassis)
) : v => intersight_chassis_profile.chassis[v].moid if length(regexall(
"^[A-Z]{3}[2-3][\\d]([0][1-9]|[1-4][0-9]|[5][1-3])[\\dA-Z]{4}$", local.chassis[v].serial_number)
) > 0 && local.chassis[v].action == "Deploy"
for v in sort(keys(intersight_chassis_profile.chassis)) : v => merge({
moid = intersight_chassis_profile.chassis[v].moid
}, local.chassis[v])
}
}
#output "deploy_chassis" {
# value = {
# for v in sort(keys(intersight_chassis_profile.chassis)
# ) : v => intersight_chassis_profile.chassis[v].moid if length(regexall(
# "^[A-Z]{3}[2-3][\\d]([0][1-9]|[1-4][0-9]|[5][1-3])[\\dA-Z]{4}$", local.chassis[v].serial_number)
# ) > 0 && local.chassis[v].action == "Deploy"
# }
#}


#__________________________________________________________
#
# UCS Server Profile Outputs
#__________________________________________________________

output "server" {
description = "Moid's of the UCS Server Profiles."
value = length(lookup(local.profiles, "server", [])) > 0 ? { for v in sort(
keys(intersight_server_profile.server)
) : v => intersight_server_profile.server[v].moid } : {}
}
#output "server" {
# description = "Moid's of the UCS Server Profiles."
# value = length(lookup(local.profiles, "server", [])) > 0 ? { for v in sort(
# keys(intersight_server_profile.server)
# ) : v => intersight_server_profile.server[v].moid } : {}
#}

output "server_profiles" {
value = local.server
}

output "deploy_servers" {
output "server" {
description = "Moid and Policies for the Server Profiles"
value = {
for v in sort(keys(intersight_server_profile.server)
) : v => intersight_server_profile.server[v].moid if length(regexall(
"^[A-Z]{3}[2-3][\\d]([0][1-9]|[1-4][0-9]|[5][1-3])[\\dA-Z]{4}$", local.server[v].serial_number)
) > 0 && local.server[v].action == "Deploy"
for v in sort(keys(intersight_server_profile.server)) : v => merge({
moid = intersight_server_profile.server[v].moid
}, local.server[v])
}
}
#output "deploy_servers" {
# value = {
# for v in sort(keys(intersight_server_profile.server)
# ) : v => intersight_server_profile.server[v].moid if length(regexall(
# "^[A-Z]{3}[2-3][\\d]([0][1-9]|[1-4][0-9]|[5][1-3])[\\dA-Z]{4}$", local.server[v].serial_number)
# ) > 0 && local.server[v].action == "Deploy"
# }
#}
13 changes: 12 additions & 1 deletion server.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,25 @@ resource "intersight_server_profile" "server" {
description = lookup(each.value, "description", "${each.value.name} Server Profile.")
name = each.value.name
server_assignment_mode = length(compact(
[each.value.resource_pool])) > 0 ? "Pool" : each.value.serial_number != "unknown" ? "Static" : "None"
[each.value.resource_pool])) > 0 ? "Pool" : length(regexall(
"^[A-Z]{3}[2-3][\\d]([0][1-9]|[1-4][0-9]|[5][1-3])[\\dA-Z]{4}$", each.value.serial_number)
) > 0 ? "Static" : "None"
static_uuid_address = each.value.static_uuid_address
target_platform = each.value.target_platform
type = "instance"
uuid_address_type = length(
compact([each.value.uuid_pool])
) > 0 ? "POOL" : length(compact([each.value.static_uuid_address])) > 0 ? "STATIC" : "NONE"
wait_for_completion = each.value.wait_for_completion
lifecycle {
ignore_changes = [
action,
config_context,
mod_time,
uuid_lease,
wait_for_completion
]
}
organization {
moid = length(regexall(true, var.moids)
) > 0 ? local.orgs[each.value.organization
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ variable "tags" {
default = []
description = "List of Key/Value Pairs to Assign as Attributes to the Policy."
type = list(map(string))
}

variable "time_sleep" {
description = "This is just a dummy place holder to get around the challenge with depends_on"
type = string
}

0 comments on commit db7abeb

Please sign in to comment.