-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
206 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,58 @@ | ||
# domain_vlan_map - Intersight UCS Domain Fabric VLAN Terraform Module | ||
|
||
## Usage | ||
|
||
```hcl | ||
module "vlan_map" { | ||
source = "terraform-cisco-modules/imm/intersight//modules/domain_vlan_map" | ||
# omitted... | ||
} | ||
``` | ||
|
||
This module will create a Fabric VLAN List in Intersight. This can be used assign VLANs to a VLAN Policy. | ||
|
||
These resources are consumed | ||
|
||
* [vlan](https://registry.terraform.io/providers/CiscoDevNet/intersight/latest/docs/data-sources/fabric_vlan) | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
|
||
No requirements. | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_intersight"></a> [intersight](#provider\_intersight) | n/a | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [intersight_fabric_vlan.vlan_list](https://registry.terraform.io/providers/CiscoDevNet/intersight/latest/docs/resources/fabric_vlan) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_auto_allow_on_uplinks"></a> [auto\_allow\_on\_uplinks](#input\_auto\_allow\_on\_uplinks) | Used to determine whether this VLAN will be allowed on all uplink ports and PCs in this FI. | `bool` | `true` | no | | ||
| <a name="input_is_native"></a> [is\_native](#input\_is\_native) | Used to determine if this VLAN should be untagged on the interfaces. | `bool` | `false` | no | | ||
| <a name="input_multicast_moid"></a> [multicast\_moid](#input\_multicast\_moid) | Multicast Policy moid map. | `string` | n/a | yes | | ||
| <a name="input_tags"></a> [tags](#input\_tags) | List of Tag Attributes to Assign to the Policy. | `list(map(string))` | `[]` | no | | ||
| <a name="input_vlan_list"></a> [vlan\_list](#input\_vlan\_list) | n/a | `string` | `"2-10,21-30"` | no | | ||
| <a name="input_vlan_policy_moid"></a> [vlan\_policy\_moid](#input\_vlan\_policy\_moid) | VLAN Policy (Ethernet Network Policy) moid. | `string` | n/a | yes | | ||
| <a name="input_vlan_prefix"></a> [vlan\_prefix](#input\_vlan\_prefix) | Prefix Name for VLANs. | `string` | `"VLAN"` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_moid"></a> [moid](#output\_moid) | Fabric VLAN Managed Object ID (moid). | | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains 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,28 @@ | ||
#____________________________________________________________ | ||
# | ||
# Intersight Fabric VLAN List | ||
# GUI Location: Policies > Create Policy | ||
#____________________________________________________________ | ||
|
||
resource "intersight_fabric_vlan" "vlan_map" { | ||
for_each = {for k, v in var.vlan_map : k => v } | ||
auto_allow_on_uplinks = var.auto_allow_on_uplinks | ||
is_native = var.is_native | ||
name = length(regexall("^[0-9]{4}$", each.value.vlan_id)) > 0 ? join("-vl", [ | ||
each.value.prefix, each.value.vlan_id | ||
]) : length(regexall("^[0-9]{3}$", each.value.vlan_id)) > 0 ? join("-vl0", [ | ||
each.value.prefix, each.value.vlan_id | ||
]) : length(regexall("^[0-9]{2}$", each.value.vlan_id)) > 0 ? join("-vl00", [ | ||
each.value.prefix, each.value.vlan_id | ||
]) : join("-vl000", [ | ||
each.value.prefix, each.value.vlan_id | ||
] | ||
) | ||
vlan_id = each.value.vlan_id | ||
eth_network_policy { | ||
moid = var.vlan_policy_moid | ||
} | ||
multicast_policy { | ||
moid = var.multicast_moid | ||
} | ||
} |
This file contains 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,9 @@ | ||
#____________________________________________________________ | ||
# | ||
# Collect the moid of the Fabric VLAN as an Output | ||
#____________________________________________________________ | ||
|
||
output "moid" { | ||
description = "Fabric VLAN Managed Object ID (moid)." | ||
value = { for v in sort(keys(intersight_fabric_vlan.vlan_map)) : v => intersight_fabric_vlan.vlan_map[v].moid } | ||
} |
This file contains 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,13 @@ | ||
#_______________________________________________________________________ | ||
# | ||
# Terraform Required Parameters - Intersight Provider | ||
# https://registry.terraform.io/providers/CiscoDevNet/intersight/latest | ||
#_______________________________________________________________________ | ||
|
||
terraform { | ||
required_providers { | ||
intersight = { | ||
source = "CiscoDevNet/intersight" | ||
} | ||
} | ||
} |
This file contains 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,74 @@ | ||
#____________________________________________________________ | ||
# | ||
# UCS Domain VLANs Variables Section. | ||
#____________________________________________________________ | ||
|
||
variable "apikey" { | ||
description = "Intersight API Key." | ||
sensitive = true | ||
type = string | ||
} | ||
|
||
variable "endpoint" { | ||
default = "https://intersight.com" | ||
description = "Intersight URL." | ||
type = string | ||
} | ||
|
||
variable "secretkey" { | ||
description = "Intersight Secret Key." | ||
sensitive = true | ||
type = string | ||
} | ||
|
||
variable "auto_allow_on_uplinks" { | ||
default = true | ||
description = "Used to determine whether this VLAN will be allowed on all uplink ports and PCs in this FI." | ||
type = bool | ||
} | ||
|
||
variable "is_native" { | ||
default = false | ||
description = "Used to determine if this VLAN should be untagged on the interfaces." | ||
type = bool | ||
} | ||
|
||
variable "multicast_moid" { | ||
description = "Multicast Policy moid map." | ||
type = string | ||
} | ||
|
||
variable "tags" { | ||
default = [] | ||
description = "List of Tag Attributes to Assign to the Policy." | ||
type = list(map(string)) | ||
} | ||
|
||
variable "vlan_map" { | ||
description = <<-EOT | ||
This VLAN Map should contain key/value pairs of prefix and vlan_id. In Example: | ||
vlan_map = [ | ||
{ | ||
prefix = "test" | ||
vlan_id = 123 | ||
}, | ||
{ | ||
prefix = "test" | ||
vlan_id = 124 | ||
} | ||
] | ||
This will be configured as test-vl0123 and test-vl0124 in intersight. | ||
EOT | ||
type = list(map(string)) | ||
} | ||
|
||
variable "vlan_prefix" { | ||
default = "VLAN" | ||
description = "Prefix Name for VLANs." | ||
type = string | ||
} | ||
|
||
variable "vlan_policy_moid" { | ||
description = "VLAN Policy (Ethernet Network Policy) moid." | ||
type = string | ||
} |