profile for Gajendra D Ambi on Stack Exchange, a network of free, community-driven Q&A sites

Monday, January 8, 2018

Automating the deployment of VMware vCSA 6.5 with json

So in my earlier post  I was exploring the deployment of vcsa and tried to create a json file for importing.
This post is about deploy the primary platform service controller directly to an esxi.

1
.$deployer\vcsa-deploy.exe install "psc1.json" --accept-eula --no-esx-ssl-verify 
The above is the command to deploy the vcsa. We first however need the vcsa and the updated json file which contains all of these. You have however various templates available inside the vcsa iso. This one is for platform services controller 1 deployed directly against esxi.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function DeployPsc1 {
# variables to deploy psc1
$esxihostname = "10.11.27.143"
$esxiPass = "VMware1!"
$datastore = "vsanDs"
$portgroup = "VM Network"
$deployment_option = "infrastructure"
$psc1_name = "psc1"
$psc1_fqdn = "psc1.dell.com"
$psc1_ip = "10.1.1.1"
$dnsServers = "2.3.4.4" # dns servers separated by comma
$gateway = "10.1.1.1"
$subnet = "255.255.255.0"
$maskBits = 0
foreach($octet in $psc1_ip.Split('.'))
  {
    while(0 -ne $octet)
    {
      $octet = ($octet -shl 1) -band [byte]::MaxValue
      $maskBits++
    }
  }
 
$psc1Pass = "VMware1!"
$ssoDomain = "vsphere.local"
$ssoPass = "VMware1!"
$siteName = "dc"

# The automation script
$iso_path = (get-PSDrive | where Description -Match CDROM).Root
$ovaPath = "$iso_path"+"vcsa"
$name = (dir $ovaPath | where name -Match ".ova").Name
$vcsa_ovapath = "$iso_path"+"$name"
$jsonName = "PSC_first_instance_on_ESXi.json"
$jsonSource = "$iso_path"+"vcsa-cli-installer\templates\install\$jsonName"
Copy-Item $jsonSource -Force | Out-Null
$json = get-childitem | where name -Match $jsonName

Write-Host "preparing the deployment json template"
$a = Get-Content $json -raw | ConvertFrom-Json
$a.'new.vcsa'.esxi.hostname = $esxihostname
$a.'new.vcsa'.esxi.username = 'root'
$a.'new.vcsa'.esxi.password = $esxiPass
$a.'new.vcsa'.esxi.datastore = $datastore
$a.'new.vcsa'.esxi.'deployment.network' = $portgroup
$a.'new.vcsa'.appliance.'deployment.option' = $deployment_option
$a.'new.vcsa'.appliance.name = ""
$a.'new.vcsa'.appliance.'thin.disk.mode' = $true
$a.'new.vcsa'.appliance.name = $psc1_name
$a.'new.vcsa'.network.'ip.family' = "ipv4"
$a.'new.vcsa'.network.ip = $psc1_ip
$a.'new.vcsa'.network.'dns.servers' = $dnsServers
$a.'new.vcsa'.network.gateway = $gateway
$a.'new.vcsa'.network.mode = "static"
$a.'new.vcsa'.network.'system.name' = "$psc1_fqdn"
$a.'new.vcsa'.network.prefix = "$maskBits"
$a.'new.vcsa'.os.'ssh.enable' = $true
$a.'new.vcsa'.os.password = $psc1Pass
$a.'new.vcsa'.sso.'domain-name' = $ssoDomain
$a.'new.vcsa'.sso.password = $ssoPass
$a.'new.vcsa'.sso.'site-name' = $siteName
$a.ceip.settings.'ceip.enabled' = $false
$a | ConvertTo-Json -Depth 3 | Out-File psc1.json -Encoding utf8 -Force

Write-Host "deploying psc1"
$deployer = "$iso_path"+"vcsa-cli-installer\win32"
.$deployer\vcsa-deploy.exe install "psc1.json" --accept-eula --no-esx-ssl-verify 
} DeployPsc1

Till line 13 you have all the variables that you need to populate.
14-22 calculate the subnet bits.
30 it finds the mounded iso on the machine where the script is being run.
31 vcsa is the folder inside the iso, so we are adding that to our path.
32 searching the vcsa folder for the .ova file and find the complete path to use it later.
33 complete path to the vcsa ova file
34 name of the json template which we want to use from the iso file
35 complete path to the json template that we want to use
36-37 copying the json template to our local directory for the sake of simplicity and later we will import this json template, update it with our values and deploy the psc.
40 you import the json into powershell so that you can update it.
41- 62 you update the various values of the json. Don't worry. When you type $a. and tab it automatically shows the next options for you.
63 we export the new updated json as psc1.json.
66 find out the path of the .exe from the mounted iso which deploys vcsa.


No comments:

Post a Comment