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.


Sunday, January 7, 2018

Auto BI and AI for your department performance

So I wanted to do this from a very long time but since my skills always lag behind how fast i think or how many things.
I always saw friends who manage people or those who have to do deal with excels. What is excel anyway? tables and columns and making sense out of data against each other. I think our department is the best example for this. We have a lot of engineers who are mainly segregated into 3 different domains based on their primary area of interest and expertise.
storage [deal with 16+ EMC storage components and now redhat too]
virtualization/vmware [VMware, Dell idrax, cisco c series servers, vRealize, EHC, virtualization]
compute/network [network, compute..mainly from cisco and dell].
If you take the storage team there are few who are really good at some of those many storage products and few at others. Let us say avamar or data domain. Some are considered point of contact for certain products because they have chosen that product and taken ownership of that. Hence whenever such products come into the design that we are building and delivering they are involved.
Let us say we delivered a vblock, vxblock or vxRack with one of such storage product then their name is counted against that product. In year if we are delivering roughly 1000+ datacenters with so many products baked in then it is a tedious task to maintain excel for the management team and be accurate and happy about it.
So... you can have a VM running in your IT department. A manager or whoever is owning the data management here just has to send a mail to the VM with the following.
subject line of the mail will define the task

  1. new table <table name>
  2. all table
  3. set table <table name>
  4. get table <table name>
  5. import table <csv,html,xls,xlsx>
I guess the name itself is sufficient and self explanatory. Any mail sent to the AI VM with that subject defines the task that it has to do.
1. you want to create a new table
heading1
heading2
heading3
heading4
.
.
.
.
.
headingN
ex:
Project_ID
vmware_engineer
cisco_engineer
emc_engineer
days_taken
vmware_qa_findings
cisco_qa_findings
emc_qa_findings

Once you create the table and want to update it, then just ask for it with the subject line
get table <table name> and it will send a template that you fill it up and reply back. It will in the background parse it and update it to db.
A lot of cool things can be implemented with this methodology. Let us say you want to know the stats of
engineer1 vs engineer2 <table name>
it will reply with a pie bar chart. You can implement a lot of BI features and all a lead has to do is ask the AI via email. If you implement a bit of NLP here then it will even great. I am sure scikit can help here. I got no time for this and always wanted to do this but may be someone else with a less busy mind can pick it up. If implemented properly you can add amazon alexa and do it all by just talking to alexa.

Wednesday, January 3, 2018

Python Context Management - Managing Resources [3.6]

Create json from powershell to deploy vCenter 6.5

So I have been working on generating a json file within powershell and then import it during the deployment of vcenter VCSA 6.5.


1
vcsa-deploy.exe install --accept-eula --no-esx-ssl-verify c:\vcsa.json

Above is how you deploy the vCSA. We have an automation portal which poops out pretty awesome automation scripts. I am however planning to use the variables from the web portal and generate the json. This is how you do it. We will end up using this in our future deployment of vCSA on vxracks, vxblocks and our other CI/HCI solutions of dell emc.


 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
$dnsServers = "" # dns servers separated by comma

$jsonRequest = [ordered]@{
    "target.vcsa" = @{
        "appliance" = @{            
            "deployment.network"="VM Network"
            "deployment.option"="infrastructure"
            "name"="vCenter-Server-Appliance"
            "thin.disk.mode"=$true }

        "esx"= @{
            "hostname"= "<ESXi host name or IP address>"
            "username"= "root"
            "password"= "<Password of the ESXi host root user>"
            "datastore"= "<ESXi host datastore>" }

        "network"= @{
            "hostname"= "<Host name>"
            "dns.servers"= "[$dnsServers]"
            "gateway"= "<Gateway IP address>"
            "ip"= "<Static IP address>"
            "ip.family"= "ipv4"
            "mode"= "static"
            "prefix"= "<The value must be 0-32>"  }


        "os"= @{
            "password"= "<vCenter Server Appliance root password>"
            "ssh.enable"=$true }

        "sso"= @{
            "password"= "<vCenter Single Sign-On password>"
            "domain-name"= "vsphere.local"
            "site-name"= "<SSO site name>" }
    }
}

$jsonPath = $PSScriptRoot +"\jsonVcsa.json"
$jsonData = $jsonRequest | ConvertTo-Json | Out-File $jsonPath -Force
$jsonData

This does creates a good json file. Hopefully I get to use it to deploy the vcenter. You want to check out william lam's blog for the same here https://www.virtuallyghetto.com/2016/12/how-to-automate-the-deployment-of-an-un-configured-vcsa-6-5-stage-1-only.html