Deploying NSX-T Using Ansible – Part 3: Running The Playbook

Posts in the Series: Deploying NSX-T Using Ansible
  1. Deploying NSX-T Using Ansible – Part 1: Setting Up The Environment
  2. Deploying NSX-T Using Ansible – Part 2: Setting Up The Playbook
  3. Deploying NSX-T Using Ansible – Part 3: Running The Playbook

In this post, I am going to cover the running of the Ansible NSX-T playbook so that you can get NSX-T deployed in your environment(s). In case you missed them, in my previous posts, I detailed how to set up your Ansible environment and configure the playbook in preparation for deploying NSX-T.

If you arrived here and want to figure it out for yourself, you can download my playbooks here.

Playbook Overview

The main playbook that you will need to run is called ‘nsxt_create_environment.yml‘, which is located in the root of the Ansible-NSXT folder.

---
## Deploys an NSX-T environment
- hosts: nsxt_managers_controllers
  connection: local
  become: yes
  gather_facts: False
  vars:
    nsxt_deployment_vcenter: "{{ mgmt_vcenter_server }}"
    nsxt_deployment_vcenter_username: "{{ mgmt_vcenter_admin_username }}"
    nsxt_deployment_vcenter_password: "{{ mgmt_vcenter_admin_password }}"
    nsxt_deployment_datacenter: "{{ mgmt_vcenter_datacenter }}"
    nsxt_deployment_cluster: "{{ mgmt_vcenter_cluster }}"
    nsxt_deployment_datastore: "{{ nsxt_datastore }}"
    nsxt_deployment_portgroup: "{{ nsxt_portgroup }}"
    nsxt_deployment_size: "{{ nsxt_default_deployment_size }}"
    nsxt_role: "{{ nsxt_default_role }}"

    compute_managers:
    - name: "{{ nsxt_compute_manager_name }}"
      host: "{{ nsxt_compute_manager_host }}"
      transport_clusters: "{{ nsxt_transport_clusters }}"

    ip_pools:
    - display_name: "{{ nsxt_transport_switch_ip_pool_name }}"
      subnets:
      - allocation_ranges:
        - start: "{{ nsxt_transport_switch_ip_pool_start }}"
          end: "{{ nsxt_transport_switch_ip_pool_end }}"
        cidr: "{{ nsxt_transport_switch_ip_pool_cidr }}"

    transport_zones:
    - display_name: "{{ nsxt_transport_zone_name }}"
      description: "{{ nsxt_transport_zone_desc }}"
      transport_type: "OVERLAY"
      transport_switch_name: "{{ nsxt_transport_switch_name }}"

    uplink_profiles:
    - display_name: "{{ nsxt_transport_switch_uplink_profile_name }}"
      teaming:
        active_list:
        - uplink_name: "{{ nsxt_transport_switch_uplink_1 }}"
          uplink_type: PNIC
        - uplink_name: "{{ nsxt_transport_switch_uplink_2 }}"
          uplink_type: PNIC
        policy: "{{ nsxt_transport_switch_uplink_profile_policy }}"
      transport_vlan: "{{ nsxt_transport_switch_uplink_profile_vlan }}"

    transport_node_profiles:
    - display_name: "{{ nsxt_transport_node_profile_name }}"
      description: "{{ nsxt_transport_switch_profile_desc }}"
      host_switches:
      - host_switch_profiles:
        - name: "{{ nsxt_transport_switch_uplink_profile_name }}"
          type: UplinkHostSwitchProfile
        host_switch_name: "{{ nsxt_transport_switch_name }}"
        pnics:
        - device_name: "{{ nsxt_transport_switch_pnic_1 }}"
          uplink_name: "{{ nsxt_transport_switch_uplink_1 }}"
        - device_name: "{{ nsxt_transport_switch_pnic_2 }}"
          uplink_name: "{{ nsxt_transport_switch_uplink_2 }}"
        ip_assignment_spec:
          resource_type: StaticIpPoolSpec
          ip_pool_name: "{{ nsxt_transport_switch_ip_pool_name }}"
      transport_zone_endpoints:
      - transport_zone_name: "{{ nsxt_transport_zone_name }}"
    
  roles:
    - nsxt_deploy_ova
    - nsxt_apply_license
    - nsxt_add_compute_managers
    - nsxt_create_ip_pools
    - nsxt_create_transport_zones
    - nsxt_create_uplink_profiles
    - nsxt_create_transport_profiles
    - nsxt_configure_transport_clusters

By default, the playbook is targeting the ‘nsxt_managers_controllers‘ group, that has been defined in the inventory hosts file. You can, of course, change this to another group or even a specific host, but I prefer to limit the target hosts during execution if required (I’ll detail more on that in the next section).

The first section of the playbook is made up of all the vars that are used by the various roles to deploy NSX-T. You will notice that all the variables that have been defined in the ‘group_vars’ files are being included here. This approach means that I can re-use this playbook (for the most part), without changing anything. All I need to do is correctly set up the ‘group_vars’ files and they will be included. This will allow the playbook to scale to deployments across any number of required sites.

The last section of the playbook is the roles which are being called/used for the deployment. These roles provide the nuggets of functionality that are stitched together in the playbook to create the full solution.

Running the Playbook

Running the playbook is a simple case of executing the following command:

ansible-playbook nsxt_create_environment.yml

If you are deploying across multiple sites, then one of the great features of this playbook is that the deployment will occur simultaneously. In my lab, my 2 sites are virtualized and are using the same management vCenter to host the NSX-T appliances. Below you can see the import occurring twice, one for each site.

And here is the output of my playbook execution, which shows the configuration for NSX-T at both sites being applied:

[stephensg@sg1-ans001 Ansible-NSXT]$ ansible-playbook nsxt_create_environment.yml

PLAY [nsxt_managers_controllers] ****************************************************************************************************************************

TASK [nsxt_deploy_ova : deploy NSX-T Manager OVA] ***********************************************************************************************************
changed: [sg1-nsx002]
changed: [sg1-nsx003]

TASK [Check NSX-T Manager Status] ***************************************************************************************************************************

TASK [nsxt_check_manager_status : Check NSX-T Manager Status] ***********************************************************************************************
ok: [sg1-nsx002]
ok: [sg1-nsx003]

TASK [nsxt_apply_license : Add NSX-T License] ***************************************************************************************************************
changed: [sg1-nsx003]
changed: [sg1-nsx002]

TASK [nsxt_add_compute_managers : Add NSX-T Compute Managers] ***********************************************************************************************
included: /home/stephensg/Ansible-NSXT/roles/nsxt_add_compute_managers/tasks/add_compute_manager.yml for sg1-nsx002
included: /home/stephensg/Ansible-NSXT/roles/nsxt_add_compute_managers/tasks/add_compute_manager.yml for sg1-nsx003

TASK [nsxt_add_compute_managers : Add Compute Manager: SiteA CMP vCenter Server] ****************************************************************************
changed: [sg1-nsx002]

TASK [nsxt_add_compute_managers : Add Compute Manager: SiteB CMP vCenter Server] ****************************************************************************
changed: [sg1-nsx003]

TASK [nsxt_create_ip_pools : Create NSX-T IP Pools] *********************************************************************************************************
included: /home/stephensg/Ansible-NSXT/roles/nsxt_create_ip_pools/tasks/create_ip_pool.yml for sg1-nsx002
included: /home/stephensg/Ansible-NSXT/roles/nsxt_create_ip_pools/tasks/create_ip_pool.yml for sg1-nsx003

TASK [nsxt_create_ip_pools : Creating IP Pool: SiteA-CMP-Transport-Pool] ************************************************************************************
changed: [sg1-nsx002]

TASK [nsxt_create_ip_pools : Creating IP Pool: SiteB-CMP-Transport-Pool] ************************************************************************************
changed: [sg1-nsx003]

TASK [nsxt_create_transport_zones : Create NSX-T Transport Zones] *******************************************************************************************
included: /home/stephensg/Ansible-NSXT/roles/nsxt_create_transport_zones/tasks/create_transport_zone.yml for sg1-nsx002
included: /home/stephensg/Ansible-NSXT/roles/nsxt_create_transport_zones/tasks/create_transport_zone.yml for sg1-nsx003

TASK [nsxt_create_transport_zones : Creating Transport Zone: SiteA-CMP-Transport] ***************************************************************************
changed: [sg1-nsx002]

TASK [nsxt_create_transport_zones : Creating Transport Zone: SiteB-CMP-Transport] ***************************************************************************
changed: [sg1-nsx003]

TASK [nsxt_create_uplink_profiles : Create NSX-T Uplink Profiles] *******************************************************************************************
included: /home/stephensg/Ansible-NSXT/roles/nsxt_create_uplink_profiles/tasks/create_uplink_profile.yml for sg1-nsx002, sg1-nsx003

TASK [nsxt_create_uplink_profiles : Creating uplink profile dualUplinkProfile] ******************************************************************************
changed: [sg1-nsx003]
changed: [sg1-nsx002]

TASK [nsxt_create_transport_profiles : Create NSX-T Transport Node Profiles] ********************************************************************************
included: /home/stephensg/Ansible-NSXT/roles/nsxt_create_transport_profiles/tasks/create_transport_node_profile.yml for sg1-nsx002
included: /home/stephensg/Ansible-NSXT/roles/nsxt_create_transport_profiles/tasks/create_transport_node_profile.yml for sg1-nsx003

TASK [nsxt_create_transport_profiles : Creating Transport Node Profile: SiteA-CMP-Transport-Profile] ********************************************************
changed: [sg1-nsx002]

TASK [nsxt_create_transport_profiles : Creating Transport Node Profile: SiteB-CMP-Transport-Profile] ********************************************************
changed: [sg1-nsx003]

TASK [nsxt_configure_transport_clusters : Configure NSX-T Transport Clusters] *******************************************************************************
included: /home/stephensg/Ansible-NSXT/roles/nsxt_configure_transport_clusters/tasks/configure_transport_cluster.yml for sg1-nsx002
included: /home/stephensg/Ansible-NSXT/roles/nsxt_configure_transport_clusters/tasks/configure_transport_cluster.yml for sg1-nsx003

TASK [nsxt_configure_transport_clusters : Configure Transport Cluster: {{ cls }}] ***************************************************************************
changed: [sg1-nsx002] => (item=SITEA-CLS-CLOUD-01)

TASK [nsxt_configure_transport_clusters : Configure Transport Cluster: {{ cls }}] ***************************************************************************
changed: [sg1-nsx003] => (item=SITEB-CLS-CLOUD-01)

PLAY RECAP **************************************************************************************************************************************************
sg1-nsx002                 : ok=15   changed=8    unreachable=0    failed=0
sg1-nsx003                 : ok=15   changed=8    unreachable=0    failed=0

Targeting Specific Hosts or Groups

If you only want to deploy a specific NSX-T environment, you can use the ‘–limit’ flag and specify the NSX-T host that is a member of the ‘nsxt_managers_controllers‘ group:

ansible-playbook nsxt_create_environment.yml --limit "sg1-nsx002"

That completes the deployment of NSX-T using Ansible. I will continue to add additional posts to this series soon, to cover adding additional fabric nodes and other functionality. Until then, I hope this has been helpful. If you discover any bugs or require some help, then please drop me a message via the Drift app. Also, please provide some feedback on this series so that I may improve it for future readers.

3.7 3 votes
Article Rating

Related Posts

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments