-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathndo_deploy_templates.tf
More file actions
137 lines (123 loc) · 6.74 KB
/
ndo_deploy_templates.tf
File metadata and controls
137 lines (123 loc) · 6.74 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
locals {
unmanaged_schemas = [for schema in try(local.ndo.schemas, []) : schema if !var.manage_schemas && var.deploy_templates && !var.manage_tenant_templates]
deploy_templates = flatten([
for schema in concat(local.schemas, local.unmanaged_schemas) : [
for template in try(schema.templates, {}) : {
key = "${schema.name}/${template.name}"
schema_name = schema.name
template_name = template.name
deploy_order = try(template.deploy_order, 1)
}
]
])
}
resource "mso_schema_template_deploy_ndo" "template" {
for_each = { for template in local.deploy_templates : template.key => template if var.deploy_templates && template.deploy_order == 1 }
schema_id = var.manage_schemas ? mso_schema.schema[each.value.schema_name].id : local.schema_ids[each.value.schema_name].id
template_name = each.value.template_name
undeploy_on_destroy = true
depends_on = [
mso_schema.schema,
mso_schema_site.schema_site,
mso_schema_site.schema_site1,
mso_schema_site.schema_site2,
mso_schema_site.schema_site3,
mso_schema_template_filter_entry.schema_template_filter_entry,
mso_schema_template_contract.schema_template_contract,
mso_rest.schema_site_contract,
mso_schema_template_contract_service_graph.schema_template_contract_service_graph,
mso_schema_site_contract_service_graph.schema_site_contract_service_graph,
mso_schema_template_vrf.schema_template_vrf,
mso_schema_site_vrf.schema_site_vrf,
mso_schema_template_vrf_contract.schema_template_vrf_contract,
mso_schema_site_vrf_region.schema_site_vrf_region,
mso_schema_template_bd.schema_template_bd,
mso_schema_site_bd.schema_site_bd,
mso_schema_template_bd_subnet.schema_template_bd_subnet,
mso_schema_site_bd_subnet.schema_site_bd_subnet,
mso_schema_site_bd_l3out.schema_site_bd_l3out,
mso_schema_template_anp.schema_template_anp,
mso_schema_site_anp.schema_site_anp,
mso_schema_template_anp_epg.schema_template_anp_epg,
mso_schema_site_anp_epg.schema_site_anp_epg,
mso_schema_template_anp_epg_contract.schema_template_anp_epg_contract,
mso_schema_template_anp_epg_subnet.schema_template_anp_epg_subnet,
mso_schema_site_anp_epg_subnet.schema_site_anp_epg_subnet,
mso_schema_site_anp_epg_bulk_staticport.schema_site_anp_epg_bulk_staticport,
mso_schema_site_anp_epg_static_leaf.schema_site_anp_epg_static_leaf,
mso_schema_site_anp_epg_domain.schema_site_anp_epg_domain_physical,
mso_schema_site_anp_epg_domain.schema_site_anp_epg_domain_vmware,
mso_schema_site_anp_epg_selector.schema_site_anp_epg_selector,
mso_schema_template_l3out.schema_template_l3out,
mso_schema_template_external_epg.schema_template_external_epg,
mso_schema_template_external_epg_contract.schema_template_external_epg_contract,
mso_schema_template_external_epg_subnet.schema_template_external_epg_subnet,
mso_schema_template_external_epg_selector.schema_template_external_epg_selector,
mso_schema_site_external_epg.schema_site_external_epg,
mso_schema_site_external_epg_selector.schema_site_external_epg_selector,
mso_schema_template_service_graph.schema_template_service_graph,
mso_schema_site_service_graph.schema_site_service_graph,
mso_rest.schema_site_service_graph,
mso_rest.provider_redirect_policy,
mso_rest.consumer_redirect_policy,
]
}
resource "mso_schema_template_deploy_ndo" "template2" {
for_each = { for template in local.deploy_templates : template.key => template if var.deploy_templates && template.deploy_order == 2 }
schema_id = var.manage_schemas ? mso_schema.schema[each.value.schema_name].id : local.schema_ids[each.value.schema_name].id
template_name = each.value.template_name
undeploy_on_destroy = true
depends_on = [mso_schema_template_deploy_ndo.template]
}
resource "mso_schema_template_deploy_ndo" "template3" {
for_each = { for template in local.deploy_templates : template.key => template if var.deploy_templates && template.deploy_order == 3 }
schema_id = var.manage_schemas ? mso_schema.schema[each.value.schema_name].id : local.schema_ids[each.value.schema_name].id
template_name = each.value.template_name
undeploy_on_destroy = true
depends_on = [
mso_schema_template_deploy_ndo.template,
mso_schema_template_deploy_ndo.template2,
]
}
locals {
unmanaged_templates = [for template in try(local.ndo.tenant_templates.tenant_policies, []) : template if !var.manage_tenant_templates && var.deploy_templates && !var.manage_schemas]
deploy_tenant_templates = flatten([
for template in try(concat(local.tenant_templates, local.unmanaged_templates), {}) : {
key = template.name
template_name = template.name
deploy_order = try(template.deploy_order, 1)
}
])
}
resource "mso_schema_template_deploy_ndo" "tenant_template" {
for_each = { for template in local.deploy_tenant_templates : template.key => template if var.deploy_templates && template.deploy_order == 1 }
template_id = var.manage_tenant_templates ? mso_template.tenant_template[each.value.template_name].id : local.template_ids[each.value.template_name].id
template_type = "tenant"
template_name = each.value.template_name
undeploy_on_destroy = true
depends_on = [
mso_template.tenant_template,
mso_tenant_policies_dhcp_relay_policy.tenant_policies_dhcp_relay_policy,
mso_tenant_policies_ipsla_monitoring_policy.tenant_policies_ipsla_monitoring_policy,
mso_tenant_policies_route_map_policy_multicast.tenant_policies_route_map_policy_multicast,
]
}
resource "mso_schema_template_deploy_ndo" "tenant_template2" {
for_each = { for template in local.deploy_tenant_templates : template.key => template if var.deploy_templates && template.deploy_order == 2 }
template_id = var.manage_tenant_templates ? mso_template.tenant_template[each.value.template_name].id : local.template_ids[each.value.template_name].id
template_type = "tenant"
template_name = each.value.template_name
undeploy_on_destroy = true
depends_on = [mso_schema_template_deploy_ndo.tenant_template]
}
resource "mso_schema_template_deploy_ndo" "tenant_template3" {
for_each = { for template in local.deploy_tenant_templates : template.key => template if var.deploy_templates && template.deploy_order == 3 }
template_id = var.manage_tenant_templates ? mso_template.tenant_template[each.value.template_name].id : local.template_ids[each.value.template_name].id
template_type = "tenant"
template_name = each.value.template_name
undeploy_on_destroy = true
depends_on = [
mso_schema_template_deploy_ndo.tenant_template,
mso_schema_template_deploy_ndo.tenant_template2,
]
}