Skip to content
Interface on top of Ansible Tower (or AWX) for deploying a VMware virtual machine.
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
filter_plugins Simple interface Oct 11, 2019
group_vars Simple interface Oct 11, 2019
library Simple interface Oct 11, 2019
roles Simple interface Oct 11, 2019
simple-interface Simple interface Oct 11, 2019
.gitignore Simple interface Oct 11, 2019
LICENSE Initial commit Oct 8, 2019
README.md Update README.md Oct 17, 2019
ansible.cfg Simple interface Oct 11, 2019
browse_folders.yml Simple interface Oct 11, 2019
deploy_template.yml
list_clusters.yml Simple interface Oct 11, 2019
list_datacenters.yml
list_datastores.yml Simple interface Oct 11, 2019
list_templates.yml Simple interface Oct 11, 2019
virtualtower-simple.jpg Add files via upload Oct 17, 2019
virtualtower-simple.userinput.jpg Add files via upload Oct 17, 2019
virtualtower.jpg Add files via upload Oct 10, 2019

README.md

VirtualTower

VirtualTower is a terminal interface on top of Ansible Tower (or AWX) for deploying a VMware virtual machine (based on a template). Interface is built using Python 2.7/urwid.

It allows you to wrap all the complexity of the Tower's GUI (which is not the sweetest example of user experience...) and, most important, allows you to create useful workflows, where you do need user's interaction between the steps.

alt text

It's tested to work with a CentOS and RedHat VMware templates on VMware vSphere 6+ and ant Tower (AWX) installation at the time of writing.

Set up (with AWX)

We will now set up both the host operating system from where you will run the terminal interface and the AWX example system. Because you can of course run the interface via SSH from the AWX system directly, the host operating system and the AWX system coincide in this guide.

Installation on a Debian 10, Buster operating system

Via SSH as root, install all the prerequisites, tower cli and AWX:

apt install git python-pip python-urwid ansible docker docker-compose python-docker
pip install docker-compose ansible-tower-cli # debian standard tower-cli packages won't work
systemctl enable docker; systemctl start docker

cd /tmp
git clone https://github.com/ansible/awx
cd awx/installer
sed -i "s|postgres_data_dir=/tmp/pgdocker|postgres_data_dir=/var/pgdocker|g" inventory
sed -i "s|docker_compose_dir=/tmp/awxcompose|docker_compose_dir=/var/lib/awx|g" inventory
sed -i "s|#project_data_dir=/var/lib/awx/projects|project_data_dir=/var/lib/awx/projects|g" inventory
ansible-playbook install.yml -i inventory

The Start the containers task could take a long while.

Via browser: AWX administration is performed by connecting to your AWS system via browser, http://AWX_IP.

  • Check it's alive.
  • Default login is admin / password, we won't change it here.

Via SSH as root, configure tower-cli:

# tower-cli configuration:
tower-cli config host http://localhost
tower-cli config verify_ssl False
tower-cli config username admin
tower-cli config password password

If everything is ok so far, you should see the Default organization as the output of: tower-cli organization list

Installing VirtualTower now, both interface and the Ansible playbooks components. The Ansible playbooks will be used by AWX in order to work with VMware vSphere.

cd /var/lib/awx/projects
git clone https://github.com/LumIT-Labs/virtualtower.git

Via browser:

http://AWX_IP

Create a new Project: name VMWARE, SCM Type: Manual, Playbook directory: virtualtower.

Create a new Credential: name VSPHERE, Credential type: VMware vCenter and fill in your vCenter's host, user and password.

Create a new Inventory: name VSPHERE, and associate as the host (tab HOSTS) your VMware vCenter's host.

Templates: create the following job templates:

list_datacenters

Name: list_datacenters
Inventory: VSHPERE
Playbook: list_datacenters.yml
Credential: VMware vSphere, VSHPERE
Verbosity: 0
Flag Prompt on launch for the extra_vars

You can run each job template within Tower in order to see if it correctly runs.

With the same logic, create:

list_clusters:

Extra variables:

---
__datacenter: ""

list_datastores:

Extra variables:

---
__cluster: ""

list_templates

browse_folders

deploy_template:

Extra variables:

---
__datacenter: ""
__cluster: ""
__datastore: ""
__portgroup: ""
__network_device_type: ""
__vm_name: ""
__template_name: ""
__vm_folder: ""
__vm_hostname: ""
__vm_ip: ""
__vm_netmask: ""
__vm_gateway: ""
__vm_domainname: ""
__vm_dns1: ""
__vm_dns2: ""
__vm_vcpu: ""
__vm_ram_mb: ""

Via SSH as root; If everything is set up correctly, have this test:

tower-cli job launch --job-template list_datacenters --monitor

On correct run, you can begin using the VirtualTower terminal-based interface in order to deploy a virtual machine based on your VMware template with the use of the terminal emulator only (not the AWX's GUI any more). Of course, you need a template on your VMware infrastructure ready to be used.

Usage, from any Linux host via SSH

SSH into the AWX host as root.

cd /var/lib/awx/projects/virtualtower/interface
python interface.py

An very simple/demo interface is also available.

cd /var/lib/awx/projects/virtualtower/simple-interface
python interface.py

alt text alt text

Notes for contributors

Each Ansible playbook needs to have a set_fact final for outputting the "real" data to the interface and each job template within AWX needs a 0-level log.

This is a hack due to https://github.com/ansible/tower-cli/issues/587 at the time of coding (!).

Authors

Michele Sartori and Marco Buratto at LumIT Innovation Labs, Milano, Italy.

You can’t perform that action at this time.