├── tests ├── unit │ ├── __init__.py │ └── plugins │ │ ├── __init__.py │ │ └── module_utils │ │ └── __init__.py └── playbooks │ ├── topologies │ ├── policy_modules │ │ ├── README.md │ │ ├── build_topology.yml │ │ ├── cleanup_topology.yml │ │ ├── 02_create_t1_gateway.yml │ │ ├── 04_create_groups.yml │ │ ├── 01_create_t0_gateway.yml │ │ ├── 05_create_security_policy.yml │ │ └── 03_create_segments.yml │ ├── upgrade │ │ ├── 03_upgrade_uc.yml │ │ ├── 02_upgrade_accept_eula.yml │ │ ├── check_upgrade_groups_facts.yml │ │ ├── 07_upgrade_run.yml │ │ ├── check_upgrade_status_summary_facts.yml │ │ ├── 06_upgrade_prechecks.yml │ │ ├── check_upgrade_pre_post_checks_facts.yml │ │ ├── 01_upgrade_upload_mub.yml │ │ ├── upgrade_vars.yml │ │ ├── 04_upgrade_update_plan.yml │ │ ├── README.md │ │ └── 05_upgrade_update_groups.yml │ ├── deploy_nsx_cluster │ │ ├── README.md │ │ ├── 04_add_nsx_license.yml │ │ ├── 02_configure_compute_manager.yml │ │ ├── 01_deploy_first_node.yml │ │ ├── 03_deploy_second_third_node.yml │ │ └── deploy_nsx_cluster_vars.yml │ ├── setup_infra │ │ ├── 02_setup_TEP_IP_Pools.yml │ │ ├── 05_setup_edge_cluster.yml │ │ ├── 01_setup_transport_zones_9x.yml │ │ ├── 01_setup_transport_zones.yml │ │ ├── 04_setup_transport_nodes_9x.yml │ │ ├── 03_setup_transport_node_profiles_9x.yml │ │ ├── 04_setup_transport_nodes.yml │ │ ├── 03_setup_transport_node_profiles.yml │ │ ├── README.md │ │ └── 06_setup_transport_node_collections.yml │ └── misc │ │ └── create_and_attach_t0_t1_routers.yml │ ├── mp │ ├── test_upgrade_uc.yml │ ├── test_upgrade_eula_accept.yml │ ├── test_ip_blocks_facts.yml │ ├── test_upgrade_history_facts.yml │ ├── test_upgrade_uc_facts.yml │ ├── test_repo_sync.yml │ ├── test_upgrade_groups_facts.yml │ ├── test_upgrade_run.yml │ ├── test_ip_pools_facts.yml │ ├── test_licenses_facts.yml │ ├── test_upgrade_status_summary_facts.yml │ ├── test_edge_clusters_facts.yml │ ├── test_logical_ports_facts.yml │ ├── test_certificates_facts.yml │ ├── test_local_managers_facts.yml │ ├── test_upgrade_plan_facts.yml │ ├── test_upgrade_pre_post_checks_facts.yml │ ├── test_logical_routers_facts.yml │ ├── test_transport_nodes_facts.yml │ ├── test_transport_zones_facts.yml │ ├── test_upgrade_prechecks.yml │ ├── test_uplink_profiles_facts.yml │ ├── test_cluster_profiles_facts.yml │ ├── test_logical_switches_facts.yml │ ├── test_virtual_ip_facts.yml │ ├── test_compute_managers_facts.yml │ ├── test_manager_status.yml │ ├── test_logical_router_ports_facts.yml │ ├── test_principal_identities_facts.yml │ ├── test_repo_sync_facts.yml │ ├── test_transport_node_profiles_facts.yml │ ├── test_licenses.yml │ ├── test_transport_node_collections_facts.yml │ ├── test_upgrade_postchecks.yml │ ├── test_upgrade_eula_accept_facts.yml │ ├── test_upgrade_upload_mub_facts.yml │ ├── test_ip_blocks.yml │ ├── test_manager_auto_deployment_facts.yml │ ├── test_global_managers_active.yml │ ├── test_ip_pools.yml │ ├── test_upgrade_plan.yml │ ├── test_logical_switches.yml │ ├── test_virtual_ip.yml │ ├── test_upgrade_upload_mub.yml │ ├── test_certificates.yml │ ├── test_global_manager_enable_service.yml │ ├── test_upgrade_groups.yml │ ├── test_logical_ports.yml │ ├── test_edge_clusters.yml │ ├── test_uplink_profiles_9x.yml │ ├── test_logical_router_static_route.yml │ ├── test_vidm.yml │ ├── test_uplink_profiles.yml │ ├── test_transport_node_collections.yml │ ├── test_cluster_profiles.yml │ ├── test_transport_nodes_host_9x.yml │ ├── test_transport_nodes_edge_9x.yml │ ├── test_transport_zones.yml │ ├── test_transport_node_profiles.yml │ ├── test_local_manager_registration.yml │ ├── test_transport_nodes_edge.yml │ ├── test_principal_identities.yml │ ├── test_global_manager_registration.yml │ ├── test_logical_router_ports.yml │ ├── test_local_managers_compatibility.yml │ ├── test_transport_nodes_host.yml │ ├── test_compute_managers.yml │ ├── test_route_advertise.yml │ ├── test_logical_routers.yml │ ├── answerfile_attach_tnp_to_cluster.yml │ ├── test_ovf_deployment.yml │ ├── answerfile_attach_tnp_to_cluster_9x.yml │ ├── answerfile_tn_9x.yml │ ├── answerfile_tn.yml │ ├── test_manager_auto_deployment.yml │ ├── test_configure_transport_node_9x.yml │ ├── test_configure_transport_node.yml │ ├── test_transport_nodes.yml │ └── test_attach_tnp_to_cluster_9x.yml │ └── policy │ ├── test_nsxt_policy_bfd_profile.yaml │ ├── test_nsxt_policy_ip_block.yml │ ├── test_vm_tags.yaml │ ├── test_nsxt_policy_l2_bridge_ep_profile.yml │ ├── test_nsxt_policy_group.yml │ ├── test_nsxt_policy_security_policy.yml │ ├── test_nsxt_policy_gateway_policy.yml │ ├── test_nsxt_policy_ip_pool.yml │ ├── test_nsxt_policy_segment.yml │ └── test_nsxt_policy_tier1.yml ├── plugins ├── modules │ ├── __init__.py │ ├── nsxt_upgrade_history.py │ ├── nsxt_upgrade_uc_facts.py │ ├── nsxt_logical_switches_facts.py │ ├── nsxt_virtual_ip_facts.py │ ├── nsxt_licenses_facts.py │ ├── nsxt_manager_auto_deployment_facts.py │ ├── nsxt_cluster_profiles_facts.py │ ├── nsxt_transport_node_profiles_facts.py │ ├── nsxt_principal_identities_facts.py │ ├── nsxt_upgrade_pre_post_checks_facts.py │ ├── nsxt_upgrade_groups_facts.py │ ├── nsxt_policy_ip_block_facts.py │ ├── nsxt_upgrade_status_summary_facts.py │ ├── nsxt_local_managers_facts.py │ ├── nsxt_fabric_compute_managers_facts.py │ ├── nsxt_transport_node_collections_facts.py │ ├── nsxt_edge_clusters_facts.py │ ├── nsxt_policy_ip_pool_facts.py │ ├── nsxt_logical_routers_facts.py │ ├── nsxt_logical_ports_facts.py │ ├── nsxt_ip_blocks_facts.py │ ├── nsxt_ip_pools_facts.py │ ├── nsxt_policy_ip_block.py │ └── nsxt_transport_nodes_facts.py └── module_utils │ ├── __init__.py │ ├── policy_resource_specs │ ├── __init__.py │ └── l2_bridge_ep_profile.py │ └── nsxt_resource_urls.py ├── meta └── runtime.yml ├── .gitignore ├── galaxy.yml └── CONTRIBUTING.md /tests/unit/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /plugins/modules/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /plugins/module_utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/unit/plugins/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/unit/plugins/module_utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /meta/runtime.yml: -------------------------------------------------------------------------------- 1 | requires_ansible: ">=2.9" 2 | -------------------------------------------------------------------------------- /plugins/module_utils/policy_resource_specs/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # build products... 2 | *.py[co] 3 | # Mac OS X stuff... 4 | .DS_Store 5 | # test output 6 | *.retry 7 | # JetBrains project dir 8 | .idea 9 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/policy_modules/README.md: -------------------------------------------------------------------------------- 1 | Example to build the following Topology: 2 | 3 | * 1 Tier0 Gateway 4 | * 1 Tier1 Gateway 5 | * 3 Subnets 6 | * 3 Groups 7 | * 3 Security Policies with 1 rule each 8 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/policy_modules/build_topology.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - import_playbook: 01_create_t0_gateway.yml 5 | - import_playbook: 02_create_t1_gateway.yml 6 | - import_playbook: 03_create_segments.yml 7 | - import_playbook: 04_create_groups.yml 8 | - import_playbook: 05_create_security_policy.yml 9 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/policy_modules/cleanup_topology.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - import_playbook: 05_create_security_policy.yml 5 | - import_playbook: 04_create_groups.yml 6 | - import_playbook: 03_create_segments.yml 7 | - import_playbook: 02_create_t1_gateway.yml 8 | - import_playbook: 01_create_t0_gateway.yml 9 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/upgrade/03_upgrade_uc.yml: -------------------------------------------------------------------------------- 1 | - hosts: 127.0.0.1 2 | connection: local 3 | become: yes 4 | vars_files: 5 | - upgrade_vars.yml 6 | tasks: 7 | - name: Upgrade UC 8 | vmware.ansible_for_nsxt.nsxt_upgrade_uc: 9 | hostname: "{{ nsx_manager }}" 10 | username: "{{ nsx_username }}" 11 | password: "{{ nsx_password }}" 12 | validate_certs: "{{ validate_certs }}" 13 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/upgrade/02_upgrade_accept_eula.yml: -------------------------------------------------------------------------------- 1 | - hosts: 127.0.0.1 2 | connection: local 3 | become: yes 4 | vars_files: 5 | - upgrade_vars.yml 6 | tasks: 7 | - name: Accepts EULA 8 | vmware.ansible_for_nsxt.nsxt_upgrade_eula_accept: 9 | hostname: "{{ nsx_manager }}" 10 | username: "{{ nsx_username }}" 11 | password: "{{ nsx_password }}" 12 | validate_certs: "{{ validate_certs }}" 13 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/upgrade/check_upgrade_groups_facts.yml: -------------------------------------------------------------------------------- 1 | - hosts: 127.0.0.1 2 | connection: local 3 | become: yes 4 | vars_files: 5 | - upgrade_vars.yml 6 | tasks: 7 | - name: Get upgrade groups info 8 | vmware.ansible_for_nsxt.nsxt_upgrade_groups_facts: 9 | hostname: "{{ nsx_manager }}" 10 | username: "{{ nsx_username }}" 11 | password: "{{ nsx_password}}" 12 | validate_certs: "{{ validate_certs }}" 13 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/upgrade/07_upgrade_run.yml: -------------------------------------------------------------------------------- 1 | - hosts: 127.0.0.1 2 | connection: local 3 | become: yes 4 | vars_files: 5 | - upgrade_vars.yml 6 | tasks: 7 | - name: Runs Upgrade 8 | vmware.ansible_for_nsxt.nsxt_upgrade_run: 9 | hostname: "{{ nsx_manager }}" 10 | username: "{{ nsx_username }}" 11 | password: "{{ nsx_password }}" 12 | validate_certs: "{{ validate_certs }}" 13 | paused_upgrade: False 14 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_upgrade_uc.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Upgrade UC 11 | vmware.ansible_for_nsxt.nsxt_upgrade_uc: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/upgrade/check_upgrade_status_summary_facts.yml: -------------------------------------------------------------------------------- 1 | - hosts: 127.0.0.1 2 | connection: local 3 | become: yes 4 | vars_files: 5 | - upgrade_vars.yml 6 | tasks: 7 | - name: Get upgrade status summary 8 | vmware.ansible_for_nsxt.nsxt_upgrade_status_summary_facts: 9 | hostname: "{{ nsx_manager }}" 10 | username: "{{ nsx_username }}" 11 | password: "{{ nsx_password}}" 12 | validate_certs: "{{ validate_certs }}" 13 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/upgrade/06_upgrade_prechecks.yml: -------------------------------------------------------------------------------- 1 | - hosts: 127.0.0.1 2 | connection: local 3 | become: yes 4 | vars_files: 5 | - upgrade_vars.yml 6 | tasks: 7 | - name: Run and abort upgrade prechecks 8 | vmware.ansible_for_nsxt.nsxt_upgrade_prechecks: 9 | hostname: "{{ nsx_manager }}" 10 | username: "{{ nsx_username }}" 11 | password: "{{ nsx_password }}" 12 | validate_certs: "{{ validate_certs }}" 13 | state: 'present' 14 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/upgrade/check_upgrade_pre_post_checks_facts.yml: -------------------------------------------------------------------------------- 1 | - hosts: 127.0.0.1 2 | connection: local 3 | become: yes 4 | vars_files: 5 | - upgrade_vars.yml 6 | tasks: 7 | - name: Get upgrade pre and post checks info 8 | vmware.ansible_for_nsxt.nsxt_upgrade_pre_post_checks_facts: 9 | hostname: "{{ nsx_manager }}" 10 | username: "{{ nsx_username }}" 11 | password: "{{ nsx_password}}" 12 | validate_certs: "{{ validate_certs }}" 13 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_upgrade_eula_accept.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Accepts EULA 11 | vmware.ansible_for_nsxt.nsxt_upgrade_eula_accept: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False -------------------------------------------------------------------------------- /tests/playbooks/mp/test_ip_blocks_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: List IP address block 11 | vmware.ansible_for_nsxt.nsxt_ip_blocks_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_upgrade_history_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Get upgrade history 11 | vmware.ansible_for_nsxt.nsxt_upgrade_history: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False -------------------------------------------------------------------------------- /tests/playbooks/mp/test_upgrade_uc_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Get UC upgrade status 11 | vmware.ansible_for_nsxt.nsxt_upgrade_uc_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_repo_sync.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Get repo sync status of an auto deployed node 11 | vmware.ansible_for_nsxt.nsxt_repo_sync: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False -------------------------------------------------------------------------------- /tests/playbooks/mp/test_upgrade_groups_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Get upgrade groups info 11 | vmware.ansible_for_nsxt.nsxt_upgrade_groups_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_upgrade_run.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Runs Upgrade 11 | vmware.ansible_for_nsxt.nsxt_upgrade_run: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | paused_upgrade: False -------------------------------------------------------------------------------- /tests/playbooks/mp/test_ip_pools_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: List IP pools 11 | vmware.ansible_for_nsxt.nsxt_ip_pools_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes 17 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_licenses_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Get all licenses 11 | vmware.ansible_for_nsxt.nsxt_licenses_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes 17 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_upgrade_status_summary_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Get upgrade status summary 11 | vmware.ansible_for_nsxt.nsxt_upgrade_status_summary_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False -------------------------------------------------------------------------------- /tests/playbooks/policy/test_nsxt_policy_bfd_profile.yaml: -------------------------------------------------------------------------------- 1 | - hosts: localhost 2 | tasks: 3 | - name: Update BFD Profile 4 | vmware.ansible_for_nsxt.nsxt_policy_bfd_profile: 5 | hostname: "default" 6 | nsx_cert_path: /root/com.vmware.nsx.ncp/nsx.crt 7 | nsx_key_path: /root/com.vmware.nsx.ncp/nsx.key 8 | validate_certs: True 9 | ca_path: /path/to/my/ca-bundle 10 | display_name: test-bfd-profile 11 | state: present 12 | interval: 200 13 | multiple: 10 14 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_edge_clusters_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: List edge clusters 11 | vmware.ansible_for_nsxt.nsxt_edge_clusters_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes 17 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_logical_ports_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: List logical ports 11 | vmware.ansible_for_nsxt.nsxt_logical_ports_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes 17 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_certificates_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: List all existing certificates 11 | vmware.ansible_for_nsxt.nsxt_certificates_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes -------------------------------------------------------------------------------- /tests/playbooks/mp/test_local_managers_facts.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # Playbook to get facts of local managers registered with a global manager 4 | # 5 | - hosts: 127.0.0.1 6 | connection: local 7 | become: yes 8 | vars_files: 9 | - answerfile.yml 10 | tasks: 11 | - name: Register local manager 12 | vmware.ansible_for_nsxt.nsxt_local_managers_facts: 13 | hostname: "{{hostname}}" 14 | username: "{{username}}" 15 | password: "{{password}}" 16 | validate_certs: "{{ validate_certs }}" 17 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_upgrade_plan_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Retrieve upgrade plan 11 | vmware.ansible_for_nsxt.nsxt_upgrade_plan_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | component_type: 'host' -------------------------------------------------------------------------------- /tests/playbooks/mp/test_upgrade_pre_post_checks_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Get upgrade pre and post checks info 11 | vmware.ansible_for_nsxt.nsxt_upgrade_pre_post_checks_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False -------------------------------------------------------------------------------- /tests/playbooks/topologies/upgrade/01_upgrade_upload_mub.yml: -------------------------------------------------------------------------------- 1 | - hosts: 127.0.0.1 2 | connection: local 3 | become: yes 4 | vars_files: 5 | - upgrade_vars.yml 6 | tasks: 7 | - name: Upload MUB to NSX-T Manager 8 | vmware.ansible_for_nsxt.nsxt_upgrade_upload_mub: 9 | hostname: "{{ nsx_manager }}" 10 | username: "{{ nsx_username }}" 11 | password: "{{ nsx_password }}" 12 | validate_certs: "{{ validate_certs }}" 13 | url: "{{ mub_url }}" 14 | timeout: "{{ timeout }}" 15 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_logical_routers_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: List Logical Routers 11 | vmware.ansible_for_nsxt.nsxt_logical_routers_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes 17 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_transport_nodes_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: List Transport Nodes 11 | vmware.ansible_for_nsxt.nsxt_transport_nodes_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes 17 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_transport_zones_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: List Transport Zones 11 | vmware.ansible_for_nsxt.nsxt_transport_zones_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes 17 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_upgrade_prechecks.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Run and abort upgrade prechecks 11 | vmware.ansible_for_nsxt.nsxt_upgrade_prechecks: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | state: 'present' -------------------------------------------------------------------------------- /tests/playbooks/mp/test_uplink_profiles_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: List uplink profiles 11 | vmware.ansible_for_nsxt.nsxt_uplink_profiles_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes 17 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_cluster_profiles_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: List all cluster profiles 11 | vmware.ansible_for_nsxt.nsxt_cluster_profiles_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes 17 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_logical_switches_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: List All Logical Switches 11 | vmware.ansible_for_nsxt.nsxt_logical_switches_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes 17 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_virtual_ip_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Get all configured cluster virtual IP address 11 | vmware.ansible_for_nsxt.nsxt_virtual_ip_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes -------------------------------------------------------------------------------- /tests/playbooks/mp/test_compute_managers_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: List all compute managers 11 | vmware.ansible_for_nsxt.nsxt_fabric_compute_managers_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes 17 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_manager_status.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Check manager status 11 | vmware.ansible_for_nsxt.nsxt_manager_status: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | wait_time: 30 17 | check_mode: yes 18 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_logical_router_ports_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: List logical router ports 11 | vmware.ansible_for_nsxt.nsxt_logical_router_ports_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes 17 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_principal_identities_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: List all existing principal identities 11 | vmware.ansible_for_nsxt.nsxt_principal_identities_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes -------------------------------------------------------------------------------- /tests/playbooks/mp/test_repo_sync_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Get repo sync status of an auto deployed node 11 | vmware.ansible_for_nsxt.nsxt_repo_sync_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | node_name: "manager-node02" -------------------------------------------------------------------------------- /tests/playbooks/mp/test_transport_node_profiles_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: List transport node profiles 11 | vmware.ansible_for_nsxt.nsxt_transport_node_profiles_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes 17 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_licenses.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Add license 11 | vmware.ansible_for_nsxt.nsxt_licenses: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | license_key: "00000-00000-00000-00000-00000" 17 | state: "present" 18 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_transport_node_collections_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: List Transport Node collections 11 | vmware.ansible_for_nsxt.nsxt_transport_node_collections_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes 17 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_upgrade_postchecks.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Run upgrade postchecks 11 | vmware.ansible_for_nsxt.nsxt_upgrade_postchecks: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | timeout: 7200 17 | component_type: 'host' 18 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_upgrade_eula_accept_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Retrieve information about EULA acceptance 11 | vmware.ansible_for_nsxt.nsxt_upgrade_eula_accept_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | required_info: 'acceptance' -------------------------------------------------------------------------------- /tests/playbooks/mp/test_upgrade_upload_mub_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Get info of uploaded MUB to NSX-T Manager 11 | vmware.ansible_for_nsxt.nsxt_upgrade_upload_mub_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | bundle_id: "2500014364090" -------------------------------------------------------------------------------- /tests/playbooks/mp/test_ip_blocks.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Create ip block 11 | vmware.ansible_for_nsxt.nsxt_ip_blocks: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: "MyDisplayname" 17 | cidr: "192.168.0.0/16" 18 | state: present 19 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_manager_auto_deployment_facts.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Lists info for all cluster node VM auto-deployment 11 | vmware.ansible_for_nsxt.nsxt_manager_auto_deployment_facts: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | check_mode: yes 17 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_global_managers_active.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # Playbook to register Compute Managers with NSX Appliance 4 | # 5 | - hosts: 127.0.0.1 6 | connection: local 7 | become: yes 8 | vars_files: 9 | - answerfile.yml 10 | tasks: 11 | - name: Make the global manager as Active 12 | vmware.ansible_for_nsxt.nsxt_global_manager_active: 13 | hostname: "{{ global_managers[0].fqdn }}" 14 | username: "{{ global_managers[0].username }}" 15 | password: "{{ global_managers[0].password }}" 16 | validate_certs: "{{ validate_certs }}" 17 | id: "{{ global_managers[0].id }}" 18 | -------------------------------------------------------------------------------- /tests/playbooks/policy/test_nsxt_policy_ip_block.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # 5 | # Playbook to test IP Block 6 | # 7 | - hosts: localhost 8 | tasks: 9 | - name: create IP Block 10 | vmware.ansible_for_nsxt.nsxt_policy_ip_block: 11 | hostname: "default" 12 | nsx_cert_path: /root/com.vmware.nsx.ncp/nsx.crt 13 | nsx_key_path: /root/com.vmware.nsx.ncp/nsx.key 14 | validate_certs: True 15 | ca_path: /path/to/my/ca-bundle 16 | display_name: test-ip-blk 17 | state: "absent" 18 | cidr: "192.168.0.0/16" -------------------------------------------------------------------------------- /tests/playbooks/mp/test_ip_pools.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Create ip pool 11 | vmware.ansible_for_nsxt.nsxt_ip_pools: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: "{{item.display_name}}" 17 | subnets: "{{item.subnets}}" 18 | state: present 19 | with_items: 20 | - "{{ip_pools}}" 21 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_upgrade_plan.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Update upgrade plan 11 | vmware.ansible_for_nsxt.nsxt_upgrade_plan: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | component_type: 'host' 17 | parallel: True 18 | pause_after_each_group: True 19 | pause_on_error: True 20 | state: 'present' 21 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_logical_switches.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Create logical switch 11 | vmware.ansible_for_nsxt.nsxt_logical_switches: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: "ls1" 17 | replication_mode: SOURCE 18 | admin_state: UP 19 | transport_zone_name: "TZ1" 20 | state: "present" 21 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_virtual_ip.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Adds cluster virtual IP address 11 | vmware.ansible_for_nsxt.nsxt_virtual_ip: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | virtual_ip_address: "10.186.94.5" 17 | virtual_ip6_address: "2620:124:6020:c308::10" 18 | action: clear_virtual_ip 19 | state: absent 20 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_upgrade_upload_mub.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Upload MUB to NSX-T Manager 11 | vmware.ansible_for_nsxt.nsxt_upgrade_upload_mub: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | url: "http://build-squid.eng.vmware.com/build/mts/release/bora-14179320/publish/upgrade/VMware-NSX-upgrade-bundle-2.5.0.0.0.14179320.mub" 17 | timeout: 9000 -------------------------------------------------------------------------------- /tests/playbooks/policy/test_vm_tags.yaml: -------------------------------------------------------------------------------- 1 | - hosts: localhost 2 | tasks: 3 | - name: Update Tags on VMs 4 | vmware.ansible_for_nsxt.nsxt_vm_tags: 5 | hostname: "default" 6 | nsx_cert_path: /root/com.vmware.nsx.ncp/nsx.crt 7 | nsx_key_path: /root/com.vmware.nsx.ncp/nsx.key 8 | validate_certs: True 9 | ca_path: /path/to/my/ca-bundle 10 | virtual_machine_display_name: App-VM-1 11 | remove_other_tags: False 12 | add_tags: 13 | - scope: "my-scope" 14 | tag: "my-tag" 15 | # - scope: "my-scope1" 16 | # tag: "my-tag" 17 | remove_tags_with_scope: 18 | - my-scope1 -------------------------------------------------------------------------------- /tests/playbooks/mp/test_certificates.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Add a new certificate 11 | vmware.ansible_for_nsxt.nsxt_certificates: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: "Certificate_file" 17 | pem_encoded_file: "/Path/to/certificate/file" 18 | #private_key_file: "/Path/to/p12/private/key/file" 19 | state: "present" 20 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/deploy_nsx_cluster/README.md: -------------------------------------------------------------------------------- 1 | # Deploy NSX-T Cluster 2 | 3 | # Overview 4 | The set of playbooks in this example deploy a full NSX Cluster. The playbooks 5 | are divided based on the workflow. 6 | 7 | There are 3 main playbooks and a common variable files: 8 | 9 | * 01_deploy_first_node.yml 10 | * 02_configure_compute_manager.yml 11 | * 03_deploy_second_third_node.yml 12 | * deploy_nsx_cluster_vars.yml 13 | 14 | To run the example, copy all the files two-levels up, edit the variables file 15 | to match your needs and run the playbooks in the order listed. 16 | 17 | Validated against: 18 | * NSX-T 2.4 GA 19 | * NSX-T 2.5 GA 20 | 21 | It currently does not configure a cluster Virtual IP 22 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_global_manager_enable_service.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # Playbook to register Compute Managers with NSX Appliance 4 | # 5 | - hosts: 127.0.0.1 6 | connection: local 7 | become: yes 8 | vars_files: 9 | - answerfile.yml 10 | tasks: 11 | - name: Make the global manager as Active 12 | vmware.ansible_for_nsxt.nsxt_global_manager_enable_service: 13 | hostname: "{{ global_managers[0].fqdn }}" 14 | username: "{{ global_managers[0].username }}" 15 | password: "{{ global_managers[0].password }}" 16 | validate_certs: "{{ validate_certs }}" 17 | id: "{{ global_managers[0].id }}" 18 | display_name: "{{ global_managers[0].display_name }}" 19 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_upgrade_groups.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Create upgrade groups 11 | vmware.ansible_for_nsxt.nsxt_upgrade_groups: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: "TestGroupAnsible" 17 | type: "HOST" 18 | parallel: "true" 19 | enabled: "true" 20 | upgrade_units: 21 | - host_name: "10.160.165.71" 22 | state: "present" -------------------------------------------------------------------------------- /tests/playbooks/mp/test_logical_ports.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Create a Logical Port 11 | vmware.ansible_for_nsxt.nsxt_logical_ports: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: "logical_port_1" 17 | logical_switch_name: "ls1" 18 | attachment: 19 | attachment_type: "VIF" 20 | id: "vif2" 21 | admin_state: "UP" 22 | state: "present" 23 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_edge_clusters.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Add edge cluster 11 | vmware.ansible_for_nsxt.nsxt_edge_clusters: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: edge-cluster-1 17 | cluster_profile_bindings: 18 | - profile_name: "Profile01" 19 | resource_type: EdgeHighAvailabilityProfile 20 | members: 21 | - transport_node_name: "TN_1" 22 | state: present 23 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/setup_infra/02_setup_TEP_IP_Pools.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - setup_infra_vars.yml 9 | tasks: 10 | - name: Create IP Pools 11 | vmware.ansible_for_nsxt.nsxt_policy_ip_pool: 12 | hostname: "{{ nsx_node1.mgmt_ip }}" 13 | username: "{{ nsx_username }}" 14 | password: "{{ nsx_password }}" 15 | validate_certs: "{{ validate_certs }}" 16 | display_name: "{{ item.display_name }}" 17 | pool_static_subnets: "{{ item.pool_static_subnets }}" 18 | state: "{{ state }}" 19 | with_items: 20 | - "{{ ip_pools }}" 21 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/policy_modules/02_create_t1_gateway.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: localhost 5 | become: yes 6 | vars_files: 7 | - build_topology_vars.yml 8 | tasks: 9 | - name: Modify Tier1 10 | vmware.ansible_for_nsxt.nsxt_policy_tier1: 11 | hostname: "{{ nsx_manager }}" 12 | username: "{{ nsx_username }}" 13 | password: "{{ nsx_password }}" 14 | validate_certs: "{{ validate_certs }}" 15 | state: "{{ state }}" 16 | display_name: "{{ item.display_name }}" 17 | tier0_display_name: "{{ item.tier0_display_name }}" 18 | tags: "{{ item.tags }}" 19 | with_items: 20 | - "{{ tier1_gateways }}" 21 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_uplink_profiles_9x.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile_9x.yml 9 | tasks: 10 | - name: Create uplink profile 11 | vmware.ansible_for_nsxt.nsxt_uplink_profiles: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | resource_type: UplinkHostSwitchProfile 17 | display_name: "{{item.display_name}}" 18 | teaming: "{{item.teaming}}" 19 | transport_vlan: "{{item.transport_vlan}}" 20 | state: "present" 21 | with_items: 22 | - "{{uplink_profiles}}" 23 | -------------------------------------------------------------------------------- /galaxy.yml: -------------------------------------------------------------------------------- 1 | namespace: vmware 2 | 3 | name: ansible_for_nsxt 4 | 5 | version: 1.0.0 6 | 7 | readme: README.md 8 | 9 | authors: 10 | - Gautam Verma @ggverma (https://vmware.slack.com/archives/CTE293BSS) 11 | - Rahul Raghuvanshi @r-raghu (https://vmware.slack.com/archives/CTE293BSS) 12 | 13 | description: Ansible Modules for NSX-t 14 | 15 | license: 16 | - GPL-3.0-only 17 | - BSD-2-Clause-FreeBSD 18 | 19 | license_file: LICENSE.txt 20 | 21 | tags: [vmware, ansible, nsxt] 22 | 23 | dependencies: {} 24 | 25 | repository: https://github.com/vmware/ansible-for-nsxt 26 | 27 | documentation: https://github.com/vmware/ansible-for-nsxt 28 | 29 | homepage: https://github.com/vmware/ansible-for-nsxt 30 | 31 | issues: https://github.com/vmware/ansible-for-nsxt/issues 32 | 33 | build_ignore: [] 34 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/deploy_nsx_cluster/04_add_nsx_license.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # 5 | # Playbook to register Compute Managers with NSX Appliance 6 | # 7 | - hosts: 127.0.0.1 8 | connection: local 9 | become: yes 10 | vars_files: 11 | - deploy_nsx_cluster_vars.yml 12 | tasks: 13 | - name: Add NSX License 14 | vmware.ansible_for_nsxt.nsxt_licenses: 15 | hostname: "{{ nsx_node1.mgmt_ip }}" 16 | username: "{{ nsx_username }}" 17 | password: "{{ nsx_password }}" 18 | validate_certs: "{{ validate_certs }}" 19 | license_key: "{{ item.license_key }}" 20 | state: "{{ state }}" 21 | with_items: 22 | - "{{nsxt_licenses}}" 23 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/policy_modules/04_create_groups.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: localhost 5 | become: yes 6 | vars_files: 7 | - build_topology_vars.yml 8 | tasks: 9 | - name: Modify Groups 10 | vmware.ansible_for_nsxt.nsxt_policy_group: 11 | hostname: "{{ nsx_manager }}" 12 | username: "{{ nsx_username }}" 13 | password: "{{ nsx_password }}" 14 | state: "{{ state }}" 15 | validate_certs: "{{ validate_certs }}" 16 | domain_id: "{{ item.domain_id }}" 17 | display_name: "{{ item.display_name }}" 18 | expression: "{{ item.expression }}" 19 | tags: "{{ item.tags }}" 20 | with_items: 21 | - "{{ mygroups }}" 22 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_logical_router_static_route.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Add Static Routes on a Logical Router 11 | vmware.ansible_for_nsxt.nsxt_logical_router_static_routes: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: "static_route" 17 | logical_router_name: "tier-0" 18 | next_hops: 19 | - administrative_distance: '2' 20 | ip_address: 192.168.200.254 21 | network: 192.168.200.0/24 22 | state: "present" 23 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_vidm.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # Playbook to register Compute Managers with NSX Appliance 4 | # 5 | - hosts: 127.0.0.1 6 | connection: local 7 | become: yes 8 | vars_files: 9 | - answerfile.yml 10 | tasks: 11 | - name: Register vidm to NSX 12 | vmware.ansible_for_nsxt.nsxt_vidm: 13 | hostname: "{{ hostname }}" 14 | username: "{{ username }}" 15 | password: "{{ password }}" 16 | validate_certs: "{{ validate_certs }}" 17 | client_id: "{{ vidm.client_id }}" 18 | client_secret: "{{ vidm.client_secret }}" 19 | host_name: "{{ vidm.host_name }}" 20 | lb_enable: "{{ vidm.lb_enable }}" 21 | node_host_name: "{{ vidm.node_host_name }}" 22 | thumbprint: "{{ vidm.thumbprint }}" 23 | state: absent -------------------------------------------------------------------------------- /tests/playbooks/mp/test_uplink_profiles.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Create uplink profile 11 | vmware.ansible_for_nsxt.nsxt_uplink_profiles: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | resource_type: UplinkHostSwitchProfile 17 | display_name: "{{item.display_name}}" 18 | mtu: 1600 19 | teaming: "{{item.teaming}}" 20 | transport_vlan: "{{item.transport_vlan}}" 21 | state: "present" 22 | with_items: 23 | - "{{uplink_profiles}}" 24 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/policy_modules/01_create_t0_gateway.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: localhost 5 | become: yes 6 | vars_files: 7 | - build_topology_vars.yml 8 | tasks: 9 | - name: Modify Tier0 10 | vmware.ansible_for_nsxt.nsxt_policy_tier0: 11 | hostname: "{{ nsx_manager }}" 12 | username: "{{ nsx_username }}" 13 | password: "{{ nsx_password }}" 14 | validate_certs: "{{ validate_certs }}" 15 | state: "{{ state }}" 16 | display_name: "{{ item.display_name }}" 17 | ha_mode: "{{ item.ha_mode }}" 18 | tags: "{{ item.tags }}" 19 | locale_services: "{{ item.locale_services }}" 20 | with_items: 21 | - "{{ tier0_gateways }}" 22 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/setup_infra/05_setup_edge_cluster.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - setup_infra_vars.yml 9 | tasks: 10 | - name: Add edge cluster 11 | vmware.ansible_for_nsxt.nsxt_edge_clusters: 12 | hostname: "{{ nsx_node1.mgmt_ip }}" 13 | username: "{{ nsx_username }}" 14 | password: "{{ nsx_password }}" 15 | validate_certs: "{{ validate_certs }}" 16 | display_name: "{{ item.display_name }}" 17 | cluster_profile_bindings: "{{ item.cluster_profile_bindings }}" 18 | members: "{{ item.members }}" 19 | state: "{{ state }}" 20 | with_items: 21 | - "{{ edge_clusters }}" 22 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/upgrade/upgrade_vars.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | # 4 | # Variables file for Upgrading NSX-T: 5 | # - NSX-T Cluster 6 | # - Transport Nodes (Edge and Host) 7 | # 8 | { 9 | 10 | # 11 | # Common NSX Appliance variables 12 | # 13 | "nsx_manager": "10.114.200.11", 14 | "nsx_username": "admin", 15 | "nsx_password": "myPassword1!myPassword1!", 16 | "validate_certs": False, 17 | 18 | # Upgrade MUB 19 | "mub_url": "http://10.114.200.8/VMware-NSX-upgrade-bundle-2.5.0.1.0.14938184.mub", 20 | "timeout": 9000, 21 | 22 | # Display names of the hosts as seen by NSX which are to be upgraded 23 | hosts: [ 24 | { 25 | "host_name": "esx-c14" 26 | }, 27 | { 28 | "host_name": "esx-c15" 29 | } 30 | ] 31 | 32 | } 33 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_transport_node_collections.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Attach Transport node profile to cluster 11 | vmware.ansible_for_nsxt.nsxt_transport_node_collections: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: "TNC1" 17 | resource_type: "TransportNodeCollection" 18 | description: "Transport Node Collections 1" 19 | compute_manager_name: "VC1" 20 | cluster_name: "os-compute-cluster-1" 21 | transport_node_profile_name: "TNP1" 22 | state: present 23 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/setup_infra/01_setup_transport_zones_9x.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - setup_infra_vars_9x.yml 9 | tasks: 10 | - name: Create transport zone 11 | vmware.ansible_for_nsxt.nsxt_transport_zones: 12 | hostname: "{{ nsx_node1.mgmt_ip }}" 13 | username: "{{ nsx_username }}" 14 | password: "{{ nsx_password }}" 15 | validate_certs: "{{ validate_certs }}" 16 | resource_type: "TransportZone" 17 | display_name: "{{ item.display_name }}" 18 | description: "{{ item.description }}" 19 | tz_type: "{{item.tz_type}}" 20 | state: "{{ state }}" 21 | with_items: 22 | - "{{ transport_zones }}" 23 | -------------------------------------------------------------------------------- /tests/playbooks/policy/test_nsxt_policy_l2_bridge_ep_profile.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # 5 | # Playbook to test L2 Bridge Endpoint Profile 6 | # 7 | - hosts: localhost 8 | tasks: 9 | - name: update L2 Bridge Endpoint Profile 10 | vmware.ansible_for_nsxt.nsxt_policy_l2_bridge_ep_profile: 11 | hostname: "default" 12 | nsx_cert_path: /root/com.vmware.nsx.ncp/nsx.crt 13 | nsx_key_path: /root/com.vmware.nsx.ncp/nsx.key 14 | validate_certs: True 15 | ca_path: /path/to/my/ca-bundle 16 | display_name: test-br-profile 17 | state: present 18 | edge_nodes_info: 19 | - edge_cluster_display_name: edge-cluster 20 | edge_node_id: 60f7dc14-d11c-11ea-8fb5-000c29e1fb0e 21 | failover_mode: NON_PREEMPTIVE 22 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/policy_modules/05_create_security_policy.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: localhost 5 | become: yes 6 | vars_files: 7 | - build_topology_vars.yml 8 | tasks: 9 | - name: Modify Security Policy 10 | vmware.ansible_for_nsxt.nsxt_policy_security_policy: 11 | hostname: "{{ nsx_manager }}" 12 | username: "{{ nsx_username }}" 13 | password: "{{ nsx_password }}" 14 | validate_certs: "{{ validate_certs }}" 15 | state: "{{ state }}" 16 | display_name: "{{ item.display_name }}" 17 | domain_id: "{{ item.domain_id }}" 18 | category: "{{ item.category }}" 19 | rules: "{{ item.rules }}" 20 | tags: "{{ item.tags }}" 21 | with_items: 22 | - "{{ security_policies }}" 23 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_cluster_profiles.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Add edge cluster 11 | vmware.ansible_for_nsxt.nsxt_cluster_profiles: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | resource_type: EdgeHighAvailabilityProfile 17 | display_name: edge-cluster-profile-East 18 | description: "Edge cluster profile description" 19 | bfd_probe_interval: 1000 20 | bfd_declare_dead_multiple: 3 21 | bfd_allowed_hops: 1 22 | standby_relocation_config: 23 | standby_relocation_threshold: 600 24 | state: present 25 | -------------------------------------------------------------------------------- /tests/playbooks/policy/test_nsxt_policy_group.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # 5 | # Playbook to test Policy Group 6 | # 7 | - hosts: localhost 8 | tasks: 9 | - name: create Policy Group 10 | vmware.ansible_for_nsxt.nsxt_policy_group: 11 | hostname: "default" 12 | nsx_cert_path: /root/com.vmware.nsx.ncp/nsx.crt 13 | nsx_key_path: /root/com.vmware.nsx.ncp/nsx.key 14 | validate_certs: True 15 | ca_path: /path/to/my/ca-bundle 16 | id: test-policy-group 17 | display_name: test-policy-group 18 | state: "present" 19 | domain_id: "default" 20 | expression: 21 | - member_type: "VirtualMachine" 22 | value: "webvm" 23 | key: "Tag" 24 | operator: "EQUALS" 25 | resource_type: "Condition" -------------------------------------------------------------------------------- /tests/playbooks/mp/test_transport_nodes_host_9x.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile_9x.yml 9 | tasks: 10 | - name: Create transport nodes 11 | vmware.ansible_for_nsxt.nsxt_transport_nodes: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: "{{item.display_name}}" 17 | description: "Transport node with host" 18 | host_switch_spec: 19 | resource_type: StandardHostSwitchSpec 20 | host_switches: "{{item.host_switches}}" 21 | node_deployment_info: "{{item.node_deployment_info}}" 22 | state: present 23 | with_items: 24 | - "{{host_transport_nodes}}" -------------------------------------------------------------------------------- /tests/playbooks/mp/test_transport_nodes_edge_9x.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile_9x.yml 9 | tasks: 10 | - name: Create edge transport nodes 11 | vmware.ansible_for_nsxt.nsxt_transport_nodes: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: "{{item.display_name}}" 17 | description: "Edge transport node ansible" 18 | host_switch_spec: 19 | resource_type: StandardHostSwitchSpec 20 | host_switches: "{{item.host_switches}}" 21 | node_deployment_info: "{{item.node_deployment_info}}" 22 | state: present 23 | with_items: 24 | - "{{edge_transport_nodes}}" -------------------------------------------------------------------------------- /tests/playbooks/mp/test_transport_zones.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Create transport zone 11 | vmware.ansible_for_nsxt.nsxt_transport_zones: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | resource_type: "PolicyTransportZone" 17 | display_name: "{{item.display_name}}" 18 | description: "NSX configured Test Transport Zone" 19 | tz_type: "{{item.tz_type}}" 20 | state: "present" 21 | is_default: false 22 | nested_nsx: False 23 | register: result 24 | with_items: 25 | - "{{transportzones}}" 26 | - debug: var=result.id 27 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/policy_modules/03_create_segments.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: localhost 5 | become: yes 6 | vars_files: 7 | - build_topology_vars.yml 8 | tasks: 9 | - name: Modify Segment 10 | vmware.ansible_for_nsxt.nsxt_policy_segment: 11 | hostname: "{{ nsx_manager }}" 12 | username: "{{ nsx_username }}" 13 | password: "{{ nsx_password }}" 14 | state: "{{ state }}" 15 | validate_certs: "{{ validate_certs }}" 16 | display_name: "{{ item.display_name }}" 17 | tier1_id: "{{ item.tier1_display_name }}" 18 | domain_name: "{{ item.domain_name }}" 19 | transport_zone_display_name: "{{ item.tz }}" 20 | subnets: "{{ item.subnets }}" 21 | tags: "{{ item.tags }}" 22 | with_items: 23 | - "{{ segments }}" 24 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_transport_node_profiles.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Create transport node profile 11 | vmware.ansible_for_nsxt.nsxt_transport_node_profiles: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | resource_type: TransportNodeProfile 17 | display_name: "{{item.display_name}}" 18 | description: NSX configured Test Transport Node Profile 19 | host_switch_spec: 20 | resource_type: StandardHostSwitchSpec 21 | host_switches: "{{item.host_switches}}" 22 | state: present 23 | with_items: 24 | - "{{transport_node_profiles}}" 25 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/setup_infra/01_setup_transport_zones.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - setup_infra_vars.yml 9 | tasks: 10 | - name: Create transport zone 11 | vmware.ansible_for_nsxt.nsxt_transport_zones: 12 | hostname: "{{ nsx_node1.mgmt_ip }}" 13 | username: "{{ nsx_username }}" 14 | password: "{{ nsx_password }}" 15 | validate_certs: "{{ validate_certs }}" 16 | resource_type: "TransportZone" 17 | display_name: "{{ item.display_name }}" 18 | description: "{{ item.description }}" 19 | transport_type: "{{ item.transport_type }}" 20 | host_switch_name: "{{ item.host_switch_name }}" 21 | state: "{{ state }}" 22 | with_items: 23 | - "{{ transport_zones }}" 24 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_local_manager_registration.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # Playbook to register Compute Managers with NSX Appliance 4 | # 5 | - hosts: 127.0.0.1 6 | connection: local 7 | become: yes 8 | vars_files: 9 | - answerfile.yml 10 | tasks: 11 | - name: Register local manager 12 | vmware.ansible_for_nsxt.nsxt_local_manager_registration: 13 | hostname: "{{hostname}}" 14 | username: "{{username}}" 15 | password: "{{password}}" 16 | validate_certs: "{{ validate_certs }}" 17 | display_name: "{{ item.display_name }}" 18 | id: "{{ item.id }}" 19 | site_connection_info: 20 | fqdn: "{{ item.fqdn }}" 21 | username: "{{ item.username }}" 22 | password: "{{ item.password }}" 23 | thumbprint: "{{ item.thumbprint }}" 24 | state: absent 25 | with_items: 26 | - "{{local_managers}}" 27 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_transport_nodes_edge.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | tasks: 8 | - name: Create edge transport nodes 9 | vmware.ansible_for_nsxt.nsxt_transport_nodes: 10 | hostname: "{{hostname}}" 11 | username: "{{username}}" 12 | password: "{{password}}" 13 | validate_certs: False 14 | display_name: "{{display_name}}" 15 | description: "Edge transport node ansible" 16 | host_switch_spec: 17 | resource_type: StandardHostSwitchSpec 18 | host_switches: "{{item.host_switches}}" 19 | transport_zone_endpoints: "{{item.transport_zone_endpoints}}" 20 | node_deployment_info: "{{item.node_deployment_info}}" 21 | state: present 22 | with_items: 23 | - "{{edge_transport_nodes}}" -------------------------------------------------------------------------------- /tests/playbooks/topologies/setup_infra/04_setup_transport_nodes_9x.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - setup_infra_vars_9x.yml 9 | tasks: 10 | - name: Create Transport Nodes 11 | vmware.ansible_for_nsxt.nsxt_transport_nodes: 12 | hostname: "{{ nsx_node1.mgmt_ip }}" 13 | username: "{{ nsx_username }}" 14 | password: "{{ nsx_password }}" 15 | validate_certs: "{{ validate_certs }}" 16 | display_name: "{{ item.display_name }}" 17 | host_switch_spec: 18 | resource_type: StandardHostSwitchSpec 19 | host_switches: "{{ item.host_switches }}" 20 | node_deployment_info: "{{ item.node_deployment_info }}" 21 | state: "{{ state }}" 22 | with_items: 23 | - "{{ transport_nodes }}" 24 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_principal_identities.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Register a name-certificate combination 11 | vmware.ansible_for_nsxt.nsxt_principal_identities: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: "Principal_display_name" 17 | description: 'Foo bar' 18 | certificate_name: 'Certificate_file' 19 | name: "Principal_name" 20 | certificate_pem_file: "/Path/to/cert/file" 21 | is_protected: True 22 | node_id: "node-1" 23 | role: "enterprise_admin" 24 | #certificate_name: "Certificate_file" 25 | state: "absent" 26 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_global_manager_registration.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # Playbook to register Compute Managers with NSX Appliance 4 | # 5 | - hosts: 127.0.0.1 6 | connection: local 7 | become: yes 8 | vars_files: 9 | - answerfile.yml 10 | tasks: 11 | - name: Register global manager 12 | vmware.ansible_for_nsxt.nsxt_global_manager_registration: 13 | hostname: "{{ hostname }}" 14 | username: "{{ username }}" 15 | password: "{{ password }}" 16 | validate_certs: "{{ validate_certs }}" 17 | display_name: "{{ item.display_name }}" 18 | mode: "{{ item.mode }}" 19 | connection_info: 20 | fqdn: "{{ item.fqdn }}" 21 | username: "{{ item.username }}" 22 | password: "{{ item.password }}" 23 | thumbprint: "{{ item.thumbprint }}" 24 | state: absent 25 | with_items: 26 | - "{{global_managers}}" 27 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_logical_router_ports.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Create logical router port 11 | vmware.ansible_for_nsxt.nsxt_logical_router_ports: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: "lrouterport-103" 17 | resource_type: "LogicalRouterDownLinkPort" 18 | logical_router_name: "tier-0" 19 | linked_logical_switch_port_id: 20 | target_type: "LogicalPort" 21 | target_id: "fa535fbd-c01f-4536-86e4-36ee3572b6f3" 22 | subnets: 23 | - ip_addresses: 24 | - 192.168.3.1 25 | prefix_length: 24 26 | state: "present" 27 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_local_managers_compatibility.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # Playbook to register Compute Managers with NSX Appliance 4 | # 5 | - hosts: 127.0.0.1 6 | connection: local 7 | become: yes 8 | vars_files: 9 | - answerfile.yml 10 | tasks: 11 | - name: Checks the compatibility of a local manager for registration with a global manager 12 | vmware.ansible_for_nsxt.nsxt_local_managers_compatibility: 13 | hostname: "{{ hostname }}" 14 | username: "{{ username }}" 15 | password: "{{ password }}" 16 | validate_certs: "{{ validate_certs }}" 17 | site_connection_info: 18 | fqdn: "{{ local_managers[0].fqdn }}" 19 | username: "{{ local_managers[0].username }}" 20 | password: "{{ local_managers[0].password }}" 21 | thumbprint: "{{ local_managers[0].thumbprint }}" 22 | register: task_output 23 | - debug: 24 | var: task_output.version_compatible 25 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_transport_nodes_host.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Create transport nodes 11 | vmware.ansible_for_nsxt.nsxt_transport_nodes: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: "{{item.display_name}}" 17 | description: "Transport node with host" 18 | host_switch_spec: 19 | resource_type: StandardHostSwitchSpec 20 | host_switches: "{{item.host_switches}}" 21 | transport_zone_endpoints: "{{item.transport_zone_endpoints}}" 22 | node_deployment_info: "{{item.node_deployment_info}}" 23 | state: present 24 | with_items: 25 | - "{{host_transport_nodes}}" -------------------------------------------------------------------------------- /tests/playbooks/topologies/setup_infra/03_setup_transport_node_profiles_9x.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - setup_infra_vars_9x.yml 9 | tasks: 10 | - name: Create Transport Node Profiles 11 | vmware.ansible_for_nsxt.nsxt_transport_node_profiles: 12 | hostname: "{{ nsx_node1.mgmt_ip }}" 13 | username: "{{ nsx_username }}" 14 | password: "{{ nsx_password }}" 15 | validate_certs: "{{ validate_certs }}" 16 | resource_type: TransportNodeProfile 17 | display_name: "{{ item.display_name }}" 18 | description: "{{ item.description }}" 19 | host_switch_spec: 20 | resource_type: StandardHostSwitchSpec 21 | host_switches: "{{ item.host_switches }}" 22 | state: "{{ state }}" 23 | with_items: 24 | - "{{ transport_node_profiles }}" 25 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/setup_infra/04_setup_transport_nodes.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - setup_infra_vars.yml 9 | tasks: 10 | - name: Create Transport Nodes 11 | vmware.ansible_for_nsxt.nsxt_transport_nodes: 12 | hostname: "{{ nsx_node1.mgmt_ip }}" 13 | username: "{{ nsx_username }}" 14 | password: "{{ nsx_password }}" 15 | validate_certs: "{{ validate_certs }}" 16 | display_name: "{{ item.display_name }}" 17 | host_switch_spec: 18 | resource_type: StandardHostSwitchSpec 19 | host_switches: "{{ item.host_switches }}" 20 | transport_zone_endpoints: "{{ item.transport_zone_endpoints }}" 21 | node_deployment_info: "{{ item.node_deployment_info }}" 22 | state: "{{ state }}" 23 | with_items: 24 | - "{{ transport_nodes }}" 25 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_compute_managers.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Register compute manager 11 | vmware.ansible_for_nsxt.nsxt_fabric_compute_managers: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | #compute_manager_id: "25d314b6-97f2-48e2-87b5-f9ce04caf5f8" 17 | display_name: "{{item.display_name}}" 18 | server: "{{item.server}}" 19 | origin_type: "{{item.origin_type}}" 20 | credential: 21 | credential_type: "{{item.credential_type}}" 22 | username: "{{item.username}}" 23 | password: "{{item.password}}" 24 | thumbprint: "{{item.thumbprint}}" 25 | state: present 26 | with_items: 27 | - "{{compute_managers}}" 28 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/setup_infra/03_setup_transport_node_profiles.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - setup_infra_vars.yml 9 | tasks: 10 | - name: Create Transport Node Profiles 11 | vmware.ansible_for_nsxt.nsxt_transport_node_profiles: 12 | hostname: "{{ nsx_node1.mgmt_ip }}" 13 | username: "{{ nsx_username }}" 14 | password: "{{ nsx_password }}" 15 | validate_certs: "{{ validate_certs }}" 16 | resource_type: TransportNodeProfile 17 | display_name: "{{ item.display_name }}" 18 | description: "{{ item.description }}" 19 | host_switch_spec: 20 | resource_type: StandardHostSwitchSpec 21 | host_switches: "{{ item.host_switches }}" 22 | transport_zone_endpoints: "{{ item.transport_zone_endpoints }}" 23 | state: "{{ state }}" 24 | with_items: 25 | - "{{ transport_node_profiles }}" 26 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/setup_infra/README.md: -------------------------------------------------------------------------------- 1 | # Setup Day-1 Infra 2 | 3 | # Overview 4 | The set of playbooks in this example deploy all the Day-1 Infra objects needed 5 | to start using NSX-T. The playbooks are divided based on the workflow. 6 | 7 | There are 4 main playbooks and a common variable file: 8 | 9 | * 01_setup_transport_zones.yml 10 | * 02_setup_TEP_IP_Pools.yml: In this example, a single IP Pool is used to provide TEP IP for both Edge and Host Transport nodes. 11 | * 03_setup_transport_node_profiles.yml 12 | * 04_setup_transport_nodes.yml: Creates both Edge and Host Transport nodes 13 | * 05_setup_edge_cluster.yml 14 | * setup_infra_vars.yml: The variables file 15 | 16 | To delete all objects, change the 'state' to 'absent' in the variables file and run the playbooks in the reverse order: 17 | 18 | * 05_setup_edge_cluster.yml 19 | * 04_setup_transport_nodes.yml 20 | * 03_setup_transport_node_profiles.yml 21 | * 02_setup_TEP_IP_Pools.yml 22 | * 01_setup_transport_zone.yml 23 | 24 | Validated against: 25 | * NSX-T 2.4 GA 26 | * NSX-T 2.5 GA 27 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/setup_infra/06_setup_transport_node_collections.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - setup_infra_vars.yml 9 | tasks: 10 | - name: Create Transport Node Collections 11 | vmware.ansible_for_nsxt.nsxt_transport_node_collections: 12 | hostname: "{{ nsx_node1.mgmt_ip }}" 13 | username: "{{ nsx_username }}" 14 | password: "{{ nsx_password }}" 15 | validate_certs: "{{ validate_certs }}" 16 | display_name: "{{ item.display_name }}" 17 | description: "{{ item.description }}" 18 | resource_type: "TransportNodeCollection" 19 | compute_manager_name: "{{ item.compute_manager_name }}" 20 | cluster_name: "{{ item.cluster_name }}" 21 | transport_node_profile_name: "{{ item.transport_node_profile_name }}" 22 | state: "{{ state }}" 23 | with_items: 24 | - "{{ transport_node_collections }}" 25 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/upgrade/04_upgrade_update_plan.yml: -------------------------------------------------------------------------------- 1 | - hosts: 127.0.0.1 2 | connection: local 3 | become: yes 4 | vars_files: 5 | - upgrade_vars.yml 6 | tasks: 7 | - name: Update upgrade plan for Hosts 8 | vmware.ansible_for_nsxt.nsxt_upgrade_plan: 9 | hostname: "{{ nsx_manager }}" 10 | username: "{{ nsx_username }}" 11 | password: "{{ nsx_password }}" 12 | validate_certs: "{{ validate_certs }}" 13 | component_type: 'host' 14 | parallel: False 15 | pause_after_each_group: False 16 | pause_on_error: True 17 | state: 'present' 18 | - name: Update upgrade plan for Edges 19 | vmware.ansible_for_nsxt.nsxt_upgrade_plan: 20 | hostname: "{{ nsx_manager }}" 21 | username: "{{ nsx_username }}" 22 | password: "{{ nsx_password }}" 23 | validate_certs: "{{ validate_certs }}" 24 | component_type: 'edge' 25 | parallel: False 26 | pause_after_each_group: False 27 | pause_on_error: True 28 | state: 'present' 29 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/upgrade/README.md: -------------------------------------------------------------------------------- 1 | # Upgrade NSX-T Cluster 2 | 3 | # Overview 4 | The set of playbooks in this example does a full NSX upgrade (including 5 | Host Transport Nodes and Edge Transport Nodes). The playbooks 6 | are divided based on the workflow. 7 | 8 | There are 7 main playbooks and a common variable files: 9 | 10 | * 01_upgrade_upload_mub.yml 11 | * 02_upgrade_accept_eula.yml 12 | * 03_upgrade_uc.yml 13 | * 04_upgrade_update_plan.yml 14 | * [ OPTIONAL ] 05_upgrade_update_groups.yml 15 | * 06_upgrade_prechecks.yml 16 | * 07_upgrade_run.yml 17 | * upgrade_vars.yml 18 | 19 | The following playbooks can be used to check the status of different objects during 20 | the upgrade process 21 | 22 | check_upgrade_groups_facts.yml 23 | 24 | check_upgrade_pre_post_checks_facts.yml 25 | 26 | check_upgrade_status_summary_facts.yml 27 | 28 | 29 | To run the example, copy all the files two-levels up, edit the variables file 30 | to match your needs and run the playbooks in the order listed. 31 | 32 | Validated against: 33 | * NSX-T 2.5 GA --> NSX-T 2.5.1 GA 34 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_route_advertise.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Toggle tier 1 route advertisement 11 | vmware.ansible_for_nsxt.nsxt_route_advertise: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | display_name: "{{item.display_name}}" 16 | validate_certs: False 17 | enabled: "{{item.enabled}}" 18 | advertise_dns_forwarder: "{{item.advertise_dns_forwarder}}" 19 | advertise_lb_snat_ip: "{{item.advertise_lb_snat_ip}}" 20 | advertise_lb_vip: "{{item.advertise_lb_vip}}" 21 | advertise_nat_routes: "{{item.advertise_nat_routes}}" 22 | advertise_nsx_connected_routes: "{{item.advertise_nsx_connected_routes}}" 23 | advertise_static_routes: "{{item.advertise_static_routes}}" 24 | with_items: 25 | - "{{route_advertise}}" 26 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/deploy_nsx_cluster/02_configure_compute_manager.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # 5 | # Playbook to register Compute Managers with NSX Appliance 6 | # 7 | - hosts: 127.0.0.1 8 | connection: local 9 | become: yes 10 | vars_files: 11 | - deploy_nsx_cluster_vars.yml 12 | tasks: 13 | - name: Register compute manager 14 | vmware.ansible_for_nsxt.nsxt_fabric_compute_managers: 15 | hostname: "{{ nsx_node1.mgmt_ip }}" 16 | username: "{{ nsx_username }}" 17 | password: "{{ nsx_password }}" 18 | validate_certs: "{{ validate_certs }}" 19 | display_name: "{{ item.display_name }}" 20 | server: "{{ item.mgmt_ip }}" 21 | origin_type: "{{ item.origin_type }}" 22 | credential: 23 | credential_type: "{{ item.credential_type }}" 24 | username: "{{ item.username }}" 25 | password: "{{ item.password }}" 26 | state: present 27 | with_items: 28 | - "{{compute_managers}}" 29 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/upgrade/05_upgrade_update_groups.yml: -------------------------------------------------------------------------------- 1 | - hosts: 127.0.0.1 2 | connection: local 3 | become: yes 4 | vars_files: 5 | - upgrade_vars.yml 6 | tasks: 7 | - name: Create upgrade groups 8 | vmware.ansible_for_nsxt.nsxt_upgrade_groups: 9 | hostname: "{{ nsx_manager }}" 10 | username: "{{ nsx_username }}" 11 | password: "{{ nsx_password }}" 12 | validate_certs: "{{ validate_certs }}" 13 | display_name: "TestGroupAnsible" 14 | type: "HOST" 15 | parallel: "False" 16 | enabled: "true" 17 | upgrade_units: "{{ hosts }}" 18 | state: "present" 19 | # extended_configuration: 20 | # - key: "upgrade_mode" 21 | # value: "in_place" 22 | # - key: "rebootless_upgrade" 23 | # value: "true" 24 | extended_configuration: 25 | - key: "upgrade_mode" 26 | value: "maintenance_mode" 27 | - key: "rebootless_upgrade" 28 | value: "true" 29 | - key: "maintenance_mode_config_evacuate_powerd_off_vms" 30 | value: "false" 31 | state: "present" 32 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_logical_routers.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Create logical router 11 | vmware.ansible_for_nsxt.nsxt_logical_routers: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: "tier-0" 17 | edge_cluster_name: "edge-cluster-1" 18 | router_type: "TIER0" 19 | high_availability_mode: "ACTIVE_ACTIVE" 20 | state: "present" 21 | failover_mode: "NON_PREEMPTIVE" 22 | advanced_config: 23 | internal_transit_network: "169.254.0.0/28" 24 | ha_vip_configs: 25 | - enabled: False 26 | ha_vip_subnets: 27 | - active_vip_addresses: [ "12.12.4.4" ] 28 | prefix_length: "22" 29 | redundant_uplink_port_ids: [ "Uplink-1","Uplink-2" ] 30 | - enabled: False 31 | ha_vip_subnets: 32 | - active_vip_addresses: [ "12.12.4.5" ] 33 | prefix_length: "22" 34 | redundant_uplink_port_names: [ "Uplink-3","Uplink-4" ] 35 | redundant_uplink_port_ids: ["z", "y"] 36 | tags: 37 | - scope: "Scope1" 38 | tag: "Tag1" -------------------------------------------------------------------------------- /tests/playbooks/policy/test_nsxt_policy_security_policy.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # 5 | # Playbook to test Security Policy 6 | # 7 | - hosts: localhost 8 | tasks: 9 | - name: create Security Policy 10 | vmware.ansible_for_nsxt.nsxt_policy_security_policy: 11 | hostname: "default" 12 | nsx_cert_path: /root/com.vmware.nsx.ncp/nsx.crt 13 | nsx_key_path: /root/com.vmware.nsx.ncp/nsx.key 14 | validate_certs: True 15 | ca_path: /path/to/my/ca-bundle 16 | id: test-sec-pol 17 | display_name: test-sec-pol 18 | state: "present" 19 | domain_id: "default" 20 | locked: True 21 | rules: 22 | - action: "ALLOW" 23 | description: "example-rule" 24 | sequence_number: 1 25 | display_name: "test-example-rule" 26 | id: "test-example-rule" 27 | source_groups: ["/infra/domains/vmc/groups/dbgroup"] 28 | destination_groups: ["/infra/domains/vmc/groups/appgroup"] 29 | services: ["/infra/services/HTTP", "/infra/services/CIM-HTTP"] 30 | tag: my-tag 31 | tags: 32 | - scope: scope-1 33 | tag: tag-1 34 | logged: True 35 | notes: dummy-notes 36 | ip_protocol: IPV4_IPV6 37 | scope: 38 | - /infra/tier-0s/PLR1 39 | profiles: "encryption algorithm" -------------------------------------------------------------------------------- /tests/playbooks/policy/test_nsxt_policy_gateway_policy.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # 5 | # Playbook to test Gateway Policy 6 | # 7 | - hosts: localhost 8 | tasks: 9 | - name: create Gateway Policy 10 | vmware.ansible_for_nsxt.nsxt_policy_gateway_policy: 11 | hostname: "default" 12 | nsx_cert_path: /root/com.vmware.nsx.ncp/nsx.crt 13 | nsx_key_path: /root/com.vmware.nsx.ncp/nsx.key 14 | validate_certs: True 15 | ca_path: /path/to/my/ca-bundle 16 | id: test-gateway-policy 17 | display_name: test-gateway-policy 18 | state: "present" 19 | domain_id: "default" 20 | locked: True 21 | rules: 22 | - action: "ALLOW" 23 | description: "example-rule" 24 | sequence_number: 1 25 | display_name: "test-example-rule" 26 | id: "test-example-rule" 27 | source_groups: ["/infra/domains/vmc/groups/dbgroup"] 28 | destination_groups: ["/infra/domains/vmc/groups/appgroup"] 29 | services: ["/infra/services/HTTP", "/infra/services/CIM-HTTP"] 30 | tag: my-tag 31 | tags: 32 | - scope: scope-1 33 | tag: tag-1 34 | logged: True 35 | notes: dummy-notes 36 | ip_protocol: IPV4_IPV6 37 | scope: 38 | - /infra/tier-0s/PLR1 39 | profiles: "encryption algorithm" -------------------------------------------------------------------------------- /tests/playbooks/mp/answerfile_attach_tnp_to_cluster.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | hostname: "10.161.157.200" 5 | username: "admin" 6 | password: "Admin!23Admin" 7 | validate_certs: False 8 | 9 | ip_pools: 10 | - display_name: IPPool-IPV4-1 11 | subnets: 12 | - allocation_ranges: 13 | - start: "10.112.201.28" 14 | end: "10.112.201.35" 15 | cidr: "10.112.201.0/24" 16 | 17 | transportzones: 18 | - display_name: "TZ1" 19 | transport_type: "OVERLAY" 20 | host_switch_name: "hostswitch1" 21 | 22 | uplink_profiles: 23 | - display_name: uplinkProfile1 24 | teaming: 25 | active_list: 26 | - uplink_name: "uplink-1" 27 | uplink_type: PNIC 28 | policy: FAILOVER_ORDER 29 | transport_vlan: 0 30 | 31 | transport_node_profiles: 32 | - display_name: TNP1 33 | host_switches: 34 | - host_switch_profiles: 35 | - name: uplinkProfile1 36 | type: UplinkHostSwitchProfile 37 | host_switch_name: hostswitch1 38 | pnics: 39 | - device_name: vmnic1 40 | uplink_name: "uplink-1" 41 | ip_assignment_spec: 42 | resource_type: StaticIpPoolSpec 43 | ip_pool_name: "IPPool-IPV4-1" 44 | transport_zone_endpoints: 45 | - transport_zone_name: "TZ1" 46 | 47 | 48 | compute_managers: 49 | - display_name: "VC1" 50 | server: "10.161.129.87" 51 | origin_type: vCenter 52 | credential_type: UsernamePasswordLoginCredential 53 | username: "administrator@vsphere.local" 54 | password: "Admin!23" 55 | thumbprint: "46:1E:31:DD:0B:37:4C:F0:91:5B:49:A1:A1:94:B5:DF:82:93:90:52:D9:68:0F:86:C8:CA:6C:34:CB:82:D7:D5" 56 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_ovf_deployment.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: deploy NSX Manager OVA 11 | vmware.ansible_for_nsxt.nsxt_deploy_ova: 12 | ovftool_path: "/usr/bin" 13 | #folder: 'folder-os-datacenter' 14 | datacenter: "os-datacenter" 15 | datastore: "datastore" 16 | portgroup: "VM Network" 17 | cluster: "os-compute-cluster-1" 18 | vmname: "nsxt-manager" 19 | hostname: "nsxt-manager-10" 20 | dns_server: "10.172.40.1 FD01:1:3:1001::10" 21 | dns_domain: "eng.vmware.com" 22 | ntp_server: "10.172.40.1 FD01:1:3:1001::10" 23 | gateway: "10.176.135.253" 24 | gateway6_0: "2620:124:6020:1045::253" 25 | ip_address: "10.176.132.59" 26 | ip_address6_0: "2620:124:6020:1045::1a" 27 | netmask: "255.255.252.0" 28 | netmask6_0: "64" 29 | admin_password: "Admin!23Admin" 30 | cli_password: "Admin!23Admin" 31 | path_to_ova: "http://build-squid.eng.vmware.com/build/mts/release/bora-19956989/publish/nsx-unified-appliance/exports/ovf" 32 | ova_file: "nsx-unified-appliance-4.0.1.0.0.19956985.ovf" 33 | vcenter: "10.176.132.1" 34 | vcenter_user: "administrator@vsphere.local" 35 | vcenter_passwd: "Admin!23" 36 | deployment_size: "small" 37 | role: "NSX Manager" 38 | ssh_enabled: true 39 | allow_ssh_root_login: true 40 | disk_mode: thin 41 | ip_protocol: IPv6 42 | 43 | 44 | -------------------------------------------------------------------------------- /tests/playbooks/mp/answerfile_attach_tnp_to_cluster_9x.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | hostname: "10.161.157.200" 5 | username: "admin" 6 | password: "Admin!23Admin" 7 | validate_certs: False 8 | 9 | ip_pools: 10 | - display_name: IPPool-IPV4-1 11 | pool_static_subnets: 12 | - display_name: test-ip-static-subnet-1 13 | state: present 14 | allocation_ranges: 15 | - start: "10.112.201.28" 16 | end: "10.112.201.35" 17 | cidr: "10.112.201.0/24" 18 | 19 | transportzones: 20 | - display_name: "TZ1" 21 | tz_type: "OVERLAY_BACKED" 22 | 23 | uplink_profiles: 24 | - display_name: uplinkProfile1 25 | teaming: 26 | active_list: 27 | - uplink_name: "uplink-1" 28 | uplink_type: PNIC 29 | policy: FAILOVER_ORDER 30 | transport_vlan: 0 31 | 32 | transport_node_profiles: 33 | - display_name: TNP1 34 | host_switches: 35 | - host_switch_profiles: 36 | - name: uplinkProfile1 37 | type: UplinkHostSwitchProfile 38 | host_switch_name: hostswitch1 39 | host_switch_type: VDS 40 | uplinks: 41 | - vds_uplink_name: Uplink 1 42 | uplink_name: uplink-1 43 | ip_assignment_spec: 44 | resource_type: StaticIpPoolSpec 45 | ip_pool_name: "IPPool-IPV4-1" 46 | transport_zone_endpoints: 47 | - transport_zone_name: "TZ1" 48 | 49 | 50 | compute_managers: 51 | - display_name: "VC1" 52 | server: "10.161.129.87" 53 | origin_type: vCenter 54 | credential_type: UsernamePasswordLoginCredential 55 | username: "administrator@vsphere.local" 56 | password: "Admin!23" 57 | thumbprint: "46:1E:31:DD:0B:37:4C:F0:91:5B:49:A1:A1:94:B5:DF:82:93:90:52:D9:68:0F:86:C8:CA:6C:34:CB:82:D7:D5" 58 | -------------------------------------------------------------------------------- /tests/playbooks/policy/test_nsxt_policy_ip_pool.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # 5 | # Playbook to test IP Pool 6 | # 7 | - hosts: localhost 8 | tasks: 9 | - name: create IP Pool 10 | vmware.ansible_for_nsxt.nsxt_policy_ip_pool: 11 | hostname: "default" 12 | nsx_cert_path: /root/com.vmware.nsx.ncp/nsx.crt 13 | nsx_key_path: /root/com.vmware.nsx.ncp/nsx.key 14 | validate_certs: True 15 | ca_path: /path/to/my/ca-bundle 16 | display_name: test-ip-pool-1 17 | state: "present" 18 | tags: 19 | - tag: "a" 20 | scope: "b" 21 | pool_block_subnets: 22 | - id: test-ip-subnet-1 23 | state: present 24 | ip_block_id: "test-ip-blk-1" 25 | size: 16 26 | - display_name: test-ip-subnet-2 27 | state: present 28 | ip_block_id: "test-ip-blk-1" 29 | size: 16 30 | - display_name: test-ip-subnet-3 31 | state: present 32 | ip_block_id: "test-ip-blk-1" 33 | size: 8 34 | pool_static_subnets: 35 | - id: test-ip-static-subnet-1 36 | state: present 37 | allocation_ranges: 38 | - start: '192.116.0.10' 39 | end: '192.116.0.20' 40 | - start: '192.116.0.30' 41 | end: '192.116.0.40' 42 | cidr: '192.116.0.0/26' 43 | - display_name: test-ip-static-subnet-2 44 | state: present 45 | allocation_ranges: 46 | - start: '192.116.1.10' 47 | end: '192.116.1.20' 48 | - start: '192.116.1.30' 49 | end: '192.116.1.40' 50 | cidr: '192.116.1.0/26' -------------------------------------------------------------------------------- /tests/playbooks/mp/answerfile_tn_9x.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | hostname: "10.161.157.200" 5 | username: "admin" 6 | password: "Admin!23Admin" 7 | validate_certs: False 8 | 9 | ip_pools: 10 | - display_name: IPPool-IPV4-1 11 | pool_static_subnets: 12 | - display_name: test-ip-static-subnet-1 13 | state: present 14 | allocation_ranges: 15 | - start: "10.112.201.28" 16 | end: "10.112.201.35" 17 | cidr: "10.112.201.0/24" 18 | 19 | transportzones: 20 | - display_name: "TZ1" 21 | tz_type: "OVERLAY_BACKED" 22 | 23 | uplink_profiles: 24 | - display_name: uplinkProfile1 25 | teaming: 26 | active_list: 27 | - uplink_name: "uplink-1" 28 | uplink_type: PNIC 29 | policy: FAILOVER_ORDER 30 | transport_vlan: 0 31 | 32 | transport_nodes: 33 | - display_name: TN1 34 | host_switches: 35 | - host_switch_profiles: 36 | - name: uplinkProfile1 37 | type: UplinkHostSwitchProfile 38 | host_switch_name: hostswitch1 39 | host_switch_type: VDS 40 | host_switch_mode: ENS_INTERRUPT 41 | uplinks: 42 | - vds_uplink_name: Uplink 1 43 | uplink_name: uplink-1 44 | ip_assignment_spec: 45 | resource_type: StaticIpPoolSpec 46 | ip_pool_name: "IPPool-IPV4-1" 47 | transport_zone_endpoints: 48 | - transport_zone_name: "TZ1" 49 | node_deployment_info: 50 | # Host node deployment info ESXI 51 | resource_type: "HostNode" 52 | display_name: "Host_1" 53 | ip_addresses: ["10.161.96.247"] 54 | os_type: "ESXI" 55 | os_version: "9.0.0" 56 | host_credential: 57 | username: "root" 58 | password: "ca$hc0w" 59 | thumbprint: "85:03:6A:33:CA:AF:EE:24:67:C0:02:F5:B0:77:AE:DD:FC:31:19:93:44:77:76:C9:E6:4B:61:4D:9A:9E:72:98" 60 | -------------------------------------------------------------------------------- /tests/playbooks/mp/answerfile_tn.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | hostname: "10.161.157.200" 5 | username: "admin" 6 | password: "Admin!23Admin" 7 | validate_certs: False 8 | 9 | ip_pools: 10 | - display_name: IPPool-IPV4-1 11 | subnets: 12 | - allocation_ranges: 13 | - start: "10.112.201.28" 14 | end: "10.112.201.35" 15 | cidr: "10.112.201.0/24" 16 | 17 | transportzones: 18 | - display_name: "TZ1" 19 | transport_type: "OVERLAY" 20 | host_switch_name: "hostswitch1" 21 | 22 | uplink_profiles: 23 | - display_name: uplinkProfile1 24 | teaming: 25 | active_list: 26 | - uplink_name: "uplink-1" 27 | uplink_type: PNIC 28 | policy: FAILOVER_ORDER 29 | transport_vlan: 0 30 | 31 | transport_nodes: 32 | - display_name: TN1 33 | host_switches: 34 | - host_switch_profiles: 35 | - name: uplinkProfile1 36 | type: UplinkHostSwitchProfile 37 | host_switch_name: hostswitch1 38 | # pnics: 39 | # - device_name: "vmnic1" 40 | # uplink_name: "uplink-1" 41 | ip_assignment_spec: 42 | resource_type: StaticIpPoolSpec 43 | ip_pool_name: "IPPool-IPV4-1" 44 | transport_zone_endpoints: 45 | - transport_zone_name: "TZ1" 46 | node_deployment_info: 47 | # Host node deployment info ESXI 48 | # resource_type: "HostNode" 49 | # display_name: "Host_1" 50 | # ip_addresses: ["10.161.136.35"] 51 | # os_type: "ESXI" 52 | # os_version: "6.5.0" 53 | # host_credential: 54 | # username: "root" 55 | # password: "ca$hc0w" 56 | # thumbprint: "aba87c8b3a042435e0f3d60784c1fbc6f1aba5ce71f6efb2601fd26fb5453bb0" 57 | resource_type: "HostNode" 58 | display_name: "Host_3" 59 | ip_addresses: ["10.192.44.93"] 60 | os_type: "UBUNTUKVM" 61 | os_version: "16.04" 62 | host_credential: 63 | username: "root" 64 | password: "ca$hc0w" 65 | thumbprint: "3fS+Ik4O0GOMuQ8Chbxfn7KBLjmLhhnEHPKDXnt/AFQ=" 66 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/deploy_nsx_cluster/01_deploy_first_node.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # 5 | # Playbook to deploy the first NSX Appliance node. Also checks the node 6 | # status 7 | # 8 | - hosts: 127.0.0.1 9 | connection: local 10 | become: yes 11 | vars_files: 12 | - deploy_nsx_cluster_vars.yml 13 | tasks: 14 | - name: deploy NSX Manager OVA 15 | vmware.ansible_for_nsxt.nsxt_deploy_ova: 16 | ovftool_path: "/usr/bin" 17 | datacenter: "{{ nsx_node1['datacenter'] }}" 18 | datastore: "{{ nsx_node1['datastore'] }}" 19 | portgroup: "{{ nsx_node1['portgroup'] }}" 20 | cluster: "{{ nsx_node1['cluster'] }}" 21 | vmname: "{{ nsx_node1['hostname'] }}" 22 | hostname: "{{ nsx_node1['hostname'] }}" 23 | dns_server: "{{ dns_server }}" 24 | dns_domain: "{{ domain }}" 25 | ntp_server: "{{ ntp_server }}" 26 | gateway: "{{ gateway }}" 27 | ip_address: "{{ nsx_node1['mgmt_ip'] }}" 28 | netmask: "{{ netmask }}" 29 | admin_password: "{{ nsx_password }}" 30 | cli_password: "{{ nsx_password }}" 31 | path_to_ova: "{{ nsx_ova_path }}" 32 | ova_file: "{{ nsx_ova }}" 33 | vcenter: "{{ compute_managers[0]['mgmt_ip'] }}" 34 | vcenter_user: "{{ compute_managers[0]['username'] }}" 35 | vcenter_passwd: "{{ compute_managers[0]['password'] }}" 36 | deployment_size: "small" 37 | # Note: The role below is for NSX 2.5 and above. For prior 38 | # release, the role should be "nsx-manager nsx-controller" 39 | role: "NSX Manager" 40 | 41 | - name: Check manager status 42 | vmware.ansible_for_nsxt.nsxt_manager_status: 43 | hostname: "{{ nsx_node1['mgmt_ip'] }}" 44 | username: "{{ nsx_username }}" 45 | password: "{{ nsx_password }}" 46 | validate_certs: "{{ validate_certs }}" 47 | wait_time: 50 48 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/deploy_nsx_cluster/03_deploy_second_third_node.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # 5 | # Deploys remaining NSX appliance nodes and forms a cluster. Requires the first 6 | # NSX appliance node to be deployed and at least one Compute Manager registered. 7 | # 8 | - hosts: 127.0.0.1 9 | connection: local 10 | become: yes 11 | vars_files: 12 | - deploy_nsx_cluster_vars.yml 13 | tasks: 14 | - name: Deploying additional nodes 15 | vmware.ansible_for_nsxt.nsxt_manager_auto_deployment: 16 | hostname: "{{ nsx_node1.mgmt_ip }}" 17 | username: "{{ nsx_username }}" 18 | password: "{{ nsx_password }}" 19 | validate_certs: "{{ validate_certs }}" 20 | deployment_requests: 21 | - roles: 22 | - CONTROLLER 23 | - MANAGER 24 | form_factor: "SMALL" 25 | user_settings: 26 | cli_password: "{{ nsx_password }}" 27 | root_password: "{{ nsx_password }}" 28 | deployment_config: 29 | placement_type: VsphereClusterNodeVMDeploymentConfig 30 | vc_name: "{{ compute_managers[0]['display_name'] }}" 31 | vc_username: "{{ compute_managers[0]['username'] }}" 32 | vc_password: "{{ compute_managers[0]['password'] }}" 33 | management_network: "{{ item.portgroup }}" 34 | hostname: "{{ item.hostname }}" 35 | compute: "{{ item.cluster }}" 36 | storage: "{{ item.datastore }}" 37 | default_gateway_addresses: 38 | - "{{ gateway }}" 39 | dns_servers: 40 | - "{{ dns_server }}" 41 | ntp_servers: 42 | - "{{ ntp_server }}" 43 | management_port_subnets: 44 | - ip_addresses: 45 | - "{{ item.mgmt_ip }}" 46 | prefix_length: "{{ item.prefix }}" 47 | state: present 48 | with_items: 49 | - "{{ additional_nodes }}" 50 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_manager_auto_deployment.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Deploy and register a cluster node VM 11 | vmware.ansible_for_nsxt.nsxt_manager_auto_deployment: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | deployment_requests: 17 | - roles: 18 | - CONTROLLER 19 | - MANAGER 20 | form_factor: "SMALL" 21 | user_settings: 22 | cli_password: "Admin!23Admin" 23 | root_password: "Admin!23Admin" 24 | audit_password: "Admin!23Admin" 25 | deployment_config: 26 | ignore_ssl_verification: False 27 | placement_type: VsphereClusterNodeVMDeploymentConfig 28 | vc_name: "VC1" 29 | vc_username: "administrator@vsphere.local" 30 | vc_password: "Admin!23" 31 | management_network: "VM Network" 32 | hostname: "manager5.vmware.com" 33 | compute: "HostCluster" 34 | storage: "datastore01" 35 | disk_provisioning: "THIN" 36 | default_gateway_addresses: 37 | - 10.176.135.253 38 | management_port_subnets: 39 | - ip_addresses: 40 | - 10.176.132.57 41 | prefix_length: "19" 42 | dns_servers: 43 | - 10.172.40.1 44 | - FD01:1:3:1001::10 45 | management_port_ipv6_subnets: 46 | - ip_addresses: 47 | - 2620:124:6020:1045::1b 48 | prefix_length: "64" 49 | default_ipv6_gateway_addresses: 50 | - 2620:124:6020:1045::253 51 | #node_id: 7503e86e-c502-46fc-8d91-45a06d314d88 52 | state: present 53 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_configure_transport_node_9x.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile_tn_9x.yml 9 | tasks: 10 | 11 | - name: Create ip pool 12 | vmware.ansible_for_nsxt.nsxt_policy_ip_pool: 13 | hostname: "{{hostname}}" 14 | username: "{{username}}" 15 | password: "{{password}}" 16 | validate_certs: False 17 | display_name: "{{item.display_name}}" 18 | pool_static_subnets: "{{item.pool_static_subnets}}" 19 | state: present 20 | with_items: 21 | - "{{ip_pools}}" 22 | 23 | - name: Create transport zone 24 | vmware.ansible_for_nsxt.nsxt_transport_zones: 25 | hostname: "{{hostname}}" 26 | username: "{{username}}" 27 | password: "{{password}}" 28 | validate_certs: False 29 | resource_type: "TransportZone" 30 | display_name: "{{item.display_name}}" 31 | description: "NSX configured Test Transport Zone" 32 | tz_type: "{{item.tz_type}}" 33 | state: "present" 34 | with_items: 35 | - "{{transportzones}}" 36 | 37 | - name: Create uplink profile 38 | vmware.ansible_for_nsxt.nsxt_uplink_profiles: 39 | hostname: "{{hostname}}" 40 | username: "{{username}}" 41 | password: "{{password}}" 42 | validate_certs: False 43 | resource_type: UplinkHostSwitchProfile 44 | display_name: "{{item.display_name}}" 45 | mtu: 1600 46 | teaming: "{{item.teaming}}" 47 | transport_vlan: "{{item.transport_vlan}}" 48 | state: "present" 49 | with_items: 50 | - "{{uplink_profiles}}" 51 | 52 | - name: Create transport node 53 | vmware.ansible_for_nsxt.nsxt_transport_nodes: 54 | hostname: "{{hostname}}" 55 | username: "{{username}}" 56 | password: "{{password}}" 57 | validate_certs: False 58 | display_name: "{{item.display_name}}" 59 | host_switch_spec: 60 | resource_type: StandardHostSwitchSpec 61 | host_switches: "{{item.host_switches}}" 62 | node_deployment_info: "{{item.node_deployment_info}}" 63 | state: present 64 | with_items: 65 | - "{{transport_nodes}}" 66 | -------------------------------------------------------------------------------- /tests/playbooks/policy/test_nsxt_policy_segment.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # 5 | # Playbook to test Segment 6 | # 7 | - hosts: localhost 8 | tasks: 9 | - name: Update Segment 10 | vmware.ansible_for_nsxt.nsxt_policy_segment: 11 | hostname: "default" 12 | nsx_cert_path: /root/com.vmware.nsx.ncp/nsx.crt 13 | nsx_key_path: /root/com.vmware.nsx.ncp/nsx.key 14 | validate_certs: True 15 | ca_path: /path/to/my/ca-bundle 16 | state: present 17 | domain_name: dn1 18 | transport_zone_display_name: "1-transportzone-730" 19 | replication_mode: "SOURCE" 20 | address_bindings: 21 | - ip_address: "10.1.2.11" 22 | advanced_config: 23 | address_pool_display_name: small-2-pool 24 | connectivity: "OFF" 25 | hybrid: False 26 | local_egress: True 27 | admin_state: UP 28 | connectivity_path: "/infra/tier-1s/d082bc25-a9b2-4d13-afe5-d3cecad4b854" 29 | subnets: 30 | - gateway_address: "40.1.1.1/16" 31 | # - dhcp_config: 32 | # # IPv4 example 33 | # options: 34 | # option121: 35 | # static_routes: 36 | # - network: "10.22.12.2/23" 37 | # next_hop: "10.10.10.10" 38 | # resource_type: SegmentDhcpV4Config 39 | # lease_time: 16400 40 | # gateway_address: "192.40.10.1/24" 41 | # # IPv6 Example 42 | # resource_type: SegmentDhcpV6Config 43 | # preferred_time: 2048 44 | # excluded_ranges: 45 | # - fc7e::1-fc7e::32 46 | # server_address: "fc7e:f206:db42::2/48" 47 | # gateway_address: "fc7e:f206:db42::1/48" 48 | segment_ports: 49 | - display_name: test-sp-1 50 | state: present 51 | tags: 52 | - scope: "scope-1" 53 | tag: "tag-2" 54 | extra_configs: 55 | - config_pair: 56 | key: key 57 | value: value 58 | ignored_address_bindings: 59 | - ip_address: "10.1.2.122" 60 | - display_name: test-sp-2 61 | state: present 62 | - display_name: test-sp-3 63 | state: present -------------------------------------------------------------------------------- /tests/playbooks/mp/test_configure_transport_node.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile_tn.yml 9 | tasks: 10 | 11 | - name: Create ip pool 12 | vmware.ansible_for_nsxt.nsxt_ip_pools: 13 | hostname: "{{hostname}}" 14 | username: "{{username}}" 15 | password: "{{password}}" 16 | validate_certs: False 17 | display_name: "{{item.display_name}}" 18 | subnets: "{{item.subnets}}" 19 | state: present 20 | with_items: 21 | - "{{ip_pools}}" 22 | 23 | - name: Create transport zone 24 | vmware.ansible_for_nsxt.nsxt_transport_zones: 25 | hostname: "{{hostname}}" 26 | username: "{{username}}" 27 | password: "{{password}}" 28 | validate_certs: False 29 | resource_type: "TransportZone" 30 | display_name: "{{item.display_name}}" 31 | description: "NSX configured Test Transport Zone" 32 | transport_type: "{{item.transport_type}}" 33 | host_switch_name: "{{item.host_switch_name}}" 34 | state: "present" 35 | with_items: 36 | - "{{transportzones}}" 37 | 38 | - name: Create uplink profile 39 | vmware.ansible_for_nsxt.nsxt_uplink_profiles: 40 | hostname: "{{hostname}}" 41 | username: "{{username}}" 42 | password: "{{password}}" 43 | validate_certs: False 44 | resource_type: UplinkHostSwitchProfile 45 | display_name: "{{item.display_name}}" 46 | mtu: 1600 47 | teaming: "{{item.teaming}}" 48 | transport_vlan: "{{item.transport_vlan}}" 49 | state: "present" 50 | with_items: 51 | - "{{uplink_profiles}}" 52 | 53 | - name: Create transport node 54 | vmware.ansible_for_nsxt.nsxt_transport_nodes: 55 | hostname: "{{hostname}}" 56 | username: "{{username}}" 57 | password: "{{password}}" 58 | validate_certs: False 59 | display_name: "{{item.display_name}}" 60 | host_switch_spec: 61 | resource_type: StandardHostSwitchSpec 62 | host_switches: "{{item.host_switches}}" 63 | transport_zone_endpoints: "{{item.transport_zone_endpoints}}" 64 | node_deployment_info: "{{item.node_deployment_info}}" 65 | state: present 66 | with_items: 67 | - "{{transport_nodes}}" 68 | -------------------------------------------------------------------------------- /plugins/module_utils/policy_resource_specs/l2_bridge_ep_profile.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2020 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 8 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 9 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 10 | # A PARTICULAR PURPOSE ARE DISCLAIMED. 11 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 12 | # DIRECT, INDIRECT, INCIDENTAL, 13 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 14 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 15 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 16 | # ON ANY THEORY OF LIABILITY, 17 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 18 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 19 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 20 | 21 | SPEC = dict( 22 | edge_nodes_info=dict( 23 | required=True, 24 | type='list', 25 | elements='dict', 26 | options=dict( 27 | # Note that only default site_id and 28 | # enforcementpoint_id are used 29 | site_id=dict( 30 | type='str', 31 | default="default" 32 | ), 33 | enforcementpoint_id=dict( 34 | type='str', 35 | default="default" 36 | ), 37 | edge_cluster_id=dict( 38 | type='str' 39 | ), 40 | edge_cluster_display_name=dict( 41 | type='str' 42 | ), 43 | edge_node_id=dict( 44 | type='str' 45 | ), 46 | edge_node_display_name=dict( 47 | type='str' 48 | ) 49 | ) 50 | ), 51 | enforcementpoint_id=dict( 52 | type='str', 53 | default="default" 54 | ), 55 | failover_mode=dict( 56 | required=False, 57 | default="PREEMPTIVE", 58 | choices=["PREEMPTIVE", "NON_PREEMPTIVE"], 59 | type='str' 60 | ), 61 | ha_mode=dict( 62 | required=False, 63 | type='str', 64 | default="ACTIVE_STANDBY", 65 | choices=["ACTIVE_STANDBY"] 66 | ), 67 | site_id=dict( 68 | type='str', 69 | default="default" 70 | ), 71 | ) 72 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/misc/create_and_attach_t0_t1_routers.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2020 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | # 5 | # This example shows how to create T0 and T1 Router and connect them 6 | # 7 | --- 8 | - hosts: 127.0.0.1 9 | connection: local 10 | become: yes 11 | vars: 12 | nsx: "192.168.200.11" 13 | user: "admin" 14 | password: "myPassword1!myPassword1!" 15 | state: "present" 16 | 17 | tasks: 18 | - name: Create T0 19 | vmware.ansible_for_nsxt.nsxt_logical_routers: 20 | hostname: "{{ nsx }}" 21 | username: "{{ user }}" 22 | password: "{{ password }}" 23 | validate_certs: False 24 | state: "{{ state }}" 25 | display_name: "myTier-0" 26 | edge_cluster_name: "Edge-Cluster-01" 27 | router_type: "TIER0" 28 | high_availability_mode: "ACTIVE_ACTIVE" 29 | 30 | - name: Create T1 31 | vmware.ansible_for_nsxt.nsxt_logical_routers: 32 | hostname: "{{ nsx }}" 33 | username: "{{ user }}" 34 | password: "{{ password }}" 35 | validate_certs: False 36 | state: "{{ state }}" 37 | display_name: "myTier-1" 38 | edge_cluster_name: "Edge-Cluster-01" 39 | router_type: "TIER1" 40 | 41 | - name: Create Tier0 router port to Tier1 42 | vmware.ansible_for_nsxt.nsxt_logical_router_ports: 43 | hostname: "{{ nsx }}" 44 | username: "{{ user }}" 45 | password: "{{ password }}" 46 | validate_certs: False 47 | state: "{{ state }}" 48 | display_name: "RouterPortOnTier0toT1" 49 | resource_type: "LogicalRouterLinkPortOnTIER0" 50 | logical_router_name: "myTier-0" 51 | 52 | - name: Get Router ID 53 | uri: 54 | url: "https://192.168.200.11/api/v1/logical-router-ports?resource_type=LogicalRouterLinkPortOnTIER0" 55 | user: "{{ user }}" 56 | password: "{{ password }}" 57 | validate_certs: False 58 | return_content: yes 59 | use_proxy: false 60 | force_basic_auth: true 61 | register: ports 62 | 63 | - name: Create Tier1 router port to Tier0 64 | vmware.ansible_for_nsxt.nsxt_logical_router_ports: 65 | hostname: "{{ nsx }}" 66 | username: "{{ user }}" 67 | password: "{{ password }}" 68 | validate_certs: False 69 | state: "{{ state }}" 70 | display_name: "RouterPortOnTier1toT0" 71 | resource_type: "LogicalRouterLinkPortOnTIER1" 72 | logical_router_name: "myTier-1" 73 | linked_logical_router_port_id: 74 | target_id: "{{ ports.json['results'][0].id }}" 75 | target_type: LogicalPort 76 | 77 | 78 | -------------------------------------------------------------------------------- /tests/playbooks/policy/test_nsxt_policy_tier1.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # 5 | # Playbook to test Tier1 6 | # 7 | - hosts: localhost 8 | tasks: 9 | - name: Update Tier1 10 | vmware.ansible_for_nsxt.nsxt_policy_tier1: 11 | hostname: "default" 12 | nsx_cert_path: /root/com.vmware.nsx.ncp/nsx.crt 13 | nsx_key_path: /root/com.vmware.nsx.ncp/nsx.key 14 | validate_certs: True 15 | ca_path: /path/to/my/ca-bundle 16 | display_name: test-tier22222 17 | state: present 18 | failover_mode: "PREEMPTIVE" 19 | disable_firewall: True 20 | force_whitelisting: True 21 | enable_standby_relocation: False 22 | tags: 23 | - scope: "a" 24 | tag: "b" 25 | route_advertisement_rules: 26 | - name: "test-route-advertisement-rules" 27 | route_advertisement_types: ['TIER1_STATIC_ROUTES', 'TIER1_CONNECTED'] 28 | subnets: ["35.1.1.1/23"] 29 | route_advertisement_types: ['TIER1_STATIC_ROUTES', 'TIER1_CONNECTED', 'TIER1_NAT'] 30 | tier0_display_name: "node-t0" 31 | static_routes: 32 | - state: present 33 | display_name: test-sr 34 | network: '12.12.12.0/24' 35 | next_hops: 36 | - ip_address: "192.165.1.4" 37 | locale_services: 38 | - state: present 39 | display_name: test-t1ls-2 40 | route_redistribution_config: 41 | redistribution_rules: 42 | - name: abc 43 | route_redistribution_types: ["TIER0_STATIC", "TIER0_NAT"] 44 | ha_vip_configs: 45 | - external_interface_info: 46 | # Either of the two ways below can be used 47 | - external_interface_path: /infra/tier-0s/pepsi/locale-services/1-policyconnectivity-706/interfaces/2-policyconnectivity-1411 48 | - tier0_display_name: pepsi 49 | tier0_ls_display_name: 1-policyconnectivity-706 50 | tier0_ls_interface_display_name: 1-policyconnectivity-1649 51 | vip_subnets: 52 | - ip_addresses: 53 | - '12.12.12.12' 54 | prefix_len: 23 55 | interfaces: 56 | - id: "test-t1-t1ls-iface-2" 57 | display_name: "test-t1-t1ls-iface" 58 | state: present 59 | subnets: 60 | - ip_addresses: ["35.1.1.1"] 61 | prefix_len: 24 62 | segment_id: "test-seg-2" 63 | ipv6_ndra_profile_id: test 64 | mtu: 1400 65 | urpf_mode: NONE -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contributing to ansible-for-nsxt 4 | 5 | The ansible-for-nsxt project team welcomes contributions from the community. Before you start working with ansible-for-nsxt, please read our [Developer Certificate of Origin](https://cla.vmware.com/dco). All contributions to this repository must be signed as described on that page. Your signature certifies that you wrote the patch or have the right to pass it on as an open-source patch. 6 | 7 | ## Community 8 | 9 | ## Getting Started 10 | 11 | ## Contribution Flow 12 | 13 | This is a rough outline of what a contributor's workflow looks like: 14 | 15 | - Create a topic branch from where you want to base your work 16 | - Make commits of logical units 17 | - Make sure your commit messages are in the proper format (see below) 18 | - Push your changes to a topic branch in your fork of the repository 19 | - Submit a pull request 20 | 21 | Example: 22 | 23 | ``` shell 24 | git remote add upstream https://github.com/vmware/ansible-for-nsxt.git 25 | git checkout -b my-new-feature master 26 | git commit -a 27 | git push origin my-new-feature 28 | ``` 29 | 30 | ### Staying In Sync With Upstream 31 | 32 | When your branch gets out of sync with the vmware/master branch, use the following to update: 33 | 34 | ``` shell 35 | git checkout my-new-feature 36 | git fetch -a 37 | git pull --rebase upstream master 38 | git push --force-with-lease origin my-new-feature 39 | ``` 40 | 41 | ### Updating pull requests 42 | 43 | If your PR fails to pass CI or needs changes based on code review, you'll most likely want to squash these changes into 44 | existing commits. 45 | 46 | If your pull request contains a single commit or your changes are related to the most recent commit, you can simply 47 | amend the commit. 48 | 49 | ``` shell 50 | git add . 51 | git commit --amend 52 | git push --force-with-lease origin my-new-feature 53 | ``` 54 | 55 | If you need to squash changes into an earlier commit, you can use: 56 | 57 | ``` shell 58 | git add . 59 | git commit --fixup 60 | git rebase -i --autosquash master 61 | git push --force-with-lease origin my-new-feature 62 | ``` 63 | 64 | Be sure to add a comment to the PR indicating your new changes are ready to review, as GitHub does not generate a 65 | notification when you git push. 66 | 67 | ### Code Style 68 | 69 | ### Formatting Commit Messages 70 | 71 | We follow the conventions on [How to Write a Git Commit Message](http://chris.beams.io/posts/git-commit/). 72 | 73 | Be sure to include any related GitHub issue references in the commit message. See 74 | [GFM syntax](https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown) for referencing issues 75 | and commits. 76 | 77 | ## Reporting Bugs and Creating Issues 78 | 79 | When opening a new issue, try to roughly follow the commit message format conventions above. 80 | 81 | ## Repository Structure 82 | -------------------------------------------------------------------------------- /tests/playbooks/topologies/deploy_nsx_cluster/deploy_nsx_cluster_vars.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | # 4 | # Variables file for deploying NSX-T Cluster 5 | # 6 | { 7 | 8 | # 9 | # Common NSX Appliance variables 10 | # 11 | "nsx_username": "admin", 12 | "nsx_password": "myPassword1!myPassword1!", 13 | "validate_certs": False, 14 | "state": "present", 15 | 16 | # 17 | # OVA/OVF Information. Path can be on local file system or a HTTP URL 18 | # 19 | "nsx_ova_path": "/media/disk2", 20 | # "nsx_ova": "nsx-unified-appliance-3.0.0.0.0.15946739.ova", 21 | "nsx_ova": "nsx-unified-appliance-3.0.1.0.0.16404476.ova", 22 | 23 | # 24 | # Common network details. This assumes all NSX appliance nodes are on the 25 | # same subnet. If there is a need to deploy NSX appliance nodes which are 26 | # on different subnets, add node specific details in the blocks below and 27 | # use them in the playbooks instead. 28 | # 29 | "domain": "mylab.local", 30 | "netmask": "255.255.255.224", 31 | "gateway": "10.114.200.33", 32 | "dns_server": "10.116.1.201", 33 | "ntp_server": "10.114.200.8", 34 | 35 | # 36 | # First NSX appliance node. Defined separate based on the consumption. 37 | # Accepts both IP (IPv4) and FQDN for 'mgmt_ip' 38 | # 39 | "nsx_node1": { 40 | "hostname": "mynsx-01.mylab.local", 41 | "mgmt_ip": "10.114.200.41", 42 | "datacenter": "Datacenter", 43 | "cluster": "Management", 44 | "datastore": "datastore36", 45 | "portgroup": "VM Network" 46 | }, 47 | 48 | # 49 | # Additional nodes defined as an array so that its easier to iterate 50 | # through them in the playbook. 51 | # 52 | "additional_nodes": [ 53 | { 54 | "hostname": "mynsx-02.mylab.local", 55 | "mgmt_ip": "10.114.200.42", 56 | "prefix": "27", 57 | "datacenter": "Datacenter", 58 | "cluster": "Management", 59 | "datastore": "datastore36", 60 | "portgroup": "VM Network" 61 | }, 62 | { 63 | "hostname": "mynsx-03.mylab.local", 64 | "mgmt_ip": "10.114.200.43", 65 | "prefix": "27", 66 | "datacenter": "Datacenter", 67 | "cluster": "Management", 68 | "datastore": "datastore36", 69 | "portgroup": "VM Network" 70 | } 71 | ], 72 | 73 | # 74 | # One or more compute managers that have to be registered with NSX 75 | # 76 | "compute_managers": [ 77 | { 78 | "display_name": "vcenter", 79 | "mgmt_ip": "10.114.200.6", 80 | "origin_type": "vCenter", 81 | "credential_type": "UsernamePasswordLoginCredential", 82 | "username": "administrator@madhu.local", 83 | "password": "VMware1!" 84 | } 85 | ], 86 | 87 | # 88 | # NSX-T licenses 89 | # 90 | "nsxt_licenses": [ 91 | { 92 | "license_key": "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" 93 | } 94 | ], 95 | } 96 | -------------------------------------------------------------------------------- /plugins/module_utils/nsxt_resource_urls.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2020 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 8 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 9 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 10 | # A PARTICULAR PURPOSE ARE DISCLAIMED. 11 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 12 | # DIRECT, INDIRECT, INCIDENTAL, 13 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 14 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 15 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 16 | # ON ANY THEORY OF LIABILITY, 17 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 18 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 19 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 20 | 21 | # Hidden or not exposed URLS 22 | _SITE_URL = '/infra/sites' 23 | _DOMAIN_URL = '/infra/domains' 24 | _ENFORCEMENT_POINT_URL = _SITE_URL + '/{}/enforcement-points' 25 | 26 | IP_BLOCK_URL = '/infra/ip-blocks' 27 | 28 | IP_POOL_URL = '/infra/ip-pools' 29 | IP_ADDRESS_POOL_SUBNET_URL = IP_POOL_URL + '/{}/ip-subnets' 30 | 31 | POLICY_GROUP_URL = _DOMAIN_URL + '/{}/groups' 32 | 33 | SECURITY_POLICY_URL = _DOMAIN_URL + '/{}/security-policies' 34 | 35 | SEGMENT_URL = '/infra/segments' 36 | SEGMENT_PORT_URL = SEGMENT_URL + '/{}/ports' 37 | 38 | TRANSPORT_ZONE_URL = _ENFORCEMENT_POINT_URL + '/{}/transport-zones' 39 | 40 | L2_BRIDGE_EP_PROFILE_URL = _ENFORCEMENT_POINT_URL + '/{}/edge-bridge-profiles' 41 | 42 | TIER_0_URL = '/infra/tier-0s' 43 | TIER_0_STATIC_ROUTE_URL = TIER_0_URL + '/{}/static-routes' 44 | TIER_0_LOCALE_SERVICE_URL = TIER_0_URL + '/{}/locale-services' 45 | TIER_0_LS_INTERFACE_URL = TIER_0_LOCALE_SERVICE_URL + '/{}/interfaces' 46 | TIER_0_BGP_NEIGHBOR_URL = TIER_0_LOCALE_SERVICE_URL + '/{}/bgp/neighbors' 47 | TIER_0_BFD_PEERS = TIER_0_STATIC_ROUTE_URL + '/bfd-peers' 48 | 49 | TIER_1_URL = '/infra/tier-1s' 50 | TIER_1_STATIC_ROUTE_URL = TIER_1_URL + '/{}/static-routes' 51 | TIER_1_LOCALE_SERVICE_URL = TIER_1_URL + '/{}/locale-services' 52 | TIER_1_LS_INTERFACE_URL = TIER_1_LOCALE_SERVICE_URL + '/{}/interfaces' 53 | TIER_1_BGP_NEIGHBOR_URL = TIER_1_LOCALE_SERVICE_URL + '/{}/bgp/neighbors' 54 | 55 | IPV6_DAD_PROFILE_URL = '/infra/ipv6-dad-profiles' 56 | IPV6_NDRA_PROFILE_URL = '/infra/ipv6-ndra-profiles' 57 | 58 | DHCP_RELAY_CONFIG_URL = '/infra/dhcp-relay-configs' 59 | 60 | EDGE_CLUSTER_URL = _ENFORCEMENT_POINT_URL + '/{}/edge-clusters' 61 | EDGE_NODE_URL = EDGE_CLUSTER_URL + '/{}/edge-nodes' 62 | 63 | VM_LIST_URL = '/virtual-machines' 64 | VM_UPDATE_URL = '/virtual-machines' 65 | 66 | BFD_PROFILE_URL = '/infra/bfd-profiles' 67 | 68 | GATEWAY_POLICY_URL = _DOMAIN_URL + '/{}/gateway-policies' 69 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_upgrade_history.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2019 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | 19 | ANSIBLE_METADATA = {'metadata_version': '1.1', 20 | 'status': ['preview'], 21 | 'supported_by': 'community'} 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_upgrade_history 26 | short_description: 'Get upgrade history' 27 | description: "Get upgrade history" 28 | version_added: '2.7' 29 | author: 'Kommireddy Akhilesh' 30 | options: 31 | hostname: 32 | description: 'Deployed NSX manager hostname.' 33 | required: true 34 | type: str 35 | username: 36 | description: 'The username to authenticate with the NSX manager.' 37 | required: true 38 | type: str 39 | password: 40 | description: 'The password to authenticate with the NSX manager.' 41 | required: true 42 | type: str 43 | ''' 44 | 45 | EXAMPLES = ''' 46 | - name: Get upgrade history 47 | nsxt_upgrade_history: 48 | hostname: "10.192.167.137" 49 | username: "admin" 50 | password: "Admin!23Admin" 51 | validate_certs: False 52 | ''' 53 | 54 | RETURN = '''# ''' 55 | 56 | from ansible.module_utils.basic import AnsibleModule 57 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 58 | from ansible.module_utils._text import to_native 59 | 60 | def main(): 61 | argument_spec = vmware_argument_spec() 62 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 63 | 64 | mgr_hostname = module.params['hostname'] 65 | mgr_username = module.params['username'] 66 | mgr_password = module.params['password'] 67 | validate_certs = module.params['validate_certs'] 68 | 69 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 70 | 71 | changed = False 72 | try: 73 | (rc, resp) = request(manager_url+ '/upgrade/history', headers=dict(Accept='application/json'), 74 | url_username=mgr_username, url_password=mgr_password, 75 | validate_certs=validate_certs, ignore_errors=True) 76 | except Exception as err: 77 | module.fail_json(msg='Error while retrieving bundle information. Error [%s]' % (to_native(err))) 78 | 79 | module.exit_json(changed=changed, **resp) 80 | if __name__ == '__main__': 81 | main() 82 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_upgrade_uc_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2019 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | 19 | ANSIBLE_METADATA = {'metadata_version': '1.1', 20 | 'status': ['preview'], 21 | 'supported_by': 'community'} 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_upgrade_uc_facts 26 | short_description: Get upgrade-coordinator upgrade status 27 | description: Get upgrade-coordinator upgrade status 28 | 29 | version_added: "2.7" 30 | author: 'Kommireddy Akhilesh' 31 | options: 32 | hostname: 33 | description: Deployed NSX manager hostname. 34 | required: true 35 | type: str 36 | username: 37 | description: The username to authenticate with the NSX manager. 38 | required: true 39 | type: str 40 | password: 41 | description: The password to authenticate with the NSX manager. 42 | required: true 43 | type: str 44 | 45 | ''' 46 | 47 | EXAMPLES = ''' 48 | - name: Gets UC upgrade status 49 | nsxt_upgrade_uc_facts: 50 | hostname: "10.192.167.137" 51 | username: "admin" 52 | password: "Admin!23Admin" 53 | validate_certs: False 54 | ''' 55 | 56 | RETURN = '''# ''' 57 | 58 | from ansible.module_utils.basic import AnsibleModule 59 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 60 | from ansible.module_utils._text import to_native 61 | 62 | def main(): 63 | argument_spec = vmware_argument_spec() 64 | 65 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 66 | 67 | mgr_hostname = module.params['hostname'] 68 | mgr_username = module.params['username'] 69 | mgr_password = module.params['password'] 70 | validate_certs = module.params['validate_certs'] 71 | 72 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 73 | 74 | changed = False 75 | try: 76 | (rc, resp) = request(manager_url+ '/upgrade/uc-upgrade-status', headers=dict(Accept='application/json'), 77 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 78 | except Exception as err: 79 | module.fail_json(msg='Error accessing UC upgrade status. Error [%s]' % (to_native(err))) 80 | 81 | module.exit_json(changed=changed, **resp) 82 | if __name__ == '__main__': 83 | main() -------------------------------------------------------------------------------- /plugins/modules/nsxt_logical_switches_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | 19 | ANSIBLE_METADATA = {'metadata_version': '1.1', 20 | 'status': ['preview'], 21 | 'supported_by': 'community'} 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_logical_switches_facts 26 | short_description: List All Logical Switches 27 | description: Returns information about all configured logical switches. 28 | version_added: "2.7" 29 | author: Rahul Raghuvanshi 30 | options: 31 | hostname: 32 | description: Deployed NSX manager hostname. 33 | required: true 34 | type: str 35 | username: 36 | description: The username to authenticate with the NSX manager. 37 | required: true 38 | type: str 39 | password: 40 | description: The password to authenticate with the NSX manager. 41 | required: true 42 | type: str 43 | 44 | ''' 45 | 46 | EXAMPLES = ''' 47 | - name: List All Logical Switches 48 | nsxt_logical_switches_facts: 49 | hostname: "10.192.167.137" 50 | username: "admin" 51 | password: "Admin!23Admin" 52 | validate_certs: False 53 | ''' 54 | 55 | RETURN = '''# ''' 56 | 57 | import json 58 | from ansible.module_utils.basic import AnsibleModule 59 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 60 | from ansible.module_utils._text import to_native 61 | 62 | def main(): 63 | argument_spec = vmware_argument_spec() 64 | 65 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 66 | 67 | mgr_hostname = module.params['hostname'] 68 | mgr_username = module.params['username'] 69 | mgr_password = module.params['password'] 70 | validate_certs = module.params['validate_certs'] 71 | 72 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 73 | 74 | changed = False 75 | try: 76 | (rc, resp) = request(manager_url+ '/logical-switches', headers=dict(Accept='application/json'), 77 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 78 | except Exception as err: 79 | module.fail_json(msg='Error accessing list of logical ports. Error [%s]' % (to_native(err))) 80 | 81 | module.exit_json(changed=changed, **resp) 82 | if __name__ == '__main__': 83 | main() 84 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_virtual_ip_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2019 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | 19 | ANSIBLE_METADATA = {'metadata_version': '1.1', 20 | 'status': ['preview'], 21 | 'supported_by': 'community'} 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_vitual_ip_facts 26 | short_description: Read cluster virtual IP address 27 | description: Returns the configured cluster virtual IP address or null if not configured. 28 | 29 | version_added: "2.7" 30 | author: Rahul Raghuvanshi 31 | options: 32 | hostname: 33 | description: Deployed NSX manager hostname. 34 | required: true 35 | type: str 36 | username: 37 | description: The username to authenticate with the NSX manager. 38 | required: true 39 | type: str 40 | password: 41 | description: The password to authenticate with the NSX manager. 42 | required: true 43 | type: str 44 | 45 | ''' 46 | 47 | EXAMPLES = ''' 48 | - name: Get all configured cluster virtual IP address 49 | nsxt_virtual_ip_facts: 50 | hostname: "10.192.167.137" 51 | username: "admin" 52 | password: "Admin!23Admin" 53 | validate_certs: False 54 | ''' 55 | 56 | RETURN = '''# ''' 57 | 58 | from ansible.module_utils.basic import AnsibleModule 59 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 60 | from ansible.module_utils._text import to_native 61 | 62 | def main(): 63 | argument_spec = vmware_argument_spec() 64 | 65 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 66 | 67 | mgr_hostname = module.params['hostname'] 68 | mgr_username = module.params['username'] 69 | mgr_password = module.params['password'] 70 | validate_certs = module.params['validate_certs'] 71 | 72 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 73 | 74 | changed = False 75 | try: 76 | (rc, resp) = request(manager_url+ '/cluster/api-virtual-ip', headers=dict(Accept='application/json'), 77 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 78 | except Exception as err: 79 | module.fail_json(msg='Error accessing virtual IP information. Error [%s]' % (to_native(err))) 80 | 81 | module.exit_json(changed=changed, **resp) 82 | if __name__ == '__main__': 83 | main() 84 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_licenses_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | 19 | ANSIBLE_METADATA = {'metadata_version': '1.1', 20 | 'status': ['preview'], 21 | 'supported_by': 'community'} 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_licenses_facts 26 | short_description: Get all licenses 27 | description: Returns all licenses. 28 | 29 | version_added: "2.7" 30 | author: Rahul Raghuvanshi 31 | options: 32 | hostname: 33 | description: Deployed NSX manager hostname. 34 | required: true 35 | type: str 36 | username: 37 | description: The username to authenticate with the NSX manager. 38 | required: true 39 | type: str 40 | password: 41 | description: The password to authenticate with the NSX manager. 42 | required: true 43 | type: str 44 | 45 | ''' 46 | 47 | EXAMPLES = ''' 48 | - name: Get all licenses 49 | nsxt_licenses_facts: 50 | hostname: "10.192.167.137" 51 | username: "admin" 52 | password: "Admin!23Admin" 53 | validate_certs: False 54 | ''' 55 | 56 | RETURN = '''# ''' 57 | 58 | import json 59 | from ansible.module_utils.basic import AnsibleModule 60 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 61 | from ansible.module_utils.urls import open_url, fetch_url 62 | from ansible.module_utils._text import to_native 63 | from ansible.module_utils.six.moves.urllib.error import HTTPError 64 | 65 | def main(): 66 | argument_spec = vmware_argument_spec() 67 | 68 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 69 | 70 | mgr_hostname = module.params['hostname'] 71 | mgr_username = module.params['username'] 72 | mgr_password = module.params['password'] 73 | validate_certs = module.params['validate_certs'] 74 | 75 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 76 | 77 | changed = False 78 | try: 79 | (rc, resp) = request(manager_url+ '/licenses', headers=dict(Accept='application/json'), 80 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 81 | except Exception as err: 82 | module.fail_json(msg='Error accessing licenses. Error [%s]' % (to_native(err))) 83 | 84 | module.exit_json(changed=changed, **resp) 85 | if __name__ == '__main__': 86 | main() 87 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_manager_auto_deployment_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | ANSIBLE_METADATA = {'metadata_version': '1.1', 19 | 'status': ['preview'], 20 | 'supported_by': 'community'} 21 | 22 | 23 | DOCUMENTATION = ''' 24 | module: nsxt_manager_auto_deployment_facts 25 | short_description: 'Returns info for all cluster node VM auto-deployment attempts' 26 | description: 'Returns request information for every attempted deployment of a 27 | cluster node VM' 28 | version_added: '2.7' 29 | author: 'Rahul Raghuvanshi' 30 | options: 31 | hostname: 32 | description: 'Deployed NSX manager hostname.' 33 | required: true 34 | type: str 35 | username: 36 | description: 'The username to authenticate with the NSX manager.' 37 | required: true 38 | type: str 39 | password: 40 | description: 'The password to authenticate with the NSX manager.' 41 | required: true 42 | type: str 43 | ''' 44 | 45 | EXAMPLES = ''' 46 | - nsxt_manager_auto_deployment_facts: 47 | hostname: "10.192.167.137" 48 | username: "admin" 49 | password: "Admin!23Admin" 50 | validate_certs: False 51 | ''' 52 | 53 | RETURN = '''# ''' 54 | 55 | import json 56 | from ansible.module_utils.basic import AnsibleModule 57 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 58 | from ansible.module_utils._text import to_native 59 | 60 | def main(): 61 | argument_spec = vmware_argument_spec() 62 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 63 | 64 | mgr_hostname = module.params['hostname'] 65 | mgr_username = module.params['username'] 66 | mgr_password = module.params['password'] 67 | validate_certs = module.params['validate_certs'] 68 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 69 | 70 | changed = False 71 | try: 72 | (rc, resp) = request(manager_url+ '/cluster/nodes/deployments', headers=dict(Accept='application/json'), 73 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 74 | except Exception as err: 75 | module.fail_json(msg='Error accessing controllers. Error [%s]' % (to_native(err))) 76 | module.exit_json(changed=changed, **resp) 77 | if __name__ == '__main__': 78 | main() 79 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_cluster_profiles_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | ANSIBLE_METADATA = {'metadata_version': '1.1', 19 | 'status': ['preview'], 20 | 'supported_by': 'community'} 21 | 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_cluster_profiles_facts 26 | short_description: List Cluster Profiles 27 | description: Returns paginated list of cluster profiles 28 | Cluster profiles define policies for edge cluster and bridge cluster. 29 | 30 | version_added: "2.7" 31 | author: Kommireddy Akhilesh 32 | options: 33 | hostname: 34 | description: Deployed NSX manager hostname. 35 | required: true 36 | type: str 37 | username: 38 | description: The username to authenticate with the NSX manager. 39 | required: true 40 | type: str 41 | password: 42 | description: The password to authenticate with the NSX manager. 43 | required: true 44 | type: str 45 | ''' 46 | 47 | EXAMPLES = ''' 48 | - name: List Cluster Profiles 49 | nsxt_cluster_profiles_facts: 50 | hostname: "10.192.167.137" 51 | username: "admin" 52 | password: "Admin!23Admin" 53 | validate_certs: False 54 | ''' 55 | 56 | RETURN = '''# ''' 57 | 58 | import json 59 | from ansible.module_utils.basic import AnsibleModule 60 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 61 | from ansible.module_utils._text import to_native 62 | 63 | def main(): 64 | argument_spec = vmware_argument_spec() 65 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 66 | 67 | mgr_hostname = module.params['hostname'] 68 | mgr_username = module.params['username'] 69 | mgr_password = module.params['password'] 70 | validate_certs = module.params['validate_certs'] 71 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 72 | 73 | changed = False 74 | try: 75 | (rc, resp) = request(manager_url+ '/cluster-profiles', headers=dict(Accept='application/json'), 76 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 77 | except Exception as err: 78 | module.fail_json(msg='Error accessing list of edge cluster. Error [%s]' % (to_native(err))) 79 | 80 | module.exit_json(changed=changed, **resp) 81 | if __name__ == '__main__': 82 | main() 83 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_transport_node_profiles_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | 19 | ANSIBLE_METADATA = {'metadata_version': '1.1', 20 | 'status': ['preview'], 21 | 'supported_by': 'community'} 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_transport_node_profiles_facts 26 | short_description: List Transport Nodes Profiles 27 | description: Returns information about all transport node profiles. 28 | 29 | version_added: "2.7" 30 | author: Rahul Raghuvanshi 31 | options: 32 | hostname: 33 | description: Deployed NSX manager hostname. 34 | required: true 35 | type: str 36 | username: 37 | description: The username to authenticate with the NSX manager. 38 | required: true 39 | type: str 40 | password: 41 | description: The password to authenticate with the NSX manager. 42 | required: true 43 | type: str 44 | 45 | 46 | ''' 47 | 48 | EXAMPLES = ''' 49 | - name: List Transport Node Profiles 50 | nsxt_transport_node_profiles_facts: 51 | hostname: "10.192.167.137" 52 | username: "admin" 53 | password: "Admin!23Admin" 54 | validate_certs: False 55 | ''' 56 | 57 | RETURN = '''# ''' 58 | 59 | import json 60 | from ansible.module_utils.basic import AnsibleModule 61 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 62 | from ansible.module_utils._text import to_native 63 | 64 | def main(): 65 | argument_spec = vmware_argument_spec() 66 | 67 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 68 | 69 | mgr_hostname = module.params['hostname'] 70 | mgr_username = module.params['username'] 71 | mgr_password = module.params['password'] 72 | validate_certs = module.params['validate_certs'] 73 | 74 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 75 | 76 | changed = False 77 | try: 78 | (rc, resp) = request(manager_url+ '/transport-node-profiles', headers=dict(Accept='application/json'), 79 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 80 | except Exception as err: 81 | module.fail_json(msg='Error accessing transport node profiles. Error [%s]' % (to_native(err))) 82 | 83 | module.exit_json(changed=changed, **resp) 84 | if __name__ == '__main__': 85 | main() 86 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_principal_identities_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | 19 | ANSIBLE_METADATA = {'metadata_version': '1.1', 20 | 'status': ['preview'], 21 | 'supported_by': 'community'} 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_principal_identities_facts 26 | short_description: List all existing principal identities 27 | description: Returns the list of principals registered with a certificate. 28 | version_added: "2.7" 29 | author: Rahul Raghuvanshi 30 | options: 31 | hostname: 32 | description: Deployed NSX manager hostname. 33 | required: true 34 | type: str 35 | username: 36 | description: The username to authenticate with the NSX manager. 37 | required: true 38 | type: str 39 | password: 40 | description: The password to authenticate with the NSX manager. 41 | required: true 42 | type: str 43 | 44 | 45 | ''' 46 | 47 | EXAMPLES = ''' 48 | - name: List all existing certificates 49 | nsxt_principal_identities_facts: 50 | hostname: "10.192.167.137" 51 | username: "admin" 52 | password: "Admin!23Admin" 53 | validate_certs: False 54 | ''' 55 | 56 | RETURN = '''# ''' 57 | 58 | import json 59 | from ansible.module_utils.basic import AnsibleModule 60 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 61 | from ansible.module_utils._text import to_native 62 | 63 | def main(): 64 | argument_spec = vmware_argument_spec() 65 | 66 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 67 | 68 | mgr_hostname = module.params['hostname'] 69 | mgr_username = module.params['username'] 70 | mgr_password = module.params['password'] 71 | validate_certs = module.params['validate_certs'] 72 | 73 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 74 | 75 | changed = False 76 | try: 77 | (rc, resp) = request(manager_url+ '/trust-management/principal-identities', headers=dict(Accept='application/json'), 78 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 79 | except Exception as err: 80 | module.fail_json(msg='Error accessing transport zone. Error [%s]' % (to_native(err))) 81 | 82 | module.exit_json(changed=changed, **resp) 83 | if __name__ == '__main__': 84 | main() 85 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_upgrade_pre_post_checks_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2019 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | 19 | ANSIBLE_METADATA = {'metadata_version': '1.1', 20 | 'status': ['preview'], 21 | 'supported_by': 'community'} 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_upgrade_pre_post_checks_facts 26 | short_description: 'Get the pre and post upgrade checks' 27 | description: 'Get the pre and post upgrade checks' 28 | version_added: '2.7' 29 | author: 'Kommireddy Akhilesh' 30 | options: 31 | hostname: 32 | description: 'Deployed NSX manager hostname.' 33 | required: true 34 | type: str 35 | username: 36 | description: 'The username to authenticate with the NSX manager.' 37 | required: true 38 | type: str 39 | password: 40 | description: 'The password to authenticate with the NSX manager.' 41 | required: true 42 | type: str 43 | ''' 44 | 45 | EXAMPLES = ''' 46 | - name: Get the pre upgrade and post upgrade checks 47 | nsxt_upgrade_pre_post_checks_facts: 48 | hostname: "10.192.167.137" 49 | username: "admin" 50 | password: "Admin!23Admin" 51 | validate_certs: False 52 | ''' 53 | 54 | RETURN = '''# ''' 55 | 56 | from ansible.module_utils.basic import AnsibleModule 57 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 58 | from ansible.module_utils._text import to_native 59 | 60 | def main(): 61 | argument_spec = vmware_argument_spec() 62 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 63 | 64 | mgr_hostname = module.params['hostname'] 65 | mgr_username = module.params['username'] 66 | mgr_password = module.params['password'] 67 | validate_certs = module.params['validate_certs'] 68 | 69 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 70 | 71 | changed = False 72 | try: 73 | (rc, resp) = request(manager_url+ '/upgrade/upgrade-checks-info', 74 | headers=dict(Accept='application/json'), url_username=mgr_username, 75 | url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 76 | except Exception as err: 77 | module.fail_json(msg='Error while retrieving pre and post upgrade checks. Error [%s]' % (to_native(err))) 78 | 79 | module.exit_json(changed=changed, **resp) 80 | if __name__ == '__main__': 81 | main() 82 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_upgrade_groups_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2019 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | 19 | ANSIBLE_METADATA = {'metadata_version': '1.1', 20 | 'status': ['preview'], 21 | 'supported_by': 'community'} 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_upgrade_group_facts 26 | short_description: 'Get the upgrade groups information' 27 | description: 'Get the upgrade groups information' 28 | version_added: '2.7' 29 | author: 'Kommireddy Akhilesh' 30 | options: 31 | hostname: 32 | description: 'Deployed NSX manager hostname.' 33 | required: true 34 | type: str 35 | username: 36 | description: 'The username to authenticate with the NSX manager.' 37 | required: true 38 | type: str 39 | password: 40 | description: 'The password to authenticate with the NSX manager.' 41 | required: true 42 | type: str 43 | ''' 44 | 45 | EXAMPLES = ''' 46 | - name: Get the upgrade groups information 47 | nsxt_upgrade_group_facts: 48 | hostname: "10.192.167.137" 49 | username: "admin" 50 | password: "Admin!23Admin" 51 | validate_certs: False 52 | ''' 53 | 54 | RETURN = '''# ''' 55 | 56 | from ansible.module_utils.basic import AnsibleModule 57 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 58 | from ansible.module_utils._text import to_native 59 | 60 | def main(): 61 | argument_spec = vmware_argument_spec() 62 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 63 | 64 | mgr_hostname = module.params['hostname'] 65 | mgr_username = module.params['username'] 66 | mgr_password = module.params['password'] 67 | validate_certs = module.params['validate_certs'] 68 | 69 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 70 | 71 | changed = False 72 | try: 73 | (rc, resp) = request(manager_url + '/upgrade/upgrade-unit-groups/aggregate-info', 74 | headers=dict(Accept='application/json'), url_username=mgr_username, 75 | url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 76 | except Exception as err: 77 | module.fail_json(msg='Error while retrieving upgrade group ' 78 | 'information. Error [%s]' % (to_native(err))) 79 | 80 | module.exit_json(changed=changed, **resp) 81 | 82 | if __name__ == '__main__': 83 | main() -------------------------------------------------------------------------------- /plugins/modules/nsxt_policy_ip_block_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | from ansible.module_utils.basic import AnsibleModule 19 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 20 | from ansible.module_utils._text import to_native 21 | 22 | 23 | ANSIBLE_METADATA = {'metadata_version': '1.1', 24 | 'status': ['preview'], 25 | 'supported_by': 'community'} 26 | 27 | DOCUMENTATION = ''' 28 | --- 29 | module: nsxt_ip_blocks_facts 30 | short_description: Returns list of configured IP address blocks. 31 | description: Returns information about configured IP address blocks. Information includes 32 | the id, display name, description & CIDR of IP address blocks 33 | 34 | version_added: "2.7" 35 | author: Rahul Raghuvanshi 36 | options: 37 | hostname: 38 | description: Deployed NSX manager hostname. 39 | required: true 40 | type: str 41 | username: 42 | description: The username to authenticate with the NSX manager. 43 | required: true 44 | type: str 45 | password: 46 | description: The password to authenticate with the NSX manager. 47 | required: true 48 | type: str 49 | 50 | ''' 51 | 52 | EXAMPLES = ''' 53 | - name: Lists all configured IP address blocks 54 | nsxt_ip_block_facts: 55 | hostname: "10.192.167.137" 56 | username: "admin" 57 | password: "Admin!23Admin" 58 | validate_certs: False 59 | ''' 60 | 61 | RETURN = '''# ''' 62 | 63 | def main(): 64 | argument_spec = vmware_argument_spec() 65 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 66 | 67 | mgr_hostname = module.params['hostname'] 68 | mgr_username = module.params['username'] 69 | mgr_password = module.params['password'] 70 | validate_certs = module.params['validate_certs'] 71 | manager_url = 'https://{}/policy/api/v1'.format(mgr_hostname) 72 | 73 | changed = False 74 | try: 75 | (rc, resp) = request(f"{manager_url}/infra/ip-pools", headers=dict(Accept='application/json'), 76 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 77 | except Exception as err: 78 | module.fail_json(msg='Error accessing list of ip blocks. Error [%s]' % (to_native(err))) 79 | 80 | module.exit_json(changed=changed, **resp) 81 | if __name__ == '__main__': 82 | main() 83 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_upgrade_status_summary_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2019 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | 19 | ANSIBLE_METADATA = {'metadata_version': '1.1', 20 | 'status': ['preview'], 21 | 'supported_by': 'community'} 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_upgrade_status_summary_facts 26 | short_description: 'Get the upgrade groups information' 27 | description: 'Get the upgrade groups information' 28 | version_added: '2.7' 29 | author: 'Kommireddy Akhilesh' 30 | options: 31 | hostname: 32 | description: 'Deployed NSX manager hostname.' 33 | required: true 34 | type: str 35 | username: 36 | description: 'The username to authenticate with the NSX manager.' 37 | required: true 38 | type: str 39 | password: 40 | description: 'The password to authenticate with the NSX manager.' 41 | required: true 42 | type: str 43 | ''' 44 | 45 | EXAMPLES = ''' 46 | - name: Get upgrade status summary 47 | nsxt_upgrade_status_summary_facts: 48 | hostname: "10.192.167.137" 49 | username: "admin" 50 | password: "Admin!23Admin" 51 | validate_certs: False 52 | ''' 53 | 54 | RETURN = '''# ''' 55 | 56 | from ansible.module_utils.basic import AnsibleModule 57 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 58 | from ansible.module_utils._text import to_native 59 | 60 | def main(): 61 | argument_spec = vmware_argument_spec() 62 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 63 | 64 | mgr_hostname = module.params['hostname'] 65 | mgr_username = module.params['username'] 66 | mgr_password = module.params['password'] 67 | validate_certs = module.params['validate_certs'] 68 | 69 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 70 | 71 | changed = False 72 | try: 73 | (rc, resp) = request(manager_url + '/upgrade/status-summary', 74 | headers=dict(Accept='application/json'), url_username=mgr_username, 75 | url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 76 | except Exception as err: 77 | module.fail_json(msg='Error while retrieving upgrade status summary ' 78 | 'information. Error [%s]' % (to_native(err))) 79 | 80 | module.exit_json(changed=changed, **resp) 81 | 82 | if __name__ == '__main__': 83 | main() -------------------------------------------------------------------------------- /plugins/modules/nsxt_local_managers_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Copyright 2021 VMware, Inc. 4 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 5 | # 6 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 7 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 8 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 9 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 10 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 11 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 12 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 13 | 14 | from __future__ import absolute_import, division, print_function 15 | __metaclass__ = type 16 | 17 | ANSIBLE_METADATA = {'metadata_version': '1.1', 18 | 'status': ['preview'], 19 | 'supported_by': 'community'} 20 | 21 | 22 | DOCUMENTATION = ''' 23 | --- 24 | module: nsxt_local_managers_facts 25 | short_description: 'Return the list of local managers registered with the global manager' 26 | description: "Return the list of local managers registered with the global manager" 27 | version_added: '3.2' 28 | author: 'Kaushik Lele' 29 | options: 30 | hostname: 31 | description: 'Deployed NSX Global manager hostname.' 32 | required: true 33 | type: str 34 | username: 35 | description: 'The username to authenticate with the NSX manager.' 36 | required: true 37 | type: str 38 | password: 39 | description: 'The password to authenticate with the NSX manager.' 40 | required: true 41 | type: str 42 | 43 | 44 | 45 | ''' 46 | 47 | EXAMPLES = ''' 48 | - name: Register local manager with NSX 49 | nsxt_local_managers_facts: 50 | hostname: "10.192.167.137" 51 | username: "admin" 52 | password: "Admin!23Admin" 53 | 54 | ''' 55 | 56 | RETURN = '''# ''' 57 | 58 | import json, time 59 | from ansible.module_utils.basic import AnsibleModule 60 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 61 | from ansible.module_utils._text import to_native 62 | import ssl 63 | import socket 64 | import hashlib 65 | 66 | def main(): 67 | argument_spec = vmware_argument_spec() 68 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 69 | mgr_hostname = module.params['hostname'] 70 | mgr_username = module.params['username'] 71 | mgr_password = module.params['password'] 72 | validate_certs = module.params['validate_certs'] 73 | manager_url = 'https://{}/global-manager/api/v1'.format(mgr_hostname) 74 | sites_api_url = manager_url + '/global-infra/sites/' 75 | 76 | changed = False 77 | try: 78 | (rc, resp) = request(sites_api_url, headers=dict(Accept='application/json'), 79 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 80 | except Exception as err: 81 | module.fail_json(msg='Error accessing local managers. Error [%s]' % (to_native(err))) 82 | 83 | module.exit_json(changed=changed, **resp) 84 | 85 | 86 | if __name__ == '__main__': 87 | main() 88 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_fabric_compute_managers_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | ANSIBLE_METADATA = {'metadata_version': '1.1', 19 | 'status': ['preview'], 20 | 'supported_by': 'community'} 21 | 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_fabric_compute_managers_facts 26 | short_description: Return the List of Compute managers 27 | description: Returns information about all compute managers. 28 | version_added: "2.7" 29 | author: Rahul Raghuvanshi 30 | options: 31 | hostname: 32 | description: Deployed NSX manager hostname. 33 | required: true 34 | type: str 35 | username: 36 | description: The username to authenticate with the NSX manager. 37 | required: true 38 | type: str 39 | password: 40 | description: The password to authenticate with the NSX manager. 41 | required: true 42 | type: str 43 | 44 | ''' 45 | 46 | EXAMPLES = ''' 47 | - name: Lists all compute managers 48 | nsxt_fabric_compute_managers_facts: 49 | hostname: "10.192.167.137" 50 | username: "admin" 51 | password: "Admin!23Admin" 52 | validate_certs: False 53 | ''' 54 | 55 | RETURN = '''# ''' 56 | 57 | import json 58 | from ansible.module_utils.basic import AnsibleModule 59 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 60 | from ansible.module_utils.urls import open_url, fetch_url 61 | from ansible.module_utils._text import to_native 62 | from ansible.module_utils.six.moves.urllib.error import HTTPError 63 | 64 | def main(): 65 | argument_spec = vmware_argument_spec() 66 | 67 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 68 | 69 | mgr_hostname = module.params['hostname'] 70 | mgr_username = module.params['username'] 71 | mgr_password = module.params['password'] 72 | validate_certs = module.params['validate_certs'] 73 | 74 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 75 | 76 | changed = False 77 | try: 78 | (rc, resp) = request(manager_url+ '/fabric/compute-managers', headers=dict(Accept='application/json'), 79 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 80 | except Exception as err: 81 | module.fail_json(msg='Error accessing fabric compute manager. Error [%s]' % (to_native(err))) 82 | 83 | module.exit_json(changed=changed, **resp) 84 | if __name__ == '__main__': 85 | main() 86 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_transport_node_collections_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | ANSIBLE_METADATA = {'metadata_version': '1.1', 19 | 'status': ['preview'], 20 | 'supported_by': 'community'} 21 | 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_transport_node_collections_facts 26 | short_description: List Transport Node collections 27 | description: Returns all Transport Node collections 28 | version_added: "2.7" 29 | author: Rahul Raghuvanshi 30 | options: 31 | hostname: 32 | description: Deployed NSX manager hostname. 33 | required: true 34 | type: str 35 | username: 36 | description: The username to authenticate with the NSX manager. 37 | required: true 38 | type: str 39 | password: 40 | description: The password to authenticate with the NSX manager. 41 | required: true 42 | type: str 43 | 44 | ''' 45 | 46 | EXAMPLES = ''' 47 | - name: List Transport Node collections 48 | nsxt_fabric_compute_managers_facts: 49 | hostname: "10.192.167.137" 50 | username: "admin" 51 | password: "Admin!23Admin" 52 | validate_certs: False 53 | ''' 54 | 55 | RETURN = '''# ''' 56 | 57 | import json 58 | from ansible.module_utils.basic import AnsibleModule 59 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 60 | from ansible.module_utils.urls import open_url, fetch_url 61 | from ansible.module_utils._text import to_native 62 | from ansible.module_utils.six.moves.urllib.error import HTTPError 63 | 64 | def main(): 65 | argument_spec = vmware_argument_spec() 66 | 67 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 68 | 69 | mgr_hostname = module.params['hostname'] 70 | mgr_username = module.params['username'] 71 | mgr_password = module.params['password'] 72 | validate_certs = module.params['validate_certs'] 73 | 74 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 75 | 76 | changed = False 77 | try: 78 | (rc, resp) = request(manager_url+ '/transport-node-collections', headers=dict(Accept='application/json'), 79 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 80 | except Exception as err: 81 | module.fail_json(msg='Error accessing transport-node-collections. Error [%s]' % (to_native(err))) 82 | 83 | module.exit_json(changed=changed, **resp) 84 | if __name__ == '__main__': 85 | main() 86 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_edge_clusters_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | ANSIBLE_METADATA = {'metadata_version': '1.1', 19 | 'status': ['preview'], 20 | 'supported_by': 'community'} 21 | 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_edge_clusters_facts 26 | short_description: List Edge Clusters 27 | description: Returns information about the configured edge clusters, which enable you to 28 | group together transport nodes of the type EdgeNode and apply fabric 29 | profiles to all members of the edge cluster. Each edge node can participate 30 | in only one edge cluster. 31 | 32 | version_added: "2.7" 33 | author: Rahul Raghuvanshi 34 | options: 35 | hostname: 36 | description: Deployed NSX manager hostname. 37 | required: true 38 | type: str 39 | username: 40 | description: The username to authenticate with the NSX manager. 41 | required: true 42 | type: str 43 | password: 44 | description: The password to authenticate with the NSX manager. 45 | required: true 46 | type: str 47 | ''' 48 | 49 | EXAMPLES = ''' 50 | - name: List Edge Clusters 51 | nsxt_edge_clusters_facts: 52 | hostname: "10.192.167.137" 53 | username: "admin" 54 | password: "Admin!23Admin" 55 | validate_certs: False 56 | ''' 57 | 58 | RETURN = '''# ''' 59 | 60 | import json 61 | from ansible.module_utils.basic import AnsibleModule 62 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 63 | from ansible.module_utils._text import to_native 64 | 65 | def main(): 66 | argument_spec = vmware_argument_spec() 67 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 68 | 69 | mgr_hostname = module.params['hostname'] 70 | mgr_username = module.params['username'] 71 | mgr_password = module.params['password'] 72 | validate_certs = module.params['validate_certs'] 73 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 74 | 75 | changed = False 76 | try: 77 | (rc, resp) = request(manager_url+ '/edge-clusters', headers=dict(Accept='application/json'), 78 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 79 | except Exception as err: 80 | module.fail_json(msg='Error accessing list of edge cluster. Error [%s]' % (to_native(err))) 81 | 82 | module.exit_json(changed=changed, **resp) 83 | if __name__ == '__main__': 84 | main() 85 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_policy_ip_pool_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | 19 | ANSIBLE_METADATA = {'metadata_version': '1.1', 20 | 'status': ['preview'], 21 | 'supported_by': 'community'} 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_ip_pools_facts 26 | short_description: List IP Pools 27 | description: Returns information about the configured IP address pools. Information 28 | includes the display name and description of the pool and the details of 29 | each of the subnets in the pool, including the DNS servers, allocation 30 | ranges, gateway, and CIDR subnet address. 31 | 32 | version_added: "2.7" 33 | author: Rahul Raghuvanshi 34 | options: 35 | hostname: 36 | description: Deployed NSX manager hostname. 37 | required: true 38 | type: str 39 | username: 40 | description: The username to authenticate with the NSX manager. 41 | required: true 42 | type: str 43 | password: 44 | description: The password to authenticate with the NSX manager. 45 | required: true 46 | type: str 47 | 48 | ''' 49 | 50 | EXAMPLES = ''' 51 | - name: List IP Pools 52 | nsxt_ip_pools_facts: 53 | hostname: "10.192.167.137" 54 | username: "admin" 55 | password: "Admin!23Admin" 56 | validate_certs: False 57 | ''' 58 | 59 | RETURN = '''# ''' 60 | 61 | from ansible.module_utils.basic import AnsibleModule 62 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 63 | from ansible.module_utils._text import to_native 64 | 65 | def main(): 66 | argument_spec = vmware_argument_spec() 67 | 68 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 69 | 70 | mgr_hostname = module.params['hostname'] 71 | mgr_username = module.params['username'] 72 | mgr_password = module.params['password'] 73 | validate_certs = module.params['validate_certs'] 74 | 75 | manager_url = 'https://{}/policy/api/v1'.format(mgr_hostname) 76 | 77 | changed = False 78 | try: 79 | (rc, resp) = request(f"{manager_url}/infra/ip-blocks", headers=dict(Accept='application/json'), 80 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 81 | except Exception as err: 82 | module.fail_json(msg='Error accessing list of ip pools. Error [%s]' % (to_native(err))) 83 | 84 | module.exit_json(changed=changed, **resp) 85 | if __name__ == '__main__': 86 | main() 87 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_logical_routers_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | 19 | ANSIBLE_METADATA = {'metadata_version': '1.1', 20 | 'status': ['preview'], 21 | 'supported_by': 'community'} 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_logical_routers_facts 26 | short_description: List Logical Routers 27 | description: Returns information about all logical routers, including the UUID, internal 28 | and external transit network addresses, and the router type (TIER0 or 29 | TIER1). You can get information for only TIER0 routers or only the TIER1 30 | routers by including the router_type query parameter. 31 | 32 | version_added: "2.7" 33 | author: Rahul Raghuvanshi 34 | options: 35 | hostname: 36 | description: Deployed NSX manager hostname. 37 | required: true 38 | type: str 39 | username: 40 | description: The username to authenticate with the NSX manager. 41 | required: true 42 | type: str 43 | password: 44 | description: The password to authenticate with the NSX manager. 45 | required: true 46 | type: str 47 | 48 | ''' 49 | 50 | EXAMPLES = ''' 51 | - name: List Logical Routers 52 | nsxt_logical_routers_facts: 53 | hostname: "10.192.167.137" 54 | username: "admin" 55 | password: "Admin!23Admin" 56 | validate_certs: False 57 | ''' 58 | 59 | RETURN = '''# ''' 60 | 61 | import json 62 | from ansible.module_utils.basic import AnsibleModule 63 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 64 | from ansible.module_utils._text import to_native 65 | 66 | def main(): 67 | argument_spec = vmware_argument_spec() 68 | 69 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 70 | 71 | mgr_hostname = module.params['hostname'] 72 | mgr_username = module.params['username'] 73 | mgr_password = module.params['password'] 74 | validate_certs = module.params['validate_certs'] 75 | 76 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 77 | 78 | changed = False 79 | try: 80 | (rc, resp) = request(manager_url+ '/logical-routers', headers=dict(Accept='application/json'), 81 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 82 | except Exception as err: 83 | module.fail_json(msg='Error accessing list of logical routers. Error [%s]' % (to_native(err))) 84 | 85 | module.exit_json(changed=changed, **resp) 86 | if __name__ == '__main__': 87 | main() 88 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_logical_ports_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | 19 | ANSIBLE_METADATA = {'metadata_version': '1.1', 20 | 'status': ['preview'], 21 | 'supported_by': 'community'} 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_logical_ports_facts 26 | short_description: List All Logical Ports 27 | description: Returns information about all configured logical switch ports. Logical 28 | switch ports connect to VM virtual network interface cards (NICs). Each 29 | logical port is associated with one logical switch. 30 | 31 | version_added: "2.7" 32 | author: Rahul Raghuvanshi 33 | options: 34 | hostname: 35 | description: Deployed NSX manager hostname. 36 | required: true 37 | type: str 38 | username: 39 | description: The username to authenticate with the NSX manager. 40 | required: true 41 | type: str 42 | password: 43 | description: The password to authenticate with the NSX manager. 44 | required: true 45 | type: str 46 | 47 | ''' 48 | 49 | EXAMPLES = ''' 50 | - name: List All Logical Ports 51 | nsxt_logical_ports_facts: 52 | hostname: "10.192.167.137" 53 | username: "admin" 54 | password: "Admin!23Admin" 55 | validate_certs: False 56 | ''' 57 | 58 | RETURN = '''# ''' 59 | 60 | import json 61 | from ansible.module_utils.basic import AnsibleModule 62 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 63 | from ansible.module_utils.urls import open_url, fetch_url 64 | from ansible.module_utils._text import to_native 65 | from ansible.module_utils.six.moves.urllib.error import HTTPError 66 | 67 | def main(): 68 | argument_spec = vmware_argument_spec() 69 | 70 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 71 | 72 | mgr_hostname = module.params['hostname'] 73 | mgr_username = module.params['username'] 74 | mgr_password = module.params['password'] 75 | validate_certs = module.params['validate_certs'] 76 | 77 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 78 | 79 | changed = False 80 | try: 81 | (rc, resp) = request(manager_url+ '/logical-ports', headers=dict(Accept='application/json'), 82 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 83 | except Exception as err: 84 | module.fail_json(msg='Error accessing list of logical ports. Error [%s]' % (to_native(err))) 85 | 86 | module.exit_json(changed=changed, **resp) 87 | if __name__ == '__main__': 88 | main() 89 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_ip_blocks_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | import json 19 | from ansible.module_utils.basic import AnsibleModule 20 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 21 | from ansible.module_utils.urls import open_url, fetch_url 22 | from ansible.module_utils._text import to_native 23 | from ansible.module_utils.six.moves.urllib.error import HTTPError 24 | 25 | 26 | ANSIBLE_METADATA = {'metadata_version': '1.1', 27 | 'status': ['preview'], 28 | 'supported_by': 'community'} 29 | 30 | DOCUMENTATION = ''' 31 | --- 32 | module: nsxt_ip_blocks_facts 33 | short_description: Returns list of configured IP address blocks. 34 | description: Returns information about configured IP address blocks. Information includes 35 | the id, display name, description & CIDR of IP address blocks 36 | 37 | version_added: "2.7" 38 | author: Rahul Raghuvanshi 39 | options: 40 | hostname: 41 | description: Deployed NSX manager hostname. 42 | required: true 43 | type: str 44 | username: 45 | description: The username to authenticate with the NSX manager. 46 | required: true 47 | type: str 48 | password: 49 | description: The password to authenticate with the NSX manager. 50 | required: true 51 | type: str 52 | 53 | ''' 54 | 55 | EXAMPLES = ''' 56 | - name: Lists all configured IP address blocks 57 | nsxt_ip_block_facts: 58 | hostname: "10.192.167.137" 59 | username: "admin" 60 | password: "Admin!23Admin" 61 | validate_certs: False 62 | ''' 63 | 64 | RETURN = '''# ''' 65 | 66 | def main(): 67 | argument_spec = vmware_argument_spec() 68 | #raise ValueError(argument_spec) 69 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 70 | 71 | mgr_hostname = module.params['hostname'] 72 | mgr_username = module.params['username'] 73 | mgr_password = module.params['password'] 74 | validate_certs = module.params['validate_certs'] 75 | #raise ValueError(argument_spec) 76 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 77 | 78 | changed = False 79 | try: 80 | (rc, resp) = request(manager_url+ '/pools/ip-blocks', headers=dict(Accept='application/json'), 81 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 82 | except Exception as err: 83 | module.fail_json(msg='Error accessing list of ip blocks. Error [%s]' % (to_native(err))) 84 | 85 | module.exit_json(changed=changed, **resp) 86 | if __name__ == '__main__': 87 | main() 88 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_ip_pools_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | 19 | ANSIBLE_METADATA = {'metadata_version': '1.1', 20 | 'status': ['preview'], 21 | 'supported_by': 'community'} 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_ip_pools_facts 26 | short_description: List IP Pools 27 | description: Returns information about the configured IP address pools. Information 28 | includes the display name and description of the pool and the details of 29 | each of the subnets in the pool, including the DNS servers, allocation 30 | ranges, gateway, and CIDR subnet address. 31 | 32 | version_added: "2.7" 33 | author: Rahul Raghuvanshi 34 | options: 35 | hostname: 36 | description: Deployed NSX manager hostname. 37 | required: true 38 | type: str 39 | username: 40 | description: The username to authenticate with the NSX manager. 41 | required: true 42 | type: str 43 | password: 44 | description: The password to authenticate with the NSX manager. 45 | required: true 46 | type: str 47 | 48 | ''' 49 | 50 | EXAMPLES = ''' 51 | - name: List IP Pools 52 | nsxt_ip_pools_facts: 53 | hostname: "10.192.167.137" 54 | username: "admin" 55 | password: "Admin!23Admin" 56 | validate_certs: False 57 | ''' 58 | 59 | RETURN = '''# ''' 60 | 61 | import json 62 | from ansible.module_utils.basic import AnsibleModule 63 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 64 | from ansible.module_utils.urls import open_url, fetch_url 65 | from ansible.module_utils._text import to_native 66 | from ansible.module_utils.six.moves.urllib.error import HTTPError 67 | 68 | def main(): 69 | argument_spec = vmware_argument_spec() 70 | 71 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 72 | 73 | mgr_hostname = module.params['hostname'] 74 | mgr_username = module.params['username'] 75 | mgr_password = module.params['password'] 76 | validate_certs = module.params['validate_certs'] 77 | 78 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 79 | 80 | changed = False 81 | try: 82 | (rc, resp) = request(manager_url+ '/pools/ip-pools', headers=dict(Accept='application/json'), 83 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 84 | except Exception as err: 85 | module.fail_json(msg='Error accessing list of ip pools. Error [%s]' % (to_native(err))) 86 | 87 | module.exit_json(changed=changed, **resp) 88 | if __name__ == '__main__': 89 | main() 90 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_transport_nodes.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile.yml 9 | tasks: 10 | - name: Create transport node 11 | vmware.ansible_for_nsxt.nsxt_transport_nodes: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: "{{item.display_name}}" 17 | host_switch_spec: 18 | resource_type: StandardHostSwitchSpec 19 | host_switches: "{{item.host_switches}}" 20 | node_deployment_info: "{{item.node_deployment_info}}" 21 | # Host node deployment info 22 | # resource_type: "{{item.node_deployment_info.resource_type}}" 23 | # display_name: "{{item.node_deployment_info.display_name}}" 24 | # ip_addresses: "{{item.node_deployment_info.ip_addresses}}" 25 | # os_type: "{{item.node_deployment_info.os_type}}" 26 | # os_version: "{{item.node_deployment_info.os_version}}" 27 | # host_credential: 28 | # username: "{{item.node_deployment_info.host_credential.username}}" 29 | # password: "{{item.node_deployment_info.host_credential.password}}" 30 | # thumbprint: "{{item.node_deployment_info.host_credential.thumbprint}}" 31 | # Edge node deployment info 32 | # resource_type: "{{item.node_deployment_info.resource_type}}" 33 | # display_name: "{{item.node_deployment_info.display_name}}" 34 | # ip_addresses: "{{item.node_deployment_info.ip_addresses}}" 35 | # deployment_type: "{{item.node_deployment_info.deployment_type}}" 36 | # deployment_config: 37 | # form_factor: "{{item.node_deployment_info.deployment_config.form_factor}}" 38 | # node_user_settings: 39 | # cli_password: "{{item.node_deployment_info.deployment_config.node_user_settings.cli_password}}" 40 | # root_password: "{{item.node_deployment_info.deployment_config.node_user_settings.root_password}}" 41 | # vm_deployment_config: 42 | # placement_type: "{{item.node_deployment_info.deployment_config.vm_deployment_config.placement_type}}" 43 | # vc_id: "{{item.node_deployment_info.deployment_config.vm_deployment_config.vc_id}}" 44 | # data_network_ids: "{{item.node_deployment_info.deployment_config.vm_deployment_config.data_network_ids}}" 45 | # management_network_id: "{{item.node_deployment_info.deployment_config.vm_deployment_config.management_network_id}}" 46 | # hostname: "{{item.node_deployment_info.deployment_config.vm_deployment_config.hostname}}" 47 | # compute_id: "{{item.node_deployment_info.deployment_config.vm_deployment_config.compute_id}}" 48 | # storage_id: "{{item.node_deployment_info.deployment_config.vm_deployment_config.storage_id}}" 49 | # host_id: "{{item.node_deployment_info.deployment_config.vm_deployment_config.host_id}}" 50 | # default_gateway_addresses: "{{item.node_deployment_info.deployment_config.vm_deployment_config.default_gateway_addresses}}" 51 | # management_port_subnets: 52 | # - ip_addresses: "{{item.node_deployment_info.deployment_config.vm_deployment_config.management_port_subnets.ip_addresses}}" 53 | # prefix_length: "{{item.node_deployment_info.deployment_config.vm_deployment_config.management_port_subnets.prefix_length}}" 54 | state: present 55 | with_items: 56 | - "{{host_transport_nodes}}" 57 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_policy_ip_block.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 8 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 9 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 10 | # A PARTICULAR PURPOSE ARE DISCLAIMED. 11 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 12 | # DIRECT, INDIRECT, INCIDENTAL, 13 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 14 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 15 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 16 | # ON ANY THEORY OF LIABILITY, 17 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 18 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 19 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 20 | 21 | from __future__ import (absolute_import, division, print_function) 22 | __metaclass__ = type 23 | 24 | ANSIBLE_METADATA = {'metadata_version': '1.1', 25 | 'status': ['preview'], 26 | 'supported_by': 'community'} 27 | 28 | DOCUMENTATION = ''' 29 | --- 30 | module: nsxt_policy_ip_block 31 | short_description: Create or Delete a Policy IP Block 32 | description: 33 | Creates or deletes a Policy IP Block. 34 | Required attributes include id and display_name. 35 | version_added: "2.8" 36 | author: Gautam Verma 37 | extends_documentation_fragment: 38 | - vmware.ansible_for_nsxt.vmware_nsxt 39 | options: 40 | id: 41 | description: The id of the Policy IP Block. 42 | required: false 43 | type: str 44 | description: 45 | description: IP Block description. 46 | type: str 47 | cidr: 48 | description: 49 | - A contiguous IP address space represented by network address 50 | and prefix length 51 | - Represents a network address and the prefix length which will 52 | be associated with a layer-2 broadcast domain. Support only IPv4 53 | CIDR. 54 | required: true 55 | type: str 56 | ''' 57 | 58 | EXAMPLES = ''' 59 | - name: create IP Block 60 | nsxt_policy_ip_block: 61 | hostname: "10.10.10.10" 62 | nsx_cert_path: /root/com.vmware.nsx.ncp/nsx.crt 63 | nsx_key_path: /root/com.vmware.nsx.ncp/nsx.key 64 | validate_certs: False 65 | id: test-ip-blk 66 | display_name: test-ip-blk 67 | state: "present" 68 | cidr: "192.168.0.0/16" 69 | ''' 70 | 71 | RETURN = '''# ''' 72 | 73 | import json 74 | import time 75 | from ansible.module_utils.basic import AnsibleModule 76 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.nsxt_base_resource import NSXTBaseRealizableResource 77 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.nsxt_resource_urls import IP_BLOCK_URL 78 | from ansible.module_utils._text import to_native 79 | 80 | 81 | class NSXTIpBlock(NSXTBaseRealizableResource): 82 | @staticmethod 83 | def get_resource_spec(): 84 | ip_block_arg_spec = {} 85 | ip_block_arg_spec.update( 86 | cidr=dict( 87 | required=True, 88 | type='str' 89 | ) 90 | ) 91 | return ip_block_arg_spec 92 | 93 | @staticmethod 94 | def get_resource_base_url(baseline_args=None): 95 | return IP_BLOCK_URL 96 | 97 | 98 | if __name__ == '__main__': 99 | ip_block = NSXTIpBlock() 100 | ip_block.realize() 101 | -------------------------------------------------------------------------------- /tests/playbooks/mp/test_attach_tnp_to_cluster_9x.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 VMware, Inc. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: 127.0.0.1 5 | connection: local 6 | become: yes 7 | vars_files: 8 | - answerfile_attach_tnp_to_cluster_9x.yml 9 | tasks: 10 | - name: Register compute manager 11 | vmware.ansible_for_nsxt.nsxt_fabric_compute_managers: 12 | hostname: "{{hostname}}" 13 | username: "{{username}}" 14 | password: "{{password}}" 15 | validate_certs: False 16 | display_name: "{{item.display_name}}" 17 | server: "{{item.server}}" 18 | origin_type: "{{item.origin_type}}" 19 | credential: 20 | credential_type: "{{item.credential_type}}" 21 | username: "{{item.username}}" 22 | password: "{{item.password}}" 23 | thumbprint: "{{item.thumbprint}}" 24 | state: present 25 | with_items: 26 | - "{{compute_managers}}" 27 | 28 | - name: Create ip pool 29 | vmware.ansible_for_nsxt.nsxt_policy_ip_pool: 30 | hostname: "{{hostname}}" 31 | username: "{{username}}" 32 | password: "{{password}}" 33 | validate_certs: False 34 | display_name: "{{item.display_name}}" 35 | pool_static_subnets: "{{item.pool_static_subnets}}" 36 | state: present 37 | with_items: 38 | - "{{ip_pools}}" 39 | 40 | - name: Create transport zone 41 | vmware.ansible_for_nsxt.nsxt_transport_zones: 42 | hostname: "{{hostname}}" 43 | username: "{{username}}" 44 | password: "{{password}}" 45 | validate_certs: False 46 | resource_type: "PolicyTransportZone" 47 | display_name: "{{item.display_name}}" 48 | description: "NSX configured Test Transport Zone" 49 | tz_type: "{{item.tz_type}}" 50 | state: "present" 51 | with_items: 52 | - "{{transportzones}}" 53 | 54 | - name: Create uplink profile 55 | vmware.ansible_for_nsxt.nsxt_uplink_profiles: 56 | hostname: "{{hostname}}" 57 | username: "{{username}}" 58 | password: "{{password}}" 59 | validate_certs: False 60 | resource_type: UplinkHostSwitchProfile 61 | display_name: "{{item.display_name}}" 62 | teaming: "{{item.teaming}}" 63 | transport_vlan: "{{item.transport_vlan}}" 64 | state: "present" 65 | with_items: 66 | - "{{uplink_profiles}}" 67 | 68 | - name: Create transport node profile 69 | vmware.ansible_for_nsxt.nsxt_transport_node_profiles: 70 | hostname: "{{hostname}}" 71 | username: "{{username}}" 72 | password: "{{password}}" 73 | validate_certs: False 74 | resource_type: PolicyHostTransportNodeProfile 75 | display_name: "{{item.display_name}}" 76 | description: NSX configured Test Transport Node Profile 77 | host_switch_spec: 78 | resource_type: StandardHostSwitchSpec 79 | host_switches: "{{item.host_switches}}" 80 | state: present 81 | with_items: 82 | - "{{transport_node_profiles}}" 83 | 84 | - name: Attach Transport node profile to cluster 85 | vmware.ansible_for_nsxt.nsxt_transport_node_collections: 86 | hostname: "{{hostname}}" 87 | username: "{{username}}" 88 | password: "{{password}}" 89 | validate_certs: False 90 | display_name: "TNC1" 91 | resource_type: "TransportNodeCollection" 92 | description: "Transport Node Collections 1" 93 | compute_manager_name: "VC1" 94 | cluster_name: "os-compute-cluster-1" 95 | transport_node_profile_name: "TNP1" 96 | state: present 97 | -------------------------------------------------------------------------------- /plugins/modules/nsxt_transport_nodes_facts.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 VMware, Inc. 5 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 6 | # 7 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 8 | # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 9 | # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 11 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 13 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | 15 | from __future__ import absolute_import, division, print_function 16 | __metaclass__ = type 17 | 18 | 19 | ANSIBLE_METADATA = {'metadata_version': '1.1', 20 | 'status': ['preview'], 21 | 'supported_by': 'community'} 22 | 23 | DOCUMENTATION = ''' 24 | --- 25 | module: nsxt_transport_nodes_facts 26 | short_description: List Transport Nodes 27 | description: Returns information about all transport nodes along with underlying host or 28 | edge details. A transport node is a host or edge that contains hostswitches. 29 | A hostswitch can have virtual machines connected to them. 30 | 31 | Because each transport node has hostswitches, transport nodes can also have 32 | virtual tunnel endpoints, which means that they can be part of the overlay. 33 | 34 | version_added: "2.7" 35 | author: Rahul Raghuvanshi 36 | options: 37 | hostname: 38 | description: Deployed NSX manager hostname. 39 | required: true 40 | type: str 41 | username: 42 | description: The username to authenticate with the NSX manager. 43 | required: true 44 | type: str 45 | password: 46 | description: The password to authenticate with the NSX manager. 47 | required: true 48 | type: str 49 | 50 | 51 | ''' 52 | 53 | EXAMPLES = ''' 54 | - name: List Transport Nodes 55 | nsxt_transport_nodes_facts: 56 | hostname: "10.192.167.137" 57 | username: "admin" 58 | password: "Admin!23Admin" 59 | validate_certs: False 60 | ''' 61 | 62 | RETURN = '''# ''' 63 | 64 | import json 65 | from ansible.module_utils.basic import AnsibleModule 66 | from ansible_collections.vmware.ansible_for_nsxt.plugins.module_utils.vmware_nsxt import vmware_argument_spec, request 67 | from ansible.module_utils._text import to_native 68 | 69 | def main(): 70 | argument_spec = vmware_argument_spec() 71 | 72 | module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) 73 | 74 | mgr_hostname = module.params['hostname'] 75 | mgr_username = module.params['username'] 76 | mgr_password = module.params['password'] 77 | validate_certs = module.params['validate_certs'] 78 | 79 | manager_url = 'https://{}/api/v1'.format(mgr_hostname) 80 | 81 | changed = False 82 | try: 83 | (rc, resp) = request(manager_url+ '/transport-nodes', headers=dict(Accept='application/json'), 84 | url_username=mgr_username, url_password=mgr_password, validate_certs=validate_certs, ignore_errors=True) 85 | except Exception as err: 86 | module.fail_json(msg='Error accessing transport zone. Error [%s]' % (to_native(err))) 87 | 88 | module.exit_json(changed=changed, **resp) 89 | if __name__ == '__main__': 90 | main() 91 | --------------------------------------------------------------------------------