|
| 1 | +locals { |
| 2 | + device_telnet_configs = flatten([ |
| 3 | + for device in local.devices : [ |
| 4 | + { |
| 5 | + device_name = device.name |
| 6 | + key = "${device.name}-telnet" |
| 7 | + |
| 8 | + ipv4_client_source_interface = try(local.device_config[device.name].telnet.ipv4_client_source_interface, local.defaults.iosxr.configuration.telnet.ipv4_client_source_interface, null) |
| 9 | + ipv6_client_source_interface = try(local.device_config[device.name].telnet.ipv6_client_source_interface, local.defaults.iosxr.configuration.telnet.ipv6_client_source_interface, null) |
| 10 | + |
| 11 | + vrfs = [ |
| 12 | + for vrf in try(local.device_config[device.name].telnet.vrfs, local.defaults.iosxr.configuration.telnet.vrfs, []) : { |
| 13 | + vrf_name = try(vrf.vrf_name, null) |
| 14 | + ipv4_server_max_servers = try(vrf.ipv4_server_max_servers, null) |
| 15 | + ipv4_server_access_list = try(vrf.ipv4_server_access_list, null) |
| 16 | + ipv6_server_max_servers = try(vrf.ipv6_server_max_servers, null) |
| 17 | + ipv6_server_access_list = try(vrf.ipv6_server_access_list, null) |
| 18 | + } |
| 19 | + ] |
| 20 | + |
| 21 | + vrfs_dscp = [ |
| 22 | + for vrf_dscp in try(local.device_config[device.name].telnet.vrfs_dscp, local.defaults.iosxr.configuration.telnet.vrfs_dscp, []) : { |
| 23 | + vrf_name = try(vrf_dscp.vrf_name, null) |
| 24 | + ipv4_dscp = try(vrf_dscp.ipv4_dscp, null) |
| 25 | + } |
| 26 | + ] |
| 27 | + } |
| 28 | + ] if try(local.device_config[device.name].telnet, null) != null || try(local.defaults.iosxr.configuration.telnet, null) != null |
| 29 | + ]) |
| 30 | +} |
| 31 | + |
| 32 | +resource "iosxr_telnet" "telnet" { |
| 33 | + for_each = { for telnet_config in local.device_telnet_configs : telnet_config.key => telnet_config } |
| 34 | + device = each.value.device_name |
| 35 | + |
| 36 | + ipv4_client_source_interface = each.value.ipv4_client_source_interface |
| 37 | + ipv6_client_source_interface = each.value.ipv6_client_source_interface |
| 38 | + vrfs = each.value.vrfs |
| 39 | + vrfs_dscp = each.value.vrfs_dscp |
| 40 | +} |
0 commit comments