-
Notifications
You must be signed in to change notification settings - Fork 0
/
domain_template.tf
87 lines (82 loc) · 3.4 KB
/
domain_template.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#__________________________________________________________________________
#
# Intersight Domain Profile Template Resource
# GUI Location: Templates > Create UCS Domain Profile Template
#__________________________________________________________________________
resource "intersight_fabric_switch_cluster_profile_template" "map" {
for_each = { for k, v in local.domain_template : k => v }
description = lookup(each.value, "description", "${each.value.name} Domain Profile Template.")
name = each.value.name
type = "instance"
organization { moid = var.orgs[each.value.org] }
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}
resource "intersight_fabric_switch_profile_template" "map" {
depends_on = [
data.intersight_search_search_item.policies,
data.intersight_search_search_item.pools,
intersight_fabric_switch_cluster_profile_template.map
]
for_each = { for k, v in local.switch_templates : k => v if v.create_template == true }
description = each.value.description
name = each.value.name
lifecycle { ignore_changes = [action, config_context, mod_time] }
switch_cluster_profile_template { moid = intersight_fabric_switch_cluster_profile_template.map[each.value.domain_template].moid }
switch_id = each.value.switch_id
dynamic "policy_bucket" {
for_each = { for v in each.value.policy_bucket : v.object_type => v if element(split("/", v.name), 1) != "UNUSED" }
content {
moid = contains(keys(lookup(local.policies, policy_bucket.value.policy, {})), policy_bucket.value.name
) == true ? local.policies[policy_bucket.value.policy][policy_bucket.value.name] : local.policies_data[policy_bucket.value.policy][policy_bucket.value.name].moid
object_type = policy_bucket.value.object_type
}
}
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}
resource "intersight_bulk_mo_merger" "trigger_domain_profile_update" {
depends_on = [intersight_fabric_switch_cluster_profile.map]
for_each = { for k, v in local.domain : k => v if v.attach_template == true }
merge_action = "Merge"
lifecycle { ignore_changes = all }
sources {
class_id = "fabric.SwitchClusterProfileTemplate"
object_type = "fabric.SwitchClusterProfileTemplate"
moid = local.ucs_templates.domain[each.value.ucs_domain_profile_template].moid
}
targets {
class_id = "fabric.SwitchClusterProfile"
object_type = "fabric.SwitchClusterProfile"
moid = intersight_fabric_switch_cluster_profile.map[each.key].moid
}
}
resource "intersight_bulk_mo_merger" "trigger_switch_profile_update" {
depends_on = [
intersight_bulk_mo_merger.trigger_domain_profile_update,
intersight_fabric_switch_profile.map
]
for_each = { for k, v in local.switch_profiles : k => v if v.attach_template == true }
merge_action = "Merge"
lifecycle { ignore_changes = all }
sources {
class_id = "fabric.SwitchProfileTemplate"
object_type = "fabric.SwitchProfileTemplate"
moid = local.ucs_templates.switch[each.value.ucs_switch_profile_template].moid
}
targets {
class_id = "fabric.SwitchProfile"
object_type = "fabric.SwitchProfile"
moid = intersight_fabric_switch_profile.map[each.key].moid
}
}