VCF 4.0.1 – Cloud Builder deployment with Ansible

As we all know, lazy sysadmin is the best sysadmin so even few clicks may cause you feel exhausted. That’s why I wrote Ansible role to automate VCF Cloud Builder deployment using ‘vmware_deploy_ovf’ module. Of course some OVA property keys were needed, but they can be found under ProductSection in OVF descriptor.

This ansible role is for Cloud Builder 4.0 and 4.0.1.0. I didn’t test on 3.x yet but should be fine as well (depending on whether OVF property keys are different in v. 3.x or not).

Ok so let’s start. Quick view on my playbook ‘createCloudBuilder.yml’:

- name: Deploy Cloud Builder
  hosts: localhost

  tasks:
    - name: "Running Role: createCloudBuilder"
      include_role:
        name: createCloudBuilder
        tasks_from: deployCloudBuilder.yml

Below some of vars used in ‘createCloudBuilder’ role task ‘deployCloudBuilder.yml’ .

Let’s take a look at only few of them because rest of them should be pretty clear.

vCenterUser: "administrator@vsphere.local"
cloudBuilderVmName: "cloudBuilder401"
networkMgmt: "Management Network-98529ff0-30ab-4006-8f07-38f7cad2d167"
cloudBuilderOva: "/opt/binaries/VMware-Cloud-Builder-4.0.1.0-16428904_OVF10.ova"
cloudBuilderPassword: "SoMePa$$w0rD!"
cloudBuilderIP: "172.22.16.9"
cloudBuilderNetmask: "255.255.255.0"
cloudBuilderNTP: "172.22.16.80"

And the last part- view on task called ‘deployCloudBuilder.yml’. As you can see, when the cloud builder vm deployment task is done, vm is powered on and task will finish when vm is up and running.

- name: Deploy Cloud Builder using OVA
  vmware_deploy_ovf:
    hostname: '{{ mgmtVcsFQDN }}'
    username: '{{ vCenterUser }}'
    password: '{{ vCenterPassword }}'
    validate_certs: False
    name: '{{ cloudBuilderVmName }}'
    datastore: '{{ vCenterDatastore }}'
    disk_provisioning: 'thin'
    datacenter: '{{ vCenterDataCenter }}'
    cluster: '{{ vCenterCluster }}'
    resource_pool: '{{ vCenterResourcePool }}'
    networks:
       'Network 1': '{{ networkMgmt }}'
    ova: '{{ cloudBuilderOva }}'
    power_on: 'yes'
    fail_on_spec_warnings: 'yes'
    wait_for_ip_address: 'no'
    properties:
      guestinfo.ADMIN_USERNAME: admin
      guestinfo.ADMIN_PASSWORD: '{{ cloudBuilderPassword }}'		
      guestinfo.ROOT_PASSWORD: '{{ cloudBuilderPassword }}'
      guestinfo.hostname: cloudBuilder
      guestinfo.ip0: '{{ cloudBuilderIP }}'
      guestinfo.netmask0: '{{ cloudBuilderNetmask }}'
      guestinfo.gateway: '{{ cloudBuilderGW }}'
      guestinfo.DNS: '{{ cloudBuilderDNS }}'
      guestinfo.domain: '{{ domainName }}'
      guestinfo.searchpath: '{{ domainName }}'
      guestinfo.ntp: '{{ cloudBuilderNTP }}'
  register: deployOvaCloudBuilder

- debug:
    msg:
      - 'Cloud Builder has been deployed with below configuration:'
      - 'VM name: {{ cloudBuilderVmName }}'
      - 'Hostname: '{{ cloudBuilderVmName }}'
      - 'VM network config: IP: {{ cloudBuilderIp }}, GW:{{ cloudBuilderGW }}, Netmask:{{ cloudBuilderNetmask }}, DNS: {{ cloudBuilderDNS }}, domain: {{ domainName }}, searchpath: {{ domainName }}, NTP: {{ cloudBuilderNTP }}'
  when: deployOvaCloudBuilder is succeeded
  delegate_to: localhost

- name: Waiting for Cloud Builder to become up and running
  vmware_guest_tools_wait:
    hostname: '{{ mgmtVcsFQDN }}'
    username: '{{ vCenterUser }}'
    password: '{{ vCenterPassword }}'
    validate_certs: no
    name: '{{ cloudBuilderVmName }}'
    folder: '{{ vCenterVMFolder }}'
  delegate_to: localhost

Let’s run our playbook: ansible-playbook createCloudBuilder.yml

Cloud Builder vm deployment task is in progress and after few minutes it should be done.

And few screenshots as a proof that vm is reachable and credentials are fine šŸ™‚

That’s it. Ping me if you have any questions:)