-
Notifications
You must be signed in to change notification settings - Fork 6
Added VPC configuration support #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tobiwang
wants to merge
28
commits into
netascode:main
Choose a base branch
from
tobiwang:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
8f63370
make interface group variables interpolation work
tobiwang 2774160
make config template variables interpolation work with precedence: de…
tobiwang 6089389
Merge pull request #1 from tobiwang/fix_interface_group
tobiwang 030ade9
Merge branch 'main' into fix_configuration_template
tobiwang d0e31d8
Merge pull request #2 from tobiwang/fix_configuration_template
tobiwang 5210bdc
fix variables interpolation for interface_groups and configuration_te…
tobiwang 0943aeb
fix variables interpolation with precedence: device-level > interface…
tobiwang ec7563e
fix configuration_template variable interpolation
tobiwang b4a52ba
Removing interface_group level variables support
tobiwang d744219
reuse device_variables
tobiwang 462d2d4
fix interface_groups_config with re-using device_variables
tobiwang b02c5e5
reuse device_variables
tobiwang 89b0381
fix interface_groups_config with re-using device_variables
tobiwang 0008660
fix variable names with using plural
tobiwang 1b6ba59
Merge branch 'main_reduce_vars' into main
tobiwang 9f83cb1
Merge branch 'main' of github.com:tobiwang/terraform-nxos-nac-nxos in…
tobiwang 345c966
fix README.md
tobiwang bd1792e
feat: Add comprehensive VPC (Virtual Port Channel) support
tobiwang bb15c1a
fix interface_port_channel ospf
tobiwang 26b6214
fix interface_port_channel ospf
tobiwang 24668e0
fix virtual peerlink
tobiwang 74fb5f5
fix
tobiwang 0391603
fix
tobiwang 1ad6412
fix yamllint error issue of defaults.yaml
tobiwang c36b3e7
re-order vpc related resources
tobiwang d7c839d
using null (omit) as a last resort instead of hardcording
tobiwang 9e7f4aa
vpc_domain in defaults.yaml
tobiwang 7418dc5
fix defaults value reference
tobiwang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,3 +38,5 @@ defaults: | |
| additive: false | ||
| no_community: false | ||
| set_criteria: none | ||
| vpc_domains: | ||
| admin_state: true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| locals { | ||
| vpc_domains = flatten([ | ||
| for device in local.devices : [ | ||
| { | ||
| key = format("%s/%s", device.name, local.device_config[device.name].vpc_domain.domain_id) | ||
| device = device.name | ||
| domain_id = try(local.device_config[device.name].vpc_domain.domain_id, local.defaults.nxos.devices.configuration.vpc_domains.domain_id, null) | ||
| admin_state = try(local.device_config[device.name].vpc_domain.admin_state, local.defaults.nxos.devices.configuration.vpc_domains.admin_state, true) | ||
| auto_recovery = try(local.device_config[device.name].vpc_domain.auto_recovery, local.defaults.nxos.devices.configuration.vpc_domains.auto_recovery, false) | ||
| auto_recovery_interval = try(local.device_config[device.name].vpc_domain.auto_recovery_interval, local.defaults.nxos.devices.configuration.vpc_domains.auto_recovery_interval, null) | ||
| delay_restore_orphan_port = try(local.device_config[device.name].vpc_domain.delay_restore_orphan_port, local.defaults.nxos.devices.configuration.vpc_domains.delay_restore_orphan_port, null) | ||
| delay_restore_svi = try(local.device_config[device.name].vpc_domain.delay_restore_svi, local.defaults.nxos.devices.configuration.vpc_domains.delay_restore_svi, null) | ||
| delay_restore_vpc = try(local.device_config[device.name].vpc_domain.delay_restore_vpc, local.defaults.nxos.devices.configuration.vpc_domains.delay_restore_vpc, null) | ||
| dscp = try(local.device_config[device.name].vpc_domain.dscp, local.defaults.nxos.devices.configuration.vpc_domains.dscp, null) | ||
| fast_convergence = try(local.device_config[device.name].vpc_domain.fast_convergence, local.defaults.nxos.devices.configuration.vpc_domains.fast_convergence, false) | ||
| graceful_consistency_check = try(local.device_config[device.name].vpc_domain.graceful_consistency_check, local.defaults.nxos.devices.configuration.vpc_domains.graceful_consistency_check, false) | ||
| l3_peer_router = try(local.device_config[device.name].vpc_domain.l3_peer_router, local.defaults.nxos.devices.configuration.vpc_domains.l3_peer_router, null) | ||
| l3_peer_router_syslog = try(local.device_config[device.name].vpc_domain.l3_peer_router_syslog, local.defaults.nxos.devices.configuration.vpc_domains.l3_peer_router_syslog, false) | ||
| l3_peer_router_syslog_interval = try(local.device_config[device.name].vpc_domain.l3_peer_router_syslog_interval, local.defaults.nxos.devices.configuration.vpc_domains.l3_peer_router_syslog_interval, null) | ||
| peer_gateway = try(local.device_config[device.name].vpc_domain.peer_gateway, local.defaults.nxos.devices.configuration.vpc_domains.peer_gateway, false) | ||
| virtual_peerlink_destination_ip = try(local.device_config[device.name].vpc_domain.virtual_peerlink_destination_ip, local.defaults.nxos.devices.configuration.vpc_domains.virtual_peerlink_destination_ip, null) | ||
| peer_switch = try(local.device_config[device.name].vpc_domain.peer_switch, local.defaults.nxos.devices.configuration.vpc_domains.peer_switch, false) | ||
| role_priority = try(local.device_config[device.name].vpc_domain.role_priority, local.defaults.nxos.devices.configuration.vpc_domains.role_priority, null) | ||
| system_mac = try(upper(local.device_config[device.name].vpc_domain.system_mac), upper(local.defaults.nxos.devices.configuration.vpc_domains.system_mac), null) | ||
| system_priority = try(local.device_config[device.name].vpc_domain.system_priority, local.defaults.nxos.devices.configuration.vpc_domains.system_priority, null) | ||
| track = try(local.device_config[device.name].vpc_domain.track, local.defaults.nxos.devices.configuration.vpc_domains.track, null) | ||
| virtual_peerlink_source_ip = try(local.device_config[device.name].vpc_domain.virtual_peerlink_source_ip, local.defaults.nxos.devices.configuration.vpc_domains.virtual_peerlink_source_ip, null) | ||
| peer_keepalive = try(local.device_config[device.name].vpc_domain.peer_keepalive, {}) | ||
| } | ||
| ] if try(local.device_config[device.name].vpc_domain, null) != null | ||
| ]) | ||
| } | ||
|
|
||
| resource "nxos_vpc_instance" "vpc_instance" { | ||
| for_each = { for vpc_domain in local.vpc_domains : vpc_domain.key => vpc_domain } | ||
| device = each.value.device | ||
| admin_state = each.value.admin_state ? "enabled" : "disabled" | ||
|
|
||
| depends_on = [ | ||
| nxos_feature_vpc.vpc | ||
| ] | ||
| } | ||
|
|
||
| resource "nxos_vpc_domain" "vpc_domain" { | ||
| for_each = { for vpc_domain in local.vpc_domains : vpc_domain.key => vpc_domain } | ||
| device = each.value.device | ||
| domain_id = each.value.domain_id | ||
| admin_state = each.value.admin_state ? "enabled" : "disabled" | ||
| auto_recovery = each.value.auto_recovery ? "enabled" : "disabled" | ||
| auto_recovery_interval = each.value.auto_recovery_interval | ||
| delay_restore_orphan_port = each.value.delay_restore_orphan_port | ||
| delay_restore_svi = each.value.delay_restore_svi | ||
| delay_restore_vpc = each.value.delay_restore_vpc | ||
| dscp = each.value.dscp | ||
| fast_convergence = each.value.fast_convergence ? "enabled" : "disabled" | ||
| graceful_consistency_check = each.value.graceful_consistency_check ? "enabled" : "disabled" | ||
| l3_peer_router = each.value.l3_peer_router ? "enabled" : "disabled" | ||
| l3_peer_router_syslog = each.value.l3_peer_router_syslog ? "enabled" : "disabled" | ||
| l3_peer_router_syslog_interval = each.value.l3_peer_router_syslog_interval | ||
| peer_gateway = each.value.peer_gateway ? "enabled" : "disabled" | ||
| peer_ip = each.value.virtual_peerlink_destination_ip | ||
| peer_switch = each.value.peer_switch ? "enabled" : "disabled" | ||
| role_priority = each.value.role_priority | ||
| sys_mac = each.value.system_mac | ||
| system_priority = each.value.system_priority | ||
| track = each.value.track | ||
| virtual_ip = each.value.virtual_peerlink_source_ip | ||
|
|
||
| depends_on = [ | ||
| nxos_vpc_instance.vpc_instance | ||
| ] | ||
| } | ||
|
|
||
| locals { | ||
| vpc_keepalives = flatten([ | ||
| for device in local.devices : [ | ||
| { | ||
| key = format("%s/%s", device.name, local.device_config[device.name].vpc_domain.domain_id) | ||
| device = device.name | ||
| destination_ip = try(local.device_config[device.name].vpc_domain.peer_keepalive.destination_ip, local.defaults.nxos.devices.configuration.vpc_domains.peer_keepalive.destination_ip, null) | ||
| source_ip = try(local.device_config[device.name].vpc_domain.peer_keepalive.source_ip, local.defaults.nxos.devices.configuration.vpc_domains.peer_keepalive.source_ip, null) | ||
| flush_timeout = try(local.device_config[device.name].vpc_domain.peer_keepalive.flush_timeout, local.defaults.nxos.devices.configuration.vpc_domains.peer_keepalive.flush_timeout, null) | ||
| interval = try(local.device_config[device.name].vpc_domain.peer_keepalive.interval, local.defaults.nxos.devices.configuration.vpc_domains.peer_keepalive.interval, null) | ||
| precedence_type = try(local.device_config[device.name].vpc_domain.peer_keepalive.precedence_type, local.defaults.nxos.devices.configuration.vpc_domains.peer_keepalive.precedence_type, null) | ||
| precedence_value = try(local.device_config[device.name].vpc_domain.peer_keepalive.precedence_value, local.defaults.nxos.devices.configuration.vpc_domains.peer_keepalive.precedence_value, null) | ||
| timeout = try(local.device_config[device.name].vpc_domain.peer_keepalive.timeout, local.defaults.nxos.devices.configuration.vpc_domains.peer_keepalive.timeout, null) | ||
| type_of_service_byte = try(local.device_config[device.name].vpc_domain.peer_keepalive.type_of_service_byte, local.defaults.nxos.devices.configuration.vpc_domains.peer_keepalive.type_of_service_byte, null) | ||
| type_of_service_configuration_type = try(local.device_config[device.name].vpc_domain.peer_keepalive.type_of_service_configuration_type, local.defaults.nxos.devices.configuration.vpc_domains.peer_keepalive.type_of_service_configuration_type, null) | ||
| type_of_service_type = try(local.device_config[device.name].vpc_domain.peer_keepalive.type_of_service_type, local.defaults.nxos.devices.configuration.vpc_domains.peer_keepalive.type_of_service_type, null) | ||
| type_of_service_value = try(local.device_config[device.name].vpc_domain.peer_keepalive.type_of_service_value, local.defaults.nxos.devices.configuration.vpc_domains.peer_keepalive.type_of_service_value, null) | ||
| udp_port = try(local.device_config[device.name].vpc_domain.peer_keepalive.udp_port, local.defaults.nxos.devices.configuration.vpc_domains.peer_keepalive.udp_port, null) | ||
| vrf = try(local.device_config[device.name].vpc_domain.peer_keepalive.vrf, local.defaults.nxos.devices.configuration.vpc_domains.peer_keepalive.vrf, null) | ||
| } | ||
| ] if try(local.device_config[device.name].vpc_domain, null) != null && try(local.device_config[device.name].vpc_domain.peer_keepalive, null) != null | ||
| ]) | ||
| } | ||
|
|
||
| resource "nxos_vpc_keepalive" "vpc_keepalive" { | ||
| for_each = { for vpc_keepalive in local.vpc_keepalives : vpc_keepalive.key => vpc_keepalive } | ||
| device = each.value.device | ||
| destination_ip = each.value.destination_ip | ||
| source_ip = each.value.source_ip | ||
| flush_timeout = each.value.flush_timeout | ||
| interval = each.value.interval | ||
| precedence_type = each.value.precedence_type | ||
| precedence_value = each.value.precedence_value | ||
| timeout = each.value.timeout | ||
| type_of_service_byte = each.value.type_of_service_byte | ||
| type_of_service_configuration_type = each.value.type_of_service_configuration_type | ||
| type_of_service_type = each.value.type_of_service_type | ||
| type_of_service_value = each.value.type_of_service_value | ||
| udp_port = each.value.udp_port | ||
| vrf = each.value.vrf | ||
|
|
||
| depends_on = [ | ||
| nxos_vpc_domain.vpc_domain | ||
| ] | ||
| } | ||
|
|
||
| locals { | ||
| vpc_peerlinks = flatten([ | ||
| for device in local.devices : [ | ||
| for int in try(local.device_config[device.name].interfaces.port_channels, []) : { | ||
| key = format("%s/%s", device.name, int.id) | ||
| device = device.name | ||
| port_channel_id = int.id | ||
| } if try(int.vpc_peerlink, false) == true | ||
| ] | ||
| ]) | ||
| } | ||
|
|
||
| resource "nxos_vpc_peerlink" "vpc_peerlink" { | ||
| for_each = { for peerlink in local.vpc_peerlinks : peerlink.key => peerlink } | ||
| device = each.value.device | ||
| port_channel_id = format("po%s", each.value.port_channel_id) | ||
|
|
||
| depends_on = [ | ||
| nxos_vpc_keepalive.vpc_keepalive | ||
| ] | ||
| } | ||
|
|
||
| locals { | ||
| vpc_interfaces_port_channels = flatten([ | ||
| for device in local.devices : [ | ||
| for int in try(local.device_config[device.name].interfaces.port_channels, []) : { | ||
| key = format("%s/%s", device.name, int.id) | ||
| device = device.name | ||
| vpc_interface_id = int.vpc_id | ||
| port_channel_interface_dn = format("sys/intf/aggr-[po%s]", int.id) | ||
| } if try(int.vpc_id, null) != null && try(int.vpc_peerlink, false) == false | ||
| ] | ||
| ]) | ||
| } | ||
|
|
||
| resource "nxos_vpc_interface" "vpc_interface" { | ||
| for_each = { for int in local.vpc_interfaces_port_channels : int.key => int } | ||
| device = each.value.device | ||
| vpc_interface_id = each.value.vpc_interface_id | ||
| port_channel_interface_dn = each.value.port_channel_interface_dn | ||
|
|
||
| depends_on = [ | ||
| nxos_vpc_domain.vpc_domain, | ||
| nxos_port_channel_interface.port_channel_interface | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preferably we do not hardcode default values in the code but rather define them in defaults.yaml and use "null" (omit) as a last resort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with the 'return null' principle.