Skip to content

Commit 5fd7cb6

Browse files
Development1704 (#7)
* add redeploy to template * add support for multple interfaces under l3_handoffs * update changelog * fix fabric_role in border * add time sleep to provision_device
1 parent 4b858ab commit 5fd7cb6

4 files changed

Lines changed: 44 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## 0.0.3-beta1 (unreleased)
22

3+
- BREAKING CHANGE: add support for multple interfaces under l3_handoffs
4+
- Add redeploy option to templates
5+
- Add non fabric device provisioning
6+
- Update banner settings to use allow banner settings to be assigned to Global area
37
- BREAKING CHANGE: rename `catalystcenter_fabric_port_assignment` to `catalystcenter_fabric_port_assignments`
48
- Fix issue with assiging same L3 VN to multiple fabric_sites
59
- Removed `network_profile` dependencies for deploying templates

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ module "catalystcenter" {
123123
| [catalystcenter_wireless_ssid.ssid](https://registry.terraform.io/providers/CiscoDevNet/catalystcenter/latest/docs/resources/wireless_ssid) | resource |
124124
| [local_sensitive_file.defaults](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/sensitive_file) | resource |
125125
| [terraform_data.validation](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
126+
| [time_sleep.provision_device_wait](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
126127
| [time_sleep.template_wait](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
127128
| [catalystcenter_area.global](https://registry.terraform.io/providers/CiscoDevNet/catalystcenter/latest/docs/data-sources/area) | data source |
128129
| [catalystcenter_credentials_cli.cli_credentials](https://registry.terraform.io/providers/CiscoDevNet/catalystcenter/latest/docs/data-sources/credentials_cli) | data source |

cc_device_provision.tf

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,23 @@ locals {
2424
l3_handoffs_ip_transit = flatten([
2525
for border_device in try(local.catalyst_center.fabric.border_devices, []) : [
2626
for transit in try(border_device.l3_handoffs, []) : [
27-
for vn in try(transit.virtual_networks) : {
28-
key = format("%s/%s/%s", vn.name, border_device.name, transit.name)
29-
transit_name = try(transit.name, null)
30-
device_name = try(border_device.name, null)
31-
device_ip = try(local.all_devices[border_device.name].device_ip, null)
32-
interface_name = try(transit.interface_name, null)
33-
virtual_network_name = try(vn.name, null)
34-
vlan_id = try(vn.vlan, null)
35-
local_ip_address = try(vn.local_ip_address, null)
36-
local_ipv6_address = try(vn.local_ipv6_address, null)
37-
peer_ipv6_address = try(vn.peer_ipv6_address, null)
38-
peer_ip_address = try(vn.peer_ip_address, null)
39-
tcp_mss_adjustment = try(vn.tcp_mss_adjustment, null)
40-
external_handoff_pool = try(border_device.external_handoff_pool, null)
41-
}
27+
for interface in try(transit.interfaces, []) : [
28+
for vn in try(interface.virtual_networks) : {
29+
key = format("%s/%s/%s/%s", vn.name, interface.name, transit.name, border_device.name)
30+
transit_name = try(transit.name, null)
31+
device_name = try(border_device.name, null)
32+
device_ip = try(local.all_devices[border_device.name].device_ip, null)
33+
interface_name = try(interface.name, null)
34+
virtual_network_name = try(vn.name, null)
35+
vlan_id = try(vn.vlan, null)
36+
local_ip_address = try(vn.local_ip_address, null)
37+
local_ipv6_address = try(vn.local_ipv6_address, null)
38+
peer_ipv6_address = try(vn.peer_ipv6_address, null)
39+
peer_ip_address = try(vn.peer_ip_address, null)
40+
tcp_mss_adjustment = try(vn.tcp_mss_adjustment, null)
41+
external_handoff_pool = try(border_device.external_handoff_pool, null)
42+
}
43+
]
4244
]
4345
]
4446
])
@@ -61,6 +63,10 @@ locals {
6163
l2_handoff_vlan_id_map = {
6264
for item in local.anycast_gateways : item.vlan_name => catalystcenter_anycast_gateway.anycast_gateway[item.name].vlan_id if try(item.vlan_name, null) != null
6365
}
66+
67+
provisioned_devices = [
68+
for device in try(local.catalyst_center.inventory.devices, []) : device if strcontains(device.state, "PROVISION")
69+
]
6470
}
6571

6672
data "catalystcenter_network_devices" "all_devices" {
@@ -88,7 +94,7 @@ resource "catalystcenter_fabric_provision_device" "non_fabric_device" {
8894
}
8995

9096
resource "catalystcenter_fabric_provision_device" "border_device" {
91-
for_each = { for device in try(local.catalyst_center.inventory.devices, []) : device.name => device if strcontains(device.state, "PROVISION") && device.device_role == "BORDER ROUTER" }
97+
for_each = { for device in try(local.catalyst_center.inventory.devices, []) : device.name => device if strcontains(device.state, "PROVISION") && device.device_role == "BORDER ROUTER" && try(device.fabric_roles, null) != null }
9298

9399
site_id = try(local.site_id_list[each.value.site], null)
94100
network_device_id = lookup(local.device_ip_to_id, each.value.device_ip, "")
@@ -225,5 +231,13 @@ resource "catalystcenter_fabric_port_assignments" "port_assignments" {
225231
network_device_id = try(local.device_ip_to_id[each.value.device_ip], "")
226232
port_assignments = try(local.device_port_assignments[each.key], null)
227233

228-
depends_on = [catalystcenter_fabric_device.edge_device, catalystcenter_fabric_device.border_device, catalystcenter_fabric_provision_device.edge_device, catalystcenter_fabric_provision_device.edge_device, catalystcenter_anycast_gateway.anycast_gateway]
234+
depends_on = [catalystcenter_fabric_device.edge_device, catalystcenter_fabric_device.border_device, catalystcenter_fabric_provision_device.edge_device, catalystcenter_anycast_gateway.anycast_gateway]
229235
}
236+
237+
resource "time_sleep" "provision_device_wait" {
238+
count = length(try(local.provisioned_devices, [])) > 0 ? 1 : 0
239+
240+
create_duration = "10s"
241+
242+
depends_on = [catalystcenter_fabric_provision_device.edge_device, catalystcenter_wireless_device_provision.wireless_controller, catalystcenter_fabric_provision_device.non_fabric_device, catalystcenter_fabric_provision_device.border_device]
243+
}

cc_templates.tf

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ locals {
5757

5858
combined_templates = flatten([
5959
for device in try(local.catalyst_center.inventory.devices, []) : [
60-
for template in try(device.dayn_templates.regular, []) : [
60+
for template in concat(try(device.dayn_templates.regular, []), try(device.dayn_templates.composite, [])) : [
6161
{
6262
"template" : try(template.name, null),
6363
"name" : try(device.name, null),
6464
"state" : try(device.state, null),
6565
"device_ip" : try(device.device_ip, null)
66-
"deploy" : try(template.deploy, false)
66+
"deploy_state" : try(template.state, null)
6767
}
6868
]
6969
]
@@ -187,8 +187,9 @@ resource "catalystcenter_template_version" "composite_commit_version" {
187187
}
188188

189189
resource "catalystcenter_deploy_template" "regular_template_deploy" {
190-
for_each = { for d in try(local.combined_templates, []) : "${d.name}#_#${d.template}" => d if try(local.templates_map[d.template].composite, false) == false && local.templates_map[d.template].template_type == "dayn" && strcontains(d.state, "PROVISION") && try(d.deploy, false) == true }
190+
for_each = { for d in try(local.combined_templates, []) : "${d.name}#_#${d.template}" => d if try(local.templates_map[d.template].composite, false) == false && local.templates_map[d.template].template_type == "dayn" && strcontains(d.state, "PROVISION") && strcontains(d.deploy_state, "DEPLOY") }
191191

192+
redeploy = try(each.value.deploy_state, null) == "REDEPLOY" ? true : false
192193
template_id = catalystcenter_template.regular_template[each.value.template].id
193194
force_push_template = try(local.templates_map[each.value.template].force_push_template, local.defaults.catalyst_center.templates.force_push_template, null)
194195
is_composite = false
@@ -211,12 +212,13 @@ resource "catalystcenter_deploy_template" "regular_template_deploy" {
211212
}
212213
]
213214

214-
depends_on = [catalystcenter_device_role.role, catalystcenter_fabric_provision_device.edge_device, catalystcenter_fabric_provision_device.border_device, catalystcenter_fabric_provision_device.non_fabric_device]
215+
depends_on = [catalystcenter_device_role.role, catalystcenter_fabric_provision_device.edge_device, catalystcenter_fabric_provision_device.border_device, catalystcenter_fabric_provision_device.non_fabric_device, time_sleep.provision_device_wait]
215216
}
216217

217218
resource "catalystcenter_deploy_template" "composite_template_deploy" {
218-
for_each = { for d in try(local.combined_templates, []) : "${d.name}#_#${d.template}" => d if try(local.templates_map[d.template].composite, false) == true && local.templates_map[d.template].template_type == "dayn" && strcontains(d.state, "PROVISION") && try(d.deploy, false) == true }
219+
for_each = { for d in try(local.combined_templates, []) : "${d.name}#_#${d.template}" => d if try(local.templates_map[d.template].composite, false) == true && local.templates_map[d.template].template_type == "dayn" && strcontains(d.state, "PROVISION") && strcontains(d.deploy_state, "DEPLOY") }
219220

221+
redeploy = try(each.value.deploy_state, null) == "REDEPLOY" ? true : false
220222
template_id = catalystcenter_template_version.composite_commit_version[each.value.template].id
221223
main_template_id = catalystcenter_template.composite_template[each.value.template].id
222224
force_push_template = try(local.templates_map[each.value.template].force_push_template, local.defaults.catalyst_center.templates.force_push_template, null)
@@ -261,5 +263,5 @@ resource "catalystcenter_deploy_template" "composite_template_deploy" {
261263
}
262264
]
263265

264-
depends_on = [catalystcenter_device_role.role, catalystcenter_fabric_provision_device.edge_device, catalystcenter_fabric_provision_device.border_device, catalystcenter_fabric_provision_device.non_fabric_device]
266+
depends_on = [catalystcenter_device_role.role, catalystcenter_fabric_provision_device.edge_device, catalystcenter_fabric_provision_device.border_device, catalystcenter_fabric_provision_device.non_fabric_device, time_sleep.provision_device_wait]
265267
}

0 commit comments

Comments
 (0)