Deploy the AVI/NSX ALB Controller/s using Ansible

In this post, we will go through the process of deploying an AVI Controller cluster. The reason for deploying this as a cluster is to emulate a production deployment. AVI is supported on a single controller, but you lose control plane high availability. If your resource-constrained in your lab (AVI controllers are rather big), If you are deploying a single node, you can amend the .yml file by commenting out the bit you don’t require (Node 2-3 and cluster creation).

For a copy of my example playbook for an avi cluster avi deployment, please refer to llewellyngm/ansible-avi-cluster (github.com)

AVI has some great documentation. If you’re interested in further information about AVI controller nodes and availability, please refer to this link High Availability for Avi Controllers (avinetworks.com).

Logical layout of the deployment

For this deployment, we need to work out our environmental variables, logins, and IPs. Below is an example, but please refer to the variables.yml for the full list.

vSphere InformationExample
vCenter Hostname IP/Hostname192.168.1.20lab-vc-vcsa01.vcumulus.lab
vCenter Useruser to deploy ovf files
vCenter Passwordpassword to deploy ovf files
vCenter Datacentre Namelab-vc
ESXi Cluster Namelab-vc-workloads
vSphere Foldervmware/avi
AVI InformationExample
AVI Cluster IP/Hostname172.16.1.150lab-vc-avict
AVI Node-01 IP/Hostname172.16.1.151lab-vc-avict01
AVI Node-02 IP/Hostname172.16.1.152lab-vc-avict02
AVI Node-03 IP/Hostname172.16.1.153lab-vc-avict03
AVI old passwordFrom AVI Site
AVI new passwordNewPassword
Admin User Nameadmin
NTP Server 1/2192.168.1.13192.168.1.14
DNS Server 1/2172.16.1.2172.16.1.3

Once we have collected all the information, we deploy the controllers with the below .yml file. The playbook calls on the two variable files, one with general variables & config items and the other a vault containing the user name & passwords for the deployment.

The Controllers are deployed and configured in order:

  • Deploy Controller OVF > Configure the OVF with Controller one (1) configuration
  • Deploy Controller OVF > Configure the OVF with Controller two (2) configuration
  • Deploy Controller OVF > Configure the OVF with Controller three (3) configuration
  • Set up the Cluster and configure the VIP & Setup the backup passphrase
---
- hosts: localhost
  connection: local
  vars_files:
    - vars/deploy_cluster_variables.yml
  roles:
    - { role: avinetworks.avicontroller-vmware }
    - { role: avinetworks.avisdk }
  vars:
    controller_configuration:
      - mgmt_ip: "{{ controller_ip_1 }}"
        vm_name: "{{ controller_name_1 }}"
      - mgmt_ip: "{{ controller_ip_2 }}"
        vm_name: "{{ controller_name_2 }}"
      - mgmt_ip: "{{ controller_ip_3 }}"
        vm_name: "{{ controller_name_3 }}"
  tasks:
    - name: Deploy Avi Controller
      with_items: "{{ controller_configuration }}"
      deploy_controller:
        ovftool_path: '{{ ovftool_path }}'
        vcenter_host: "{{ vcenter_host }}"
        vcenter_user: "{{ vcenter_user }}"
        vcenter_password: "{{ vcenter_password }}"
        con_datacenter: "{{ datacenter }}"
        con_cluster: "{{ vmware_cluster_name }}"
        con_ova_path: "{{ ova_path }}"
        con_vm_name: "{{ item.vm_name }}"
        con_disk_size: "{{ con_disk_size | default(omit) }}"
        con_vcenter_folder: "{{ con_folder }}"
        con_datastore: "{{ vmware_datastore }}"
        con_mgmt_network: "{{ con_mgmt_portgroup }}"
        con_power_on: true
        con_mgmt_ip: "{{ item.mgmt_ip }}"
        con_mgmt_mask: "{{ con_mgmt_mask }}"
        con_default_gw: "{{ con_default_gw }}"
    - name: Check Cluster Status
      uri:
        validate_certs: false
        url: "https://{{ item.mgmt_ip }}/api/initial-data"
        method: GET
        status_code: 200
      register: result
      until: result.status == 200
      retries: 600
      delay: 10
      with_items: "{{ controller_configuration }}"
    - name: Change admin default password
      avi_useraccount:
        controller: "{{ controller_ip_1 }}"
        username: "{{ avi_credentials.username }}"
        password: "{{ avi_credentials.password }}"
        api_version: "{{ avi_credentials.api_version }}"
        old_password: "{{ old_password }}"
        email: "{{ admin_email }}"
    - set_fact:
        dns_list: "{{ dns_list | default([]) + [{'type': 'V4', 'addr': dserver }] }}"
      loop: "{{ dns_servers }}"
      loop_control:
        loop_var: dserver
      name: "Prepare DNS Server List"
    - set_fact:
        ntp_list: "{{ ntp_list | default([]) + [{'server': {'type': ntp_type, 'addr': nserver }}] }}"
      loop: "{{ ntp_servers }}"
      loop_control:
        loop_var: nserver
      name: "Prepare NTP Server List"
    - name: Initial Controller System Configuration
      avi_systemconfiguration:
        controller: "{{ controller_ip_1 }}"
        username: "{{ avi_credentials.username }}"
        password: "{{ avi_credentials.password }}"
        api_version: "{{ avi_credentials.api_version }}"
        welcome_workflow_complete: true
        dns_configuration:
          server_list: "{{ dns_list }}"
        ntp_configuration:
          ntp_servers: "{{ ntp_list }}"
    - name: Set Backup Passphrase
      avi_backupconfiguration:
        controller: "{{ controller_ip_1 }}"
        username: "{{ avi_credentials.username }}"
        password: "{{ avi_credentials.password }}"
        api_version: "{{ avi_credentials.api_version }}"
        name: Backup-Configuration
        backup_passphrase: "{{ backup_passphrase }}"
        upload_to_remote_host: false
    - name: Cloud Cluster Configuration
      avi_cluster:
        controller: "{{ controller_ip_1 }}"
        username: "{{ avi_credentials.username }}"
        password: "{{ avi_credentials.password }}"
        api_version: "{{ avi_credentials.api_version }}"
        virtual_ip:
          type: V4
          addr: "{{ controller_cluster_vip }}"
        nodes:
            - name: "{{ controller_name_1 }}" 
              ip:
                type: V4
                addr: "{{ controller_ip_1 }}"
            - name: "{{ controller_name_2 }}"
              ip:
                type: V4
                addr: "{{ controller_ip_2 }}"
            - name: "{{ controller_name_3 }}"
              ip:
                type: V4
                addr: "{{ controller_ip_3 }}"
        name: "{{ avicluster_name }}"
        tenant_uuid: "admin"

example varible

---
# TEMPLATE FOR CONTROLLER DEPLOYMENT AND CLUSTERING in VMWARE

# ovftool is part of the SDK
ovftool_path: /usr/lib/vmware-ovftool

# Controller Name and IP
#
controller_ip_1: "172.16.1.151"
controller_name_1: "lab-vc-alb01"
controller_ip_2: "172.16.1.152"
controller_name_2: "lab-vc-alb02"
controller_ip_3: "172.16.1.153"
controller_name_3: "lab-vc-alb03"

# Info for Controller Placement
con_mgmt_portgroup: "pg-mgt-vlan-401"    # VMware MGMT PortGroup for Controller
con_mgmt_mask: 255.255.255.0
con_default_gw: 172.16.1.1

# Cluster Info for Avi Controller
#
controller_cluster_vip: 172.16.1.150
avicluster_name: 'lab-vc-avi01'
# Avi Controller Credentials
#
avi_credentials:
  controller: "{{ controller_cluster_vip }}"
  username: "admin"
  password: "F1ghtZclub!"
  api_version: "18.2.8"     # Version of Controller

# Controller default password (https://portal.avinetworks.com/)
#
old_password: "aviwebsite"

# Vcenter credentials
#
vcenter_host: lab-vc-vcsa01.vcumulus.lab
vcenter_user: administrator@vsphere.local
vcenter_password: "VMware1!VMware1!"
datacenter: MK19
vmware_cluster_name: "lab-vc-workload"
vmware_datastore: '{{ datastore | default(omit) }}'
con_folder: vmware/avi

#Controller Image Location
#
ova_path: "/home/garethl/.ansible/playbooks/files/controller-20.1.6-9132.ova"

# Avi System Configuration
#
# DNS variables
dns_servers: [ 172.16.1.2, 172.16.1.3 ]

# NTP variables
ntp_servers: [ '192.168.1.13', '192.168.1.14' ]
ntp_type: "V4"  #If servers are hostname use type "DNS", if IP use type "V4"

#Email for admin user (password resets)
admin_email: test_user@internal.lab   

# Backup Passphrase (encrypt sensitive fields)
backup_passphrase: "testpassphrase"

1 thought on “Deploy the AVI/NSX ALB Controller/s using Ansible”

Comments are closed.