From da256dd612e0c64d31589bab272663cbb06be839 Mon Sep 17 00:00:00 2001 From: Sean Larimore Date: Fri, 10 Mar 2023 21:41:26 +0000 Subject: [PATCH] add license_key feature --- README.md | 1 + .../avi-cloud-services-registration.yml.tpl | 10 ++++++++- ...avi-controller-gcp-all-in-one-play.yml.tpl | 22 ++++++++++++++++++- gcp-compute.tf | 1 + variables.tf | 5 +++++ 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fed409a..a6b8680 100644 --- a/README.md +++ b/README.md @@ -311,6 +311,7 @@ No modules. | [firewall\_controller\_allow\_source\_range](#input\_firewall\_controller\_allow\_source\_range) | The IP range allowed to connect to the Avi Controller. Access from all IP ranges will be allowed by default | `string` | `"0.0.0.0/0"` | no | | [firewall\_se\_data\_rules](#input\_firewall\_se\_data\_rules) | The ports allowed for Virtual Services hosted on Services Engines. The configure\_firewall\_se\_data variable must be set to true for this rule to be created | `list(object({ protocol = string, port = list(string) }))` |
[
{
"port": [
"443",
"53"
],
"protocol": "tcp"
},
{
"port": [
"53"
],
"protocol": "udp"
}
]
| no | | [firewall\_se\_data\_source\_range](#input\_firewall\_se\_data\_source\_range) | The IP range allowed to access Virtual Services hosted on Service Engines. The configure\_firewall\_se\_data and firewall\_se\_data\_rules variables must also be set | `string` | `"0.0.0.0/0"` | no | +| [license\_key](#input\_license\_key) | The license key that will be applied when the tier is set to ENTERPRISE with the license\_tier variable | `string` | `""` | no | | [license\_tier](#input\_license\_tier) | The license tier to use for Avi. Possible values are ENTERPRISE\_WITH\_CLOUD\_SERVICES or ENTERPRISE | `string` | `"ENTERPRISE_WITH_CLOUD_SERVICES"` | no | | [name\_prefix](#input\_name\_prefix) | This prefix is appended to the names of the Controller and SEs | `string` | n/a | yes | | [network\_project](#input\_network\_project) | The GCP Network project that the Controller and SEs will use. If not set the project variable will be used | `string` | `""` | no | diff --git a/files/ansible/avi-cloud-services-registration.yml.tpl b/files/ansible/avi-cloud-services-registration.yml.tpl index d9911bb..9615b36 100644 --- a/files/ansible/avi-cloud-services-registration.yml.tpl +++ b/files/ansible/avi-cloud-services-registration.yml.tpl @@ -55,4 +55,12 @@ until: register_controller is not failed retries: 10 delay: 10 - register: register_controller \ No newline at end of file + register: register_controller + + - name: Delete Trial Avi License when Controller is registered successfully + avi_api_session: + avi_credentials: "{{ avi_credentials }}" + http_method: delete + path: "licensing/Eval" + when: register_controller is not failed + ignore_errors: yes \ No newline at end of file diff --git a/files/ansible/avi-controller-gcp-all-in-one-play.yml.tpl b/files/ansible/avi-controller-gcp-all-in-one-play.yml.tpl index 8a736f0..8569f8f 100644 --- a/files/ansible/avi-controller-gcp-all-in-one-play.yml.tpl +++ b/files/ansible/avi-controller-gcp-all-in-one-play.yml.tpl @@ -18,6 +18,7 @@ api_version: ${avi_version} cloud_name: "Default-Cloud" license_tier: ${license_tier} + license_key: ${license_key} controller_ip: ${ indent(6, yamlencode(controller_ip))} %{ if cluster_ip != null ~} @@ -122,7 +123,26 @@ redirect_to_https: true use_uuid_from_input: false welcome_workflow_complete: true - + + - name: Apply Avi License for ENTERPRISE Tier + avi_api_session: + avi_credentials: "{{ avi_credentials }}" + http_method: put + path: "licensing" + data: + serial_key: "{{ license_key }}" + when: license_tier == "ENTERPRISE" and license_key != "" + register: license + ignore_errors: yes + + - name: Delete Trial Avi License when license is added successfully + avi_api_session: + avi_credentials: "{{ avi_credentials }}" + http_method: delete + path: "licensing/Eval" + when: license_tier == "ENTERPRISE" and license_key != "" and license.failed != true + ignore_errors: yes + - name: Configure Cloud avi_cloud: avi_credentials: "{{ avi_credentials }}" diff --git a/gcp-compute.tf b/gcp-compute.tf index 35b04b9..425e4b1 100644 --- a/gcp-compute.tf +++ b/gcp-compute.tf @@ -31,6 +31,7 @@ locals { avi_upgrade = var.avi_upgrade cluster_ip = var.cluster_ip license_tier = var.license_tier + license_key = var.license_key } controller_sizes = { small = "custom-8-24576" diff --git a/variables.tf b/variables.tf index 9d96eae..bd03c8f 100644 --- a/variables.tf +++ b/variables.tf @@ -11,6 +11,11 @@ variable "license_tier" { error_message = "The license_tier variable must be ENTERPRISE_WITH_CLOUD_SERVICES or ENTERPRISE." } } +variable "license_key" { + description = "The license key that will be applied when the tier is set to ENTERPRISE with the license_tier variable" + type = string + default = "" +} variable "cluster_ip" { description = "Sets the IP address of the Avi Controller cluster. This address must be in the same subnet as the Avi Controller VMs." type = string