Ansible in NSX-T and NSX-ALB: Using collections


A couple of days ago, I noticed VMware is changing Ansible roles to collections.
Collections are a distribution format for Ansible content that can include playbooks, roles, modules, and plugins.
This distribution is performed by Ansible Galaxy, which is a place from where you can install or get other developer’s shared content.
This is a great thing. Now we do not need to install an SDK anymore. Everything is included in the collection. This saves time installing.

I am using NSX-T 3.1.2 and AVI 20.1.5.
For Ansible I am using Linux (Ubuntu 18.04 LTS)

Installation Ansible collections

Official Git repo and README can be found here: NSX-ALB and NSX-T

Using Ansible-Galaxy

ansible-galaxy collection install vmware.alb
ansible-galaxy collection install vmware.ansible_for_nsxt

Installing by hand

I installed the collection by hand using Git. Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. A short reference to Git can be found here.

mkdir -p ~/.ansible/collections/ansible_collections/vmware
cd ~/.ansible/collections/ansible_collections/vmware
git clone alb
git clone ansible_for_nsxt

What are the consequences for this change to use collections

Changing from roles to collections can impact your playbooks.
In my previous post (Ansible with NSX-T and AVI part 1 –, I used ansible-roles

In this example, I am using the file ’07_create_pool.yml’ from the previous post.

  - role: "avinetworks.avisdk"

Roles need to change to collections

  - vmware.alb

Testing the new Ansible playbook file

$ ansible-playbook 07_create_pool.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [localhost] *******************************************************************************************************************************************************************

TASK [Gathering Facts] *************************************************************************************************************************************************************
ok: [localhost]

TASK [Create local load balancing pool] ********************************************************************************************************************************************
changed: [localhost] => (item={'pool_name': 'sddc01-vs02-pool01', 'healthmonitor_name': 'sddc01-vs02-hm01', 'pool_members': [{'ip': {'addr': '', 'type': 'V4'}, 'hostname': 'web01'}, {'ip': {'addr': '', 'type': 'V4'}, 'hostname': 'web02'}]})

PLAY RECAP *************************************************************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

I only needed to change from roles to collections and the playbooks work just fine.


Good move from VMware using collections. It saves time installing. And with Ansible-Galaxy it is very easy to install.
You can still use the roles if you want. Take a look at the v3.0.1 branch in git here.

One thought on “Ansible in NSX-T and NSX-ALB: Using collections

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s