Skip to content
vWorld
Menu
  • Main Page
  • About
  • Study Guide
    • VCAP-CMA Deploy 2018
Menu

Home Lab – scripted installation – Part II

Posted on March 29, 2023March 29, 2023 by admin

following the blow to our already existing environment, I added the vcenter installation part.

What we have already achieved so far can be found here

Home Lab – scripted installation – Part I

at the very beginning, on our prereq VM, we download the tool for downloading images from VMware as well as vCenter itself, due to the fact that vCenter is a large file, it takes a while, and after finishing we will remove the iso so as not to clutter the machines

#download VCC tool and made is as execute
Invoke-SSHCommand -SessionId $session.SessionId -Command "wget $vccSDK -O /tmp/vcc" -ShowStandardOutputStream -ShowErrorOutputStream
Invoke-SSHCommand -SessionId $session.SessionId -Command 'chmod +x /tmp/vcc' -ShowStandardOutputStream -ShowErrorOutputStream
Invoke-SSHCommand -SessionId $session.SessionId -Command 'mkdir /vcsa' -ShowStandardOutputStream -ShowErrorOutputStream

#download VCSA
Invoke-SSHCommand -SessionId $session.SessionId -Command "/tmp/vcc download -p vmware_vsphere -s vc -v 7.* -f $vCenterISO --accepteula --user $myUsername --pass $myPassword --output /vcsa" -ShowStandardOutputStream -ShowErrorOutputStream -Timeout 2400

for deployment, it uses the option of deploying vcenter using CLI, and to make it non-interactive, we prepare a template in accordance with our parameters

$json = @"
{
    "__version": "2.13.0",
    "new_vcsa": {
        "esxi": {
            "hostname": "$esxiHost",
            "username": "$esxiU ",
            "password": "$esxiP",
            "deployment_network": "$vmPortGroup",
            "datastore": "$esxiDatastore"
        },
        "appliance": {
            "thin_disk_mode": true,
            "deployment_option": "tiny",
            "name": "hl-vcsa"
        },
        "network": {
            "ip_family": "ipv4",
            "mode": "static",
            "system_name": "vcsa.vworld.domain.lab",
            "ip": "$globalIPOctet.9",
            "prefix": "24",
            "gateway": "$globalIPOctet.1",
            "dns_servers": ["$globalIPOctet.2"]
        },
        "os": {
            "password": "$vcsaP",
            "ntp_servers": "$globalIPOctet.2",
            "ssh_enable": false
        },
        "sso": {
            "password": "$vcsaP",
            "domain_name": "vsphere.local"
        }
    },
    "ceip": {
        "settings": {
            "ceip_enabled": true
        }
    }
}
"@

save the prepared template on our prereq VM

$output = Invoke-SSHCommand -SessionId $session.SessionId -Command "echo '$json' > /vcsa/template.json"

and start the installation

Invoke-SSHCommand -SessionId $session.SessionId -Command "~/iso/vcsa-cli-installer/lin64/vcsa-deploy install /vcsa/template.json  --accept-eula --acknowledge-ceip --no-ssl-certificate-verification --skip-ovftool-verification -v --log-dir /tmp/log"

I need to work on this element a bit because it gives me timeout, luckily it doesn’t stop the code and we’re moving on

I based the monitoring of the process on the log that is created until successes occur, I also have to add here what if there is an ERROR other than the one that occurs normally in the installation process

# Define the file and pattern to search for
$file = "/tmp/log/workflow_*/vcsa-cli-installer.log"
$pattern = "vcsa-deploy execution successfully completed"

# Loop until the pattern is found
while ($true) {
    # Get the contents of the file
    $output = Invoke-SSHCommand -SessionId $session.SessionId -Command "tail $file" -ErrorAction SilentlyContinue

    # Search for the pattern in the file contents
    $match = $output.Output | Select-String -Pattern $pattern

    # If the pattern is found, exit the loop
    if ($match) {
        Write-Host "Pattern found!"
        break
    }

    # Wait for a few seconds before checking again
    Start-Sleep -Seconds 30
    Write-Host "Waiting for vcsa deployment..."
}

full code will be uploaded to git again when I finish it, and even though this part of the process is much shorter than the previous one, I’m already starting to work on the next elements

Share with:


Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • VCF Automation: From Zero to a Running Virtual Machine – A Step-by-Step Guide
  • Activating the Supervisor in VMware Cloud Foundation 9 with NSX VPC – A Step-by-Step Guide
  • Configuring an NSX Edge Cluster in VMware Cloud Foundation 9
  • Complete pfSense 2.7.2‑RELEASE configuration for a VMware Cloud Foundation 9 home lab
  • Automating vRO Workflow Documentation with GitHub Actions

Archives

Follow Me!

Follow Me on TwitterFollow Me on LinkedIn

GIT

  • GITHub – vWorld GITHub – vWorld 0
© 2025 vWorld | Powered by Superbs Personal Blog theme