Skip to content

Commit

Permalink
Austa 266, GitHub AttuneOps#21 Update Windows Worker Steps to use C:\…
Browse files Browse the repository at this point in the history
…attuneautomationworker (AttuneOps#22)

* AUSTA-278: Group step "Perform Deploy ESXi Drivers to a Drop Directory with Windows Worker" is now a deploy followed by a move.

* AUSTA-266, GitHub AttuneOps#21, Updated Windows Worker steps to use C:\attuneautomationworker.

---------

Co-authored-by: Default User <default@email.com>
  • Loading branch information
h4xhor and Default User authored Nov 3, 2023
1 parent 4072993 commit 8576298
Show file tree
Hide file tree
Showing 10 changed files with 177 additions and 247 deletions.
175 changes: 84 additions & 91 deletions docs/Build-Virtual-Machine-on-ESXi-with-Windows-Worker.html
Original file line number Diff line number Diff line change
Expand Up @@ -1165,13 +1165,6 @@ <h3 id="copyisotohostwithwindowsworker">
</h3>
</div>

<div class="row">
<div class="description col px-0">
<p>

</p>
</div>
</div>



Expand All @@ -1197,62 +1190,62 @@ <h3 id="copyisotohostwithwindowsworker">
<div class="col px-0">
<pre>
<code class="language-sql py-0">
# Create the new VM
$ErrorActionPreference = &quot;Stop&quot;
Import-Module VMware.VimAutomation.Core

Connect-VIServer {vmwareVcenterNode.ip} `
-User &quot;{vmwareVcenterUser.user}&quot; `
-Password &#x27;{vmwareVcenterUser.password}&#x27;

if ($? -eq $false) {
Write-Host &quot;Error: Not connected.&quot;
exit 1
}

$vmwareBootIsoDirectory = &quot;/kickstart_isos&quot;

# Create the TO dir string
$to = &quot;ds:$vmwareBootIsoDirectory&quot;
$to = $to -Replace &quot;/&quot;,&quot;\&quot;

# Get the Datastore
$datastore = Get-Datastore -Name &#x27;{vmStoragePoolName}&#x27;
$datastore

# Create the DS drive
if (Test-Path &quot;ds:&quot;) {
Remove-PSDrive ds -Force
}

if ($datastore -is [System.Array]) {
Write-Host &quot;Get-Datastore returned multiple datastores, using first item in array..&quot;
$datastore = $datastore[0]

}
New-PSDrive -Location $datastore -Name ds -PSProvider VimDatastore -Root &quot;&quot;

# Ensure the destination dir exists
Set-Location &quot;ds:&quot;

if (-Not (Test-Path &quot;$to&quot;)) {
&quot;Creating $to&quot;
New-Item -ItemType Directory -Path &quot;$to&quot;
}

# Set the local path to the ISO
Set-Location {automationWorkerWindowsBaseDirectory}

# Copy the ISO
Copy-DatastoreItem kickstart_{newVmNode.fqn}.iso $to `
-Force:$true -Confirm:$false

if ($? -eq $false) {
Write-Host &quot;Error: Copy-DatastoreItem&quot;
exit 1
}

# Remove the DS Drive
# Create the new VM
$ErrorActionPreference = &quot;Stop&quot;
Import-Module VMware.VimAutomation.Core

Connect-VIServer {vmwareVcenterNode.ip} `
-User &quot;{vmwareVcenterUser.user}&quot; `
-Password &#x27;{vmwareVcenterUser.password}&#x27;

if ($? -eq $false) {
Write-Host &quot;Error: Not connected.&quot;
exit 1
}

$vmwareBootIsoDirectory = &quot;/kickstart_isos&quot;

# Create the TO dir string
$to = &quot;ds:$vmwareBootIsoDirectory&quot;
$to = $to -Replace &quot;/&quot;,&quot;\&quot;

# Get the Datastore
$datastore = Get-Datastore -Name &#x27;{vmStoragePoolName}&#x27;
$datastore

# Create the DS drive
if (Test-Path &quot;ds:&quot;) {
Remove-PSDrive ds -Force
}

if ($datastore -is [System.Array]) {
Write-Host &quot;Get-Datastore returned multiple datastores, using first item in array..&quot;
$datastore = $datastore[0]

}
New-PSDrive -Location $datastore -Name ds -PSProvider VimDatastore -Root &quot;&quot;

# Ensure the destination dir exists
Set-Location &quot;ds:&quot;

if (-Not (Test-Path &quot;$to&quot;)) {
&quot;Creating $to&quot;
New-Item -ItemType Directory -Path &quot;$to&quot;
}

# Set the local path to the ISO
Set-Location C:\attuneautomationworker

# Copy the ISO
Copy-DatastoreItem kickstart_{newVmNode.fqn}.iso $to `
-Force:$true -Confirm:$false

if ($? -eq $false) {
Write-Host &quot;Error: Copy-DatastoreItem&quot;
exit 1
}

# Remove the DS Drive
Remove-PSDrive ds -Force
</code>
</pre>
Expand Down Expand Up @@ -1307,10 +1300,10 @@ <h3 id="copydriversisotoesxihostwithwindowsworker">
<div class="col px-0">
<pre>
<code class="language-sql py-0">
Set-Location &quot;{automationWorkerWindowsBaseDirectory}&quot;
Set-Location &quot;C:\attuneautomationworker&quot;
if ( -Not (Test-Path &quot;drivers_{newVmNode.fqn}.iso&quot; `
-PathType Leaf) ) {
Write-Host &quot;This build doesn&#x27;t have a {automationWorkerWindowsBaseDirectory}/drivers_{newVmNode.fqn}.iso.&quot;
Write-Host &quot;This build doesn&#x27;t have a C:\attuneautomationworker\drivers_{newVmNode.fqn}.iso.&quot;
} else {

$ErrorActionPreference = &quot;Stop&quot;
Expand Down Expand Up @@ -1357,7 +1350,7 @@ <h3 id="copydriversisotoesxihostwithwindowsworker">
}

# Set the local path to the ISO
Set-Location {automationWorkerWindowsBaseDirectory}
Set-Location C:\attuneautomationworker

# Copy the ISO
Copy-DatastoreItem drivers_{newVmNode.fqn}.iso $to `
Expand Down Expand Up @@ -1495,31 +1488,31 @@ <h3 id="loaddriversisointovmwithwindowsworker">
<div class="col px-0">
<pre>
<code class="language-sql py-0">
Set-Location {automationWorkerWindowsBaseDirectory}
if ( -Not (Test-Path &quot;drivers_{newVmNode.fqn}.iso&quot; `
-PathType Leaf) ) {
Write-Host &quot;This build doesn&#x27;t have a {automationWorkerWindowsBaseDirectory}/drivers_{newVmNode.fqn}.iso.&quot;
} else {

$ErrorActionPreference = &quot;Stop&quot;
Import-Module VMware.VimAutomation.Core

Connect-VIServer {vmwareVcenterNode.ip} `
-User {vmwareVcenterUser.user} `
-Password {vmwareVcenterUser.password}

if ($? -eq $false) {
Write-Host &quot;Error: Not connected.&quot;
exit 1
}

$vm = Get-VM -Name &quot;{newVmNode.fqn}&quot;
$vmwareBootIsoDirectory = &quot;/kickstart_isos&quot;

$iso = &quot;[{vmStoragePoolName}] $vmwareBootIsoDirectory/drivers_{newVmNode.fqn}.iso&quot;

New-CDDrive -VM $vm -IsoPath $iso -StartConnected

Set-Location C:\attuneautomationworker
if ( -Not (Test-Path &quot;drivers_{newVmNode.fqn}.iso&quot; `
-PathType Leaf) ) {
Write-Host &quot;This build doesn&#x27;t have a C:\attuneautomationworker\drivers_{newVmNode.fqn}.iso.&quot;
} else {

$ErrorActionPreference = &quot;Stop&quot;
Import-Module VMware.VimAutomation.Core

Connect-VIServer {vmwareVcenterNode.ip} `
-User {vmwareVcenterUser.user} `
-Password {vmwareVcenterUser.password}

if ($? -eq $false) {
Write-Host &quot;Error: Not connected.&quot;
exit 1
}

$vm = Get-VM -Name &quot;{newVmNode.fqn}&quot;
$vmwareBootIsoDirectory = &quot;/kickstart_isos&quot;

$iso = &quot;[{vmStoragePoolName}] $vmwareBootIsoDirectory/drivers_{newVmNode.fqn}.iso&quot;

New-CDDrive -VM $vm -IsoPath $iso -StartConnected

}
</code>
</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,6 @@ <h6 class="text-right">
</a>
</p>



<p class="text-muted pt-2">
<a href="#moveesxidriverstodropdirectorywithwindowsworker">
<strong>Step 2 -</strong> Move ESXi Drivers to Drop Directory with Windows Worker
</a>
</p>


</div>
</div>
Expand Down Expand Up @@ -319,7 +311,7 @@ <h3 id="deployesxidriverswithwindowsworker">
<div class="row">
<div class="description col px-0">
<p>
<p>Deploys ESXi drivers to <code>/c$/software/drivers-{newVmNode.fqn}</code>.</p>
<p>Deploys ESXi drivers to <code>/c$/attuneautomationworker/drivers-{newVmNode.fqn}</code>.</p>
</p>
</div>
</div>
Expand Down Expand Up @@ -371,65 +363,14 @@ <h3 id="deployesxidriverswithwindowsworker">
</div>
<div class="row py-1">
<code class="language-bash">
/c$/software/drivers-{newVmNode.fqn}
/c$/attuneautomationworker/drivers-{newVmNode.fqn}
</code>
</div>









<div class="row pt-5">
<h3 id="moveesxidriverstodropdirectorywithwindowsworker">
<a href="#moveesxidriverstodropdirectorywithwindowsworker">
<strong>Step 2 -</strong> Move ESXi Drivers to Drop Directory with Windows Worker
</a>
</h3>
</div>

















<div class="row">
<p>
Execute the following script:
</p>
</div>
<div class="row">
<div class="col px-0">
<pre>
<code class="language-sql py-0">
$CURRENT_PATH = &quot;C:\software\drivers-{newVmNode.fqn}&quot;
$DEST_FOLDER = &quot;{automationWorkerWindowsBaseDirectory}&quot;

Write-Host &quot;CURRENT_PATH=${CURRENT_PATH}\n DEST_FOLDER=${DEST_FOLDER}&quot;
Move-Item -Path &quot;${CURRENT_PATH}&quot; -Destination &quot;${DEST_FOLDER}&quot;
</code>
</pre>
</div>
</div>






<div class="row pt-5">
<div class="col">
Expand Down
6 changes: 3 additions & 3 deletions steps/copydriversisotoesxihostwithwindowsworker/script.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Set-Location "{automationWorkerWindowsBaseDirectory}"
Set-Location "C:\attuneautomationworker"
if ( -Not (Test-Path "drivers_{newVmNode.fqn}.iso" `
-PathType Leaf) ) {
Write-Host "This build doesn't have a {automationWorkerWindowsBaseDirectory}/drivers_{newVmNode.fqn}.iso."
Write-Host "This build doesn't have a C:\attuneautomationworker\drivers_{newVmNode.fqn}.iso."
} else {

$ErrorActionPreference = "Stop"
Expand Down Expand Up @@ -48,7 +48,7 @@ if ( -Not (Test-Path "drivers_{newVmNode.fqn}.iso" `
}

# Set the local path to the ISO
Set-Location {automationWorkerWindowsBaseDirectory}
Set-Location C:\attuneautomationworker

# Copy the ISO
Copy-DatastoreItem drivers_{newVmNode.fqn}.iso $to `
Expand Down
Loading

0 comments on commit 8576298

Please sign in to comment.