Ansible Modules for vCloud Director are now available on GitHub.
VMware vCloud Director provides different ways to configure and consume services offered by a cloud provider. While the web-based user interface and the available command line interface are targeted for human usage, there is a rising demand of automating such tasks. The REST API of vCloud Director is the interface that can be used by client applications to implement such automation. Different client tools are available to access the REST API as part of larger automation solutions, like the vCloud Director Plugin for vRealize Orchestrator, or the vCloud Director Provider for Terraform. The now released modules provide an integration into Ansible.
The Ansible Modules for vCloud Director allow the automation of typical user operations as part of Ansible playbooks. These can be used for instance as part of a Continuous Integration / Continuous Delivery pipeline, for example to automatically deploy a vApp to prepare automated integration testing.
Installation
The modules are published under BSD-2 License on GitHub:
https://github.com/vmware/ansible-module-vcloud-director
You have to have the Python SDK for vCloud Director installed on your system in order to use the Ansible Modules. Here’s how to get started:
pip install —user pyvcloud git clone https://github.com/vmware/ansible-module-vcloud-director cd ansible–module–vcloud–director |
Features
The initial release of the Ansible Modules for vCloud Director covers 8 resources in vCloud Director. The table below shows the supported resources with their states and operations.
VCD Resources | States | Operations |
Catalog | Create / Update / Delete | Share / Unshare |
Catalog Item | Upload / Delete | Capture vApp |
vApp | Create / Delete | Power On / Power Off / Deploy / Undeploy |
vApp VM | Create / Update/ Delete | Power On / Power Off / Reload / Deploy / Undeploy |
Disk | Create / Update/ Delete | – |
Org | Create / Update/ Delete | Read |
Org VDC | Create / Update / Delete | – |
User | Create / Update/ Delete | – |
A full documentation of all the states and operations and their arguments can be found in the docs folder of the repository:
https://github.com/vmware/ansible-module-vcloud-director/blob/master/docs/index.md
Example
As example, the following playbook configuration will deploy a new vApp from a catalog:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
– name: create vapp vm from catalog vcd_vapp_vm: target_vm_name: “test_vapp_vm” target_vapp: “web2” source_vdc: “test_vdc” target_vdc: “test_vdc” source_catalog_name: “test_catalog” source_template_name: “centos7” source_vm_name: “CentOS7” hostname: “vcdcell” vmpassword: “rootpass” vmpassword_auto: “false” vmpassword_reset: “false” ip_allocation_mode: “DHCP” power_on: “false” all_eulas_accepted: “true” storage_profile: “Standard” network: “web2Network” cust_script: “test_script” deploy: false state: “present” |
Feedback
Feel free to contribute to this open-source project by providing feedback through the Issues section on GitHub, and of course submit pull requests if you have some code improvements!