{{announcement.body}}
{{announcement.title}}

Automated Deployment of vCSA 6.5/6.7 with Ansible

DZone 's Guide to

Automated Deployment of vCSA 6.5/6.7 with Ansible

Take a look at the automated deployment of vCSA by deploying it on an ESXI host using Ansible and a JSON configuration file.

· DevOps Zone ·
Free Resource

We use VMware vSphere to manage internal infrastructure. We can create and manage virtual machines very efficiently, but how can we deploy the vCenter Server automatically?

We can use our favorite tool Ansible for this. I am an Ansible expert and here I am going to show you the deployment of vCSA 6.5 on ESXI host. I am going to use ESXI 6.5 host and a JSON configuration file to pass the parameters required for the deployment. You need to download the ESXI 6.5 installer and vCSA 6.5 ISO file.  

I will use lab environment created on VMware Workstation and have manually deployed the ESXI Host. You can follow this link as well.

After the successful deployment of ESXI on one of our lab virtual machines, we will use it to deploy the vCSA 6.5.

I have used another Ubuntu 18.04 VM to use as Ansible Controller to save and run playbooks on it.  We need to have /etc/ansible/hosts file modified as:

Plain Text
 




x


 
1
[localhost]
2
127.0.0.1 ansible_connection=local ansible_user=xyz Ansible_password=abc



We need to check the connectivity as:

Plain Text
 




xxxxxxxxxx
1


1
root@ubuntu:/etc/ansible/roles# ansible -m ping localhost
2
127.0.0.1 | SUCCESS => {
3
    "changed": false, 
4
    "ping": "pong"
5
}



Then we need to create a JSON file to pass the parameters required for deployment.

Here is one sample config.json file that will be useful.

JSON
 




xxxxxxxxxx
1
70


 
1
{
2
  "__version": "2.3.0",
3
  "new.vcsa": {
4
    "esxi": {
5
      "hostname": "xxx.xxx.xxx.xxx",
6
      "username": "root",
7
      "password": "Vmware@123",
8
      "deployment.network": "VM Network",
9
      "datastore": "datastore1"
10
    },
11
    "appliance": {
12
      "thin.disk.mode": true,
13
      "deployment.option": "tiny",
14
      "name": "vcsa"
15
    },
16
    "network": {
17
      "ip.family": "ipv4",
18
      "mode": "static",
19
      "ip": "xxx.xxx.xxx.xxx",
20
      "dns.servers": [
21
        "xxx.xxx.xxx.x"
22
      ],
23
      "prefix": "24",
24
      "gateway": "xxx.xxx.xxx.xxx",
25
      "system.name": "xxx.xxx.xxx.xxx"
26
    },
27
    "os": {
28
      "password": "Vmware@123",
29
      "ssh.enable": true
30
    },
31
    "sso": {
32
      "password": "Vmware@123",
33
      "domain-name": "vsphere.local",
34
      "site-name": "Default-First-Site"
35
    }
36
  },
37
  "ceip": {
38
    "description": {
39
      "__comments": [
40
        [
41
          "++++VMware Customer Experience Improvement Program (CEIP)++++",
42
          "VMware's Customer Experience Improvement Program (CEIP) ",
43
          "provides VMware with information that enables VMware to ",
44
          "improve its products and services, to fix problems, ",
45
          "and to advise you on how best to deploy and use our ",
46
          "products. As part of CEIP, VMware collects technical ",
47
          "information about your organization's use of VMware ",
48
          "products and services on a regular basis in association ",
49
          "with your organization's VMware license key(s). This ",
50
          "information does not personally identify any individual. ",
51
          "",
52
          "Additional information regarding the data collected ",
53
          "through CEIP and the purposes for which it is used by ",
54
          "VMware is set forth in the Trust & Assurance Center at ",
55
          "http://www.vmware.com/trustvmware/ceip.html . If you ",
56
          "prefer not to participate in VMware's CEIP for this ",
57
          "product, you should disable CEIP by setting ",
58
          "'ceip.enabled': false. You may join or leave VMware's ",
59
          "CEIP for this product at any time. Please confirm your ",
60
          "acknowledgement by passing in the parameter ",
61
          "--acknowledge-ceip in the command line.",
62
          "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
63
        ]
64
      ]
65
    },
66
    "settings": {
67
      "ceip.enabled": true
68
    }
69
  }
70
}


  

You need to create a Ansible playbook vcsa-deploy.yml for this deployment. You need to use the URL of the vCSA ISO file to be used.

YAML
 




xxxxxxxxxx
1
52


 
1
---
2
- hosts: localhost
3
  vars:
4
    name_iso: VMware-VCSA-all-6.5.0-8307201.iso
5
    vcsa_iso_url: #needs to provide the url path
6
 
          
7
  tasks:
8
 
          
9
     - name: Creating a Directory to download the iso file
10
       become: yes
11
       file:
12
         path: /vcsa-iso/
13
         state: directory
14
         mode: 0777
15
 
          
16
    - name: Download the vCSA 6.5 U2 iso to /vcsa-iso
17
      get_url:
18
        url: {{vcsa_iso_url}} 
19
        dest: /vcsa-iso/{{name_iso}}
20
        mode: 755
21
 
22
     - name: Creating a Directory to mount the iso file
23
       become: yes
24
       file:
25
         path: /mnt/iso
26
         state: directory
27
         mode: 0777
28
 
          
29
    - name: Mount vCSA6.5 U2 iso to /mnt/iso directory
30
      mount:
31
        path: /mnt/iso
32
        src: /vcsa-iso/{{name_iso}}
33
        fstype: iso9660
34
        opts: ro,noauto
35
        state: present
36
 
          
37
     - name: Creating a Working Directory
38
       become: yes
39
       file:
40
         path: /vcsa
41
         state: directory
42
         mode: 0777
43
 
          
44
     - name: Copying contents to working Directory
45
       template:
46
         src: /mnt/iso/*
47
         dest: /vcsa
48
 
          
49
    - name: deployment of vcsa
50
      shell: ./vcsa-deploy install --no-esx-ssl-verify --accept-eula --acknowledge-ceip /vcsa/vcsa-cli-installer/lin64/config.json
51
      args:
52
        chdir: /VCSA-new/vcsa-cli-installer/lin64/



You need to have the ESXI host details and the deployment type and other required parameters as mentioned in the above config.json configuration file and copy it to the vcsa-cli-installer/lin64/ folder. and then run the playbook as:

Plain Text
 




xxxxxxxxxx
1


 
1
root@ubuntu:/etc/ansible/playbooks# ansible-playbook vcsa-deploy.yml 
2
 
          


and after a successful execution you should see this.

Successful execution

vCSA Deployed with Embedded Replication controller


And can login to the vCSA with the above-mentioned URL and the provided username and password. https://{{vc-hostname}}

vCSA login


Topics:
ansible playbook ,deployment ,devops ,json ,tutorial ,vcsa ,vsphere ,web design and web development

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}