Introduction
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 developers 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
ansible-galaxy collection install vmware.alb
ansible-galaxy collection install vmware.ansible_for_nsx
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 ~/.ansible/collections/ansible_collections/vmware
cd ~/.ansible/collections/ansible_collections/vmware
git clone https://github.com/vmware/ansible-collection-alb alb
git clone https://github.com/vmware/ansible-for-nsxt ansible_for_nsxt
What are the consequences of this change to the use of collections
Changing from roles to collections can impact your playbooks.
In my previous post (Ansible with NSX-T and AVI part 1 cloudworkspace.blog), I used ansible-roles
In this example, I use the file “07_create_pool.yml” from the previous post.
roles:
- role: "avinetworks.avisdk"
Roles need to change to collections
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': '10.4.193.20', 'type': 'V4'}, 'hostname': 'web01'}, {'ip': {'addr': '10.4.193.21', 'type': 'V4'}, 'hostname': 'web02'}]})
PLAY RECAP *************************************************************************************************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
$ 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': '10.4.193.20', 'type': 'V4'}, 'hostname': 'web01'}, {'ip': {'addr': '10.4.193.21', '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 worked just fine.
Conclusion
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.
B
chris