How to use Ansible Module for NSX-T

This post documents the experience in using ansible module for nsx-t



The following steps were undertaken in a control VM where the ansible playbook will be executed.

  • Install ovftool

I’m using ubuntu 18.04 and have downloaded ovftool.bundle from VMware. After uploading the file, issue

sh VMware-ovftool-4.3.0-7948156-lin.x86_64.bundle

  • pip3 install --upgrade pyvmomi pyvim requests

Since the module requires python3, we need to install the python plugins using pip3

Install the Modules

Install the module by creating a folder in the default modules for ansible

mkdir -p /usr/share/ansible/plugins/modules/
cd /usr/share/ansible/plugins/modules/
git clone https://github.com/vmware/ansible-for-nsxt.git

Setup ansible-module helper for NSX-T on the ansible.cfg, i just created this in the same folder where my playbooks are:

module_utils = module_utils:/usr/share/ansible/plugins/modules/ansible-for-nsxt/module_utils

Test if the modules are seen by ansible by executing ansible doc command

ansible-doc -t module nsxt_deploy_ova

Execute the playbook

Since Ubuntu 18.04 default python version is 2.7, we need to explicitly tell it to use python3 when executing the playbook.

ansible-playbook createManager.yaml -e ‘ansible_python_interpreter=/usr/bin/python3’

…and that’s it. Hope that helps.

UPDATE: added module helper as it was throwing error on some of the modules i tested.

Leave a Reply


This site uses Akismet to reduce spam. Learn how your comment data is processed.