Created
May 8, 2024 07:05
-
-
Save vrabbi/55467ecb64ac25ff0dbf732a5ddc39f4 to your computer and use it in GitHub Desktop.
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
- name: Wait for VIP Network in NSX ALB | |
ansible.builtin.pause: | |
seconds: 30 | |
when: (nsx_alb_cloud_type == 'CLOUD_NSXT') and (segment.type == 'vips') | |
- name: Set Fact - Intialize subnet configuration array | |
ansible.builtin.set_fact: | |
configured_subnets: [] | |
- name: Set Fact - Subnet configuration for VIP network | |
ansible.builtin.set_fact: | |
configured_subnets: | |
- prefix: | |
ip_addr: | |
addr: "{{ segment.subnet.split('/')[0] }}" | |
type: V4 | |
mask: "{{ segment.subnet.split('/')[1] }}" | |
static_ip_ranges: | |
- type: STATIC_IPS_FOR_VIP | |
range: | |
begin: | |
addr: "{{ segment.ip_range.split('-')[0] }}" | |
type: "V4" | |
end: | |
addr: "{{ segment.ip_range.split('-')[1] }}" | |
type: "V4" | |
when: segment.type == 'vips' | |
- name: Set Fact - Subnet configuration for node network | |
ansible.builtin.set_fact: | |
configured_subnets: | |
- prefix: | |
ip_addr: | |
addr: "{{ segment.subnet.split('/')[0] }}" | |
type: V4 | |
mask: "{{ segment.subnet.split('/')[1] }}" | |
when: segment.type == 'nodes' | |
- name: Configure Network in NSX ALB (NSX-T Cloud) | |
vmware.alb.avi_network: | |
avi_credentials: "{{ nsx_alb_credentials }}" | |
avi_api_update_method: patch | |
avi_api_patch_op: add | |
name: "{{ tkg_cluster_name }}-{{ segment.type }}" | |
cloud_ref: "{{ nsx_alb_cloud_ref }}" | |
vrf_context_ref: "{{ nsx_alb_vrf_context.obj.url }}" | |
dhcp_enabled: true | |
configured_subnets: "{{ configured_subnets }}" | |
when: nsx_alb_cloud_type == 'CLOUD_NSXT' | |
- name: Configure Network in NSX ALB (vSphere Cloud) | |
vmware.alb.avi_network: | |
avi_credentials: "{{ nsx_alb_credentials }}" | |
avi_api_update_method: patch | |
avi_api_patch_op: add | |
name: "{{ tkg_cluster_name }}-{{ segment.tier }}" | |
cloud_ref: "{{ nsx_alb_cloud_ref }}" | |
dhcp_enabled: true | |
configured_subnets: "{{ configured_subnets }}" | |
when: nsx_alb_cloud_type == 'CLOUD_VCENTER' |
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
--- | |
- name: Get NSX-T Edge Cluster ID | |
vmware.ansible_for_nsxt.nsxt_rest: | |
hostname: "{{ nsxt_vip }}" | |
username: "{{ nsxt_username }}" | |
password: "{{ nsxt_password }}" | |
validate_certs: false | |
method: get | |
path: "/api/v1/search?query=resource_type:EdgeCluster%20AND%20display_name:{{ edge_cluster_name }}" | |
register: nsxt_edge_cluster | |
- name: Set Fact - NSX-T Edge Cluster ID | |
ansible.builtin.set_fact: | |
edge_cluster_id: "{{ nsxt_edge_cluster.body.results[0].id }}" | |
- name: Set Fact - NSX-T Tier1 Gateway name | |
ansible.builtin.set_fact: | |
tier1_gateway_name: "{{ tkg_cluster_name }}-t1" | |
- name: NSX-T Tier1 Gateway | |
vmware.ansible_for_nsxt.nsxt_policy_tier1: | |
hostname: "{{ nsxt_vip }}" | |
username: "{{ nsxt_username }}" | |
password: "{{ nsxt_password }}" | |
validate_certs: false | |
state: present | |
display_name: "{{ tier1_gateway_name }}" | |
tier0_display_name: "{{ tier0_gateway_name }}" | |
route_advertisement_types: "{{ tier1_gateway_route_advertisement_types }}" | |
locale_services: | |
- state: present | |
display_name: "{{ tier1_gateway_name }}-ls" | |
edge_cluster_info: | |
edge_cluster_display_name: "{{ edge_cluster_name }}" | |
failover_mode: NON_PREEMPTIVE | |
tags: | |
- scope: tkg-cluster | |
tag: "{{ tkg_cluster_name }}" | |
- name: NSX-T DHCP Server Config for Segments | |
vmware.ansible_for_nsxt.nsxt_rest: | |
hostname: "{{ nsxt_vip }}" | |
username: "{{ nsxt_username }}" | |
password: "{{ nsxt_password }}" | |
validate_certs: false | |
method: patch | |
path: "/policy/api/v1/infra/dhcp-server-configs/{{ tkg_cluster_name }}-{{ segment.type }}" | |
content: | | |
{ | |
"server_address": "{{ segment.dhcp_server_address }}", | |
"server_addresses": ["{{ segment.dhcp_server_address }}"], | |
"edge_cluster_path": "/infra/sites/default/enforcement-points/default/edge-clusters/{{ edge_cluster_id }}" | |
} | |
loop: "{{ segments }}" | |
loop_control: | |
loop_var: segment | |
when: segment.type == 'vips' | |
- name: NSX-T Segments - Nodes | |
vmware.ansible_for_nsxt.nsxt_policy_segment: | |
hostname: "{{ nsxt_vip }}" | |
username: "{{ nsxt_username }}" | |
password: "{{ nsxt_password }}" | |
validate_certs: false | |
state: present | |
display_name: "{{ tkg_cluster_name }}-nodes" | |
tier1_display_name: "{{ tier1_gateway_name }}" | |
transport_zone_display_name: "{{ transport_zone_name }}" | |
subnets: | |
- gateway_address: "{{ segment.gateway_address }}" | |
tags: | |
- scope: tkg-cluster | |
tag: "{{ tkg_cluster_name }}" | |
loop: "{{ segments }}" | |
loop_control: | |
loop_var: segment | |
when: segment.type == 'nodes' | |
- name: NSX-T Segments - VIPs | |
vmware.ansible_for_nsxt.nsxt_policy_segment: | |
hostname: "{{ nsxt_vip }}" | |
username: "{{ nsxt_username }}" | |
password: "{{ nsxt_password }}" | |
validate_certs: false | |
state: present | |
display_name: "{{ tkg_cluster_name }}-vips" | |
dhcp_config_path: "/infra/dhcp-server-configs/{{ tkg_cluster_name }}-vips" | |
tier1_display_name: "{{ tier1_gateway_name }}" | |
transport_zone_display_name: "{{ transport_zone_name }}" | |
subnets: | |
- gateway_address: "{{ segment.gateway_address }}" | |
dhcp_config: | |
resource_type: SegmentDhcpV4Config | |
dns_servers: "{{ dns_servers }}" | |
server_address: "{{ segment.dhcp_server_address }}" | |
lease_time: 86400 | |
options: | |
others: | |
- code: 42 | |
values: "{{ ntp_servers }}" | |
dhcp_ranges: | |
- "{{ segment.dhcp_range }}" | |
tags: | |
- scope: tkg-cluster | |
tag: "{{ tkg_cluster_name }}" | |
loop: "{{ segments }}" | |
loop_control: | |
loop_var: segment | |
when: segment.type == 'vips' | |
- name: Create Tier Groups | |
vmware.ansible_for_nsxt.nsxt_policy_group: | |
hostname: "{{ nsxt_vip }}" | |
username: "{{ nsxt_username }}" | |
password: "{{ nsxt_password }}" | |
validate_certs: false | |
id: "{{ tkg_cluster_name }}-{{ machine_deployment.tier }}" | |
display_name: "{{ tkg_cluster_name }}-{{ machine_deployment.tier }}" | |
state: "present" | |
domain_id: "default" | |
expression: | |
- member_type: "VirtualMachine" | |
value: "{{ tkg_cluster_name }}-{{ machine_deployment.tier }}-" | |
key: "Name" | |
operator: "STARTSWITH" | |
resource_type: "Condition" | |
loop: "{{ machine_deployments }}" | |
loop_control: | |
loop_var: machine_deployment | |
- name: Create Cluster Group | |
vmware.ansible_for_nsxt.nsxt_policy_group: | |
hostname: "{{ nsxt_vip }}" | |
username: "{{ nsxt_username }}" | |
password: "{{ nsxt_password }}" | |
validate_certs: false | |
id: "{{ tkg_cluster_name }}-all-nodes" | |
display_name: "{{ tkg_cluster_name }}-all-nodes" | |
state: "present" | |
domain_id: "default" | |
expression: | |
- member_type: "VirtualMachine" | |
value: "{{ tkg_cluster_name }}-" | |
key: "Name" | |
operator: "STARTSWITH" | |
resource_type: "Condition" | |
- name: Create Cluster Control Plane Group | |
vmware.ansible_for_nsxt.nsxt_policy_group: | |
hostname: "{{ nsxt_vip }}" | |
username: "{{ nsxt_username }}" | |
password: "{{ nsxt_password }}" | |
validate_certs: false | |
id: "{{ tkg_cluster_name }}-control-plane-nodes" | |
display_name: "{{ tkg_cluster_name }}-control-plane-nodes" | |
state: "present" | |
domain_id: "default" | |
expression: | |
- member_type: "VirtualMachine" | |
value: "{{ tkg_cluster_name }}-controlplane-" | |
key: "Name" | |
operator: "STARTSWITH" | |
resource_type: "Condition" | |
- name: Set Fact - NSX ALB Credentials | |
ansible.builtin.set_fact: | |
nsx_alb_credentials: | |
controller: "{{ nsx_alb_controller }}" | |
username: "{{ nsx_alb_username }}" | |
password: "{{ nsx_alb_password }}" | |
api_version: "{{ nsx_alb_api_version }}" | |
- name: Create NSX ALB IPAM Profile | |
vmware.alb.avi_ipamdnsproviderprofile: | |
avi_credentials: "{{ nsx_alb_credentials }}" | |
name: "{{ nsx_alb_ipam_profile_name }}" | |
type: IPAMDNS_TYPE_INTERNAL | |
- name: Get NSX ALB Cloud | |
ansible.builtin.uri: | |
url: "https://{{ nsx_alb_credentials.controller }}/api/cloud?name={{ nsx_alb_cloud_name }}" | |
validate_certs: false | |
url_username: "{{ nsx_alb_credentials.username }}" | |
url_password: "{{ nsx_alb_credentials.password }}" | |
force_basic_auth: true | |
method: GET | |
return_content: true | |
headers: | |
Content-Type: application/json | |
X-Avi-Version: "{{ nsx_alb_credentials.api_version }}" | |
register: nsx_alb_cloud | |
- name: Set Fact - NSX ALB Cloud object properties | |
ansible.builtin.set_fact: | |
nsx_alb_cloud_ref: "{{ nsx_alb_cloud.json.results[0].url }}?name={{ nsx_alb_cloud.json.results[0].name }}" | |
nsx_alb_cloud_type: "{{ nsx_alb_cloud.json.results[0].vtype }}" | |
nsx_alb_cloud_uuid: "{{ nsx_alb_cloud.json.results[0].uuid }}" | |
- name: Wait for Networks in NSX ALB | |
ansible.builtin.pause: | |
seconds: 30 | |
when: nsx_alb_cloud_type == 'CLOUD_VCENTER' | |
- name: Configure NSX ALB NSX-T Cloud | |
block: | |
- name: Set Fact - NSX ALB NSX-T Cloud Object | |
ansible.builtin.set_fact: | |
nsx_alb_cloud_json: "{{ nsx_alb_cloud.json.results[0] }}" | |
- name: Set Fact - NSX ALB Cloud Object Data Network Config | |
ansible.builtin.set_fact: | |
nsx_alb_cloud_json_addition: | |
nsxt_configuration: | |
data_network_config: | |
tier1_segment_config: | |
manual: | |
tier1_lrs: | |
- tier1_lr_id: "/infra/tier-1s/{{ tier1_gateway_name }}" | |
segment_id: "/infra/segments/{{ tkg_cluster_name }}-vips" | |
- name: Set Fact - Update NSX-T Cloud JSON Object | |
ansible.builtin.set_fact: | |
nsx_alb_cloud_json: "{{ nsx_alb_cloud_json | combine(nsx_alb_cloud_json_addition, recursive=true, list_merge='append_rp') }}" | |
- name: Update NSX ALB Cloud Object | |
ansible.builtin.uri: | |
url: "https://{{ nsx_alb_credentials.controller }}/api/cloud/{{ nsx_alb_cloud_uuid }}" | |
validate_certs: false | |
url_username: "{{ nsx_alb_credentials.username }}" | |
url_password: "{{ nsx_alb_credentials.password }}" | |
force_basic_auth: true | |
method: PUT | |
body: "{{ nsx_alb_cloud_json }}" | |
body_format: json | |
return_content: true | |
headers: | |
Content-Type: application/json | |
X-Avi-Version: "{{ nsx_alb_credentials.api_version }}" | |
when: nsx_alb_cloud_type == 'CLOUD_NSXT' | |
- name: Create VRF Context in NSX ALB | |
vmware.alb.avi_vrfcontext: | |
avi_credentials: "{{ nsx_alb_credentials }}" | |
avi_api_update_method: patch | |
avi_api_patch_op: add | |
name: "{{ tier1_gateway_name }}" | |
cloud_ref: "{{ nsx_alb_cloud_ref }}" | |
register: nsx_alb_vrf_context | |
when: nsx_alb_cloud_type == 'CLOUD_NSXT' | |
- include_tasks: configure_nsxalb_networks.yml | |
loop: "{{ segments }}" | |
loop_control: | |
loop_var: segment | |
- name: Get NSX ALB IPAM Profile | |
ansible.builtin.uri: | |
url: "https://{{ nsx_alb_credentials.controller }}/api/ipamdnsproviderprofile?name={{ nsx_alb_ipam_profile_name }}" | |
validate_certs: false | |
url_username: "{{ nsx_alb_credentials.username }}" | |
url_password: "{{ nsx_alb_credentials.password }}" | |
force_basic_auth: true | |
method: GET | |
return_content: true | |
headers: | |
Content-Type: application/json | |
X-Avi-Version: "{{ nsx_alb_credentials.api_version }}" | |
register: nsx_alb_ipam_profile | |
- name: Set Fact - NSX ALB IPAM Profile JSON Object | |
ansible.builtin.set_fact: | |
ipam_profile_json: "{{ nsx_alb_ipam_profile.json.results[0] }}" | |
- include_tasks: prepare_ipam_profile_networks_addition.yml | |
loop: "{{ segments }}" | |
loop_control: | |
loop_var: segment | |
- name: Update NSX ALB IPAM Profile | |
ansible.builtin.uri: | |
url: "https://{{ nsx_alb_credentials.controller }}/api/ipamdnsproviderprofile/{{ ipam_profile_json.uuid }}" | |
validate_certs: false | |
url_username: "{{ nsx_alb_credentials.username }}" | |
url_password: "{{ nsx_alb_credentials.password }}" | |
force_basic_auth: true | |
method: PUT | |
body: "{{ ipam_profile_json }}" | |
body_format: json | |
return_content: true | |
headers: | |
Content-Type: application/json | |
X-Avi-Version: "{{ nsx_alb_credentials.api_version }}" | |
- name: Create NSX Antrea Manifest | |
ansible.builtin.shell: "antreansxctl bootstrap --user '{{ nsxt_username }}' --password '{{ nsxt_password }}' --nsx-managers '{{ nsxt_hosts }}' --cluster-name {{ tkg_cluster_name }}" | |
args: | |
creates: "{{ tkg_cluster_name }}-bootstrap-config.yaml" |
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
--- | |
- name: Set Fact - NSX-T Tier1 Gateway name | |
ansible.builtin.set_fact: | |
tier1_gateway_name: "{{ tkg_cluster_name }}-t1" | |
- name: Set Fact - NSX ALB Credentials | |
ansible.builtin.set_fact: | |
nsx_alb_credentials: | |
controller: "{{ nsx_alb_controller }}" | |
username: "{{ nsx_alb_username }}" | |
password: "{{ nsx_alb_password }}" | |
api_version: "{{ nsx_alb_api_version }}" | |
- name: Get NSX ALB IPAM Profile | |
ansible.builtin.uri: | |
url: "https://{{ nsx_alb_credentials.controller }}/api/ipamdnsproviderprofile?name={{ nsx_alb_ipam_profile_name }}" | |
validate_certs: false | |
url_username: "{{ nsx_alb_credentials.username }}" | |
url_password: "{{ nsx_alb_credentials.password }}" | |
force_basic_auth: true | |
method: GET | |
return_content: true | |
headers: | |
Content-Type: application/json | |
X-Avi-Version: "{{ nsx_alb_credentials.api_version }}" | |
register: nsx_alb_ipam_profile | |
- name: Set Fact - NSX ALB IPAM Profile JSON Object | |
ansible.builtin.set_fact: | |
ipam_profile_json: "{{ nsx_alb_ipam_profile.json.results[0] }}" | |
- name: Set Fact - NSX ALB Network Object URL | |
ansible.builtin.set_fact: | |
ipam_profile_network_urls: "{{ ipam_profile_json.internal_profile.usable_networks }}" | |
- include_tasks: prepare_ipam_profile_networks_removal.yml | |
loop: "{{ segments }}" | |
loop_control: | |
loop_var: segment | |
- name: Set Fact - NSX ALB Network Object URL | |
ansible.builtin.set_fact: | |
ipam_profile_json_update: | |
internal_profile: | |
usable_networks: "{{ ipam_profile_network_urls }}" | |
- name: Set Fact - Update NSX ALB IPAM Profile JSON Object | |
ansible.builtin.set_fact: | |
ipam_profile_json: "{{ ipam_profile_json | combine(ipam_profile_json_update, recursive=true, list_merge='replace') }}" | |
- name: Update NSX ALB IPAM Profile (Remove Networks) | |
ansible.builtin.uri: | |
url: "https://{{ nsx_alb_credentials.controller }}/api/ipamdnsproviderprofile/{{ ipam_profile_json.uuid }}" | |
validate_certs: false | |
url_username: "{{ nsx_alb_credentials.username }}" | |
url_password: "{{ nsx_alb_credentials.password }}" | |
force_basic_auth: true | |
method: PUT | |
body: "{{ ipam_profile_json }}" | |
body_format: json | |
return_content: true | |
headers: | |
Content-Type: application/json | |
X-Avi-Version: "{{ nsx_alb_credentials.api_version }}" | |
- name: Get NSX ALB Cloud | |
ansible.builtin.uri: | |
url: "https://{{ nsx_alb_credentials.controller }}/api/cloud?name={{ nsx_alb_cloud_name }}" | |
validate_certs: false | |
url_username: "{{ nsx_alb_credentials.username }}" | |
url_password: "{{ nsx_alb_credentials.password }}" | |
force_basic_auth: true | |
method: GET | |
return_content: true | |
headers: | |
Content-Type: application/json | |
X-Avi-Version: "{{ nsx_alb_credentials.api_version }}" | |
register: nsx_alb_cloud | |
- name: Set Fact - NSX ALB Cloud object properties | |
ansible.builtin.set_fact: | |
nsx_alb_cloud_ref: "{{ nsx_alb_cloud.json.results[0].url }}?name={{ nsx_alb_cloud.json.results[0].name }}" | |
nsx_alb_cloud_type: "{{ nsx_alb_cloud.json.results[0].vtype }}" | |
nsx_alb_cloud_uuid: "{{ nsx_alb_cloud.json.results[0].uuid }}" | |
- name: Remove networks from NSX ALB NSX-T Cloud | |
block: | |
- name: Set Fact - NSX ALB NSX-T Cloud Object | |
ansible.builtin.set_fact: | |
nsx_alb_cloud_json: "{{ nsx_alb_cloud.json.results[0] }}" | |
- name: Set Fact - NSX ALB NSX-T Data Network Config T1 LRs | |
ansible.builtin.set_fact: | |
nsx_alb_cloud_data_t1lrs: "{{ nsx_alb_cloud_json.nsxt_configuration.data_network_config.tier1_segment_config.manual.tier1_lrs }}" | |
- name: Set Fact - T1 LR Gateway Path | |
ansible.builtin.set_fact: | |
tier1_gateway_path: "/infra/tier-1s/{{ tier1_gateway_name }}" | |
- name: Set Fact - Update NSX ALB NSX-T Data Network Config T1 LRs | |
ansible.builtin.set_fact: | |
nsx_alb_cloud_data_t1lrs: "{{ nsx_alb_cloud_data_t1lrs | rejectattr('tier1_lr_id', 'equalto', tier1_gateway_path) | list }}" | |
- name: Set Fact - NSX ALB Cloud Object Data Network Config | |
ansible.builtin.set_fact: | |
nsx_alb_cloud_json_update: | |
nsxt_configuration: | |
data_network_config: | |
tier1_segment_config: | |
manual: | |
tier1_lrs: "{{ nsx_alb_cloud_data_t1lrs }}" | |
- name: Set Fact - Update NSX-T Cloud JSON Object | |
ansible.builtin.set_fact: | |
nsx_alb_cloud_json: "{{ nsx_alb_cloud_json | combine(nsx_alb_cloud_json_update, recursive=true, list_merge='replace') }}" | |
- name: Update NSX ALB Cloud Object | |
ansible.builtin.uri: | |
url: "https://{{ nsx_alb_credentials.controller }}/api/cloud/{{ nsx_alb_cloud_uuid }}" | |
validate_certs: false | |
url_username: "{{ nsx_alb_credentials.username }}" | |
url_password: "{{ nsx_alb_credentials.password }}" | |
force_basic_auth: true | |
method: PUT | |
body: "{{ nsx_alb_cloud_json }}" | |
body_format: json | |
return_content: true | |
headers: | |
Content-Type: application/json | |
X-Avi-Version: "{{ nsx_alb_credentials.api_version }}" | |
when: nsx_alb_cloud_type == 'CLOUD_NSXT' | |
- name: Remove Network from NSX ALB | |
vmware.alb.avi_network: | |
avi_credentials: "{{ nsx_alb_credentials }}" | |
name: "{{ tkg_cluster_name }}-{{ segment.type }}" | |
cloud_ref: "{{ nsx_alb_cloud_ref }}" | |
state: absent | |
loop: "{{ segments }}" | |
loop_control: | |
loop_var: segment | |
- name: Remove Network from NSX ALB | |
vmware.alb.avi_network: | |
avi_credentials: "{{ nsx_alb_credentials }}" | |
name: "{{ tkg_cluster_name }}-{{ segment.type }}" | |
cloud_ref: "{{ nsx_alb_cloud_ref }}" | |
state: absent | |
loop: "{{ segments }}" | |
loop_control: | |
loop_var: segment | |
- name: Remove VRF Context from NSX ALB | |
vmware.alb.avi_vrfcontext: | |
avi_credentials: "{{ nsx_alb_credentials }}" | |
name: "{{ tier1_gateway_name }}" | |
cloud_ref: "{{ nsx_alb_cloud_ref }}" | |
state: absent | |
- name: Remove NSX-T Segments | |
vmware.ansible_for_nsxt.nsxt_policy_segment: | |
hostname: "{{ nsxt_vip }}" | |
username: "{{ nsxt_username }}" | |
password: "{{ nsxt_password }}" | |
validate_certs: false | |
state: absent | |
display_name: "{{ tkg_cluster_name }}-{{ segment.type }}" | |
loop: "{{ segments }}" | |
loop_control: | |
loop_var: segment | |
- name: Remove Tier Groups | |
vmware.ansible_for_nsxt.nsxt_policy_group: | |
hostname: "{{ nsxt_vip }}" | |
username: "{{ nsxt_username }}" | |
password: "{{ nsxt_password }}" | |
validate_certs: false | |
id: "{{ tkg_cluster_name }}-{{ machine_deployment.tier }}" | |
display_name: "{{ tkg_cluster_name }}-{{ machine_deployment.tier }}" | |
state: absent | |
domain_id: "default" | |
expression: | |
- member_type: "VirtualMachine" | |
value: "{{ tkg_cluster_name }}-{{ machine_deployment.tier }}-" | |
key: "Name" | |
operator: "STARTSWITH" | |
resource_type: "Condition" | |
loop: "{{ machine_deployments }}" | |
loop_control: | |
loop_var: machine_deployment | |
- name: Remove Cluster Group | |
vmware.ansible_for_nsxt.nsxt_policy_group: | |
hostname: "{{ nsxt_vip }}" | |
username: "{{ nsxt_username }}" | |
password: "{{ nsxt_password }}" | |
validate_certs: false | |
id: "{{ tkg_cluster_name }}-all-nodes" | |
display_name: "{{ tkg_cluster_name }}-all-nodes" | |
state: absent | |
domain_id: "default" | |
expression: | |
- member_type: "VirtualMachine" | |
value: "{{ tkg_cluster_name }}-" | |
key: "Name" | |
operator: "STARTSWITH" | |
resource_type: "Condition" | |
- name: Remove Cluster Control Plane Group | |
vmware.ansible_for_nsxt.nsxt_policy_group: | |
hostname: "{{ nsxt_vip }}" | |
username: "{{ nsxt_username }}" | |
password: "{{ nsxt_password }}" | |
validate_certs: false | |
id: "{{ tkg_cluster_name }}-control-plane-nodes" | |
display_name: "{{ tkg_cluster_name }}-control-plane-nodes" | |
state: absent | |
domain_id: "default" | |
expression: | |
- member_type: "VirtualMachine" | |
value: "{{ tkg_cluster_name }}-controlplane-" | |
key: "Name" | |
operator: "STARTSWITH" | |
resource_type: "Condition" | |
- name: Remove NSX-T DHCP Server Config | |
vmware.ansible_for_nsxt.nsxt_rest: | |
hostname: "{{ nsxt_vip }}" | |
username: "{{ nsxt_username }}" | |
password: "{{ nsxt_password }}" | |
validate_certs: false | |
method: delete | |
path: "/policy/api/v1/infra/dhcp-server-configs/{{ tkg_cluster_name }}-{{ segment.type }}" | |
loop: "{{ segments }}" | |
loop_control: | |
loop_var: segment | |
changed_when: false | |
when: segment.type == 'vips' | |
- name: Remove NSX-T Tier1 Gateway | |
vmware.ansible_for_nsxt.nsxt_policy_tier1: | |
hostname: "{{ nsxt_vip }}" | |
username: "{{ nsxt_username }}" | |
password: "{{ nsxt_password }}" | |
validate_certs: false | |
state: absent | |
display_name: "{{ tier1_gateway_name }}" | |
locale_services: | |
- state: absent | |
display_name: "{{ tier1_gateway_name }}-ls" | |
- name: Delete NSX-T Principal Identity | |
vmware.ansible_for_nsxt.nsxt_principal_identities: | |
hostname: "{{ nsxt_vip }}" | |
username: "{{ nsxt_username }}" | |
password: "{{ nsxt_password }}" | |
validate_certs: false | |
state: absent | |
name: "{{ tkg_cluster_name }}" | |
display_name: "{{ tkg_cluster_name }}@{{ tkg_cluster_name }}" | |
certificate_pem_file: "{{ tkg_cluster_name }}.crt" | |
node_id: "{{ tkg_cluster_name }}" | |
ignore_errors: yes | |
register: deletion_result | |
failed_when: "deletion_result.msg is defined and deletion_result.msg.startswith('Principal identity with display name') and deletion_result.msg.endswith('Doesn\\'t exist')" |
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
segments: | |
- type: nodes | |
subnet: 172.16.238.0/24 | |
gateway_address: 172.16.238.1/24 | |
- type: vips | |
subnet: 172.16.239.0/24 | |
gateway_address: 172.16.239.1/24 | |
ip_range: 172.16.239.10-172.16.239.200 | |
# NEW | |
dhcp_server_address: 172.16.239.2/24 | |
# NEW | |
dhcp_range: 172.16.239.3-172.16.239.9 | |
# NEW | |
dns_servers: | |
- 172.16.20.10 | |
- 10.100.100.100 | |
# NEW | |
ntp_servers: | |
- 172.16.20.10 | |
- 10.100.100.100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment