Skip to content

Instantly share code, notes, and snippets.

@boardstretcher
Created April 11, 2019 15:06
Show Gist options
  • Save boardstretcher/a9eb009adea7cfb72cfdfd37a6b12a85 to your computer and use it in GitHub Desktop.
Save boardstretcher/a9eb009adea7cfb72cfdfd37a6b12a85 to your computer and use it in GitHub Desktop.

Creating Volumes in Pure and Vmware ESXi with a rundeck job

Preperation

  • log into autoadmin as rundeck
cat ./.ssh/id_rsa.pub
  • log into the pure unit with ssh rundeck@pure
  • set the key
pureadmin setattr --publickey
<paste id_rsa.pub's content here>
  • exit
  • test connection with ssh rundeck@pure "purearray list"

Powershell and PowerCLI

  • download the repo
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
  • install powershell
yum install -y powershell
  • test installation
pwsh
  • Install Vmware PowerCLI (inside pwsh)
Set-PSRepository -Name "PSGallery" -InstallationPolicy "Trusted"
Find-Module "VMware.PowerCLI" | Install-Module -Scope "CurrentUser" -AllowClobber
Set-PowerCLIConfiguration -InvalidCertificateAction "Ignore"
Import-Module "VMware.PowerCLI"
Connect-VIServer -Server <vcenter server fqdn>
Get-Vm
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false

Creating and connecting a volume

  • Create the needed options
  • Add a key value data log filter
  • Create this Rundeck bash job
ssh @option.PureHost@ "purevol create @option.VolumeName@ --size @option.VolumeSize@"
ssh @option.PureHost@ "purehgroup connect --vol @option.VolumeName@ @option.HostGroupName@"
VolumeSerial=$(ssh @option.PureHost@ "purevol list" | grep @option.VolumeName@ | awk {'print tolower($7)'})
echo "RUNDECK:DATA:VolumeSerial=naa.624a9370$VolumeSerial"
  • Add a rundeck u/p to the rundeck vault
  • Create this powershell job
#!/bin/pwsh
Connect-VIServer -Server @option.Vcenter@ -User rundeck -Password @option.rundeck_pw@
Get-VMHostStorage -VMHost @option.Vmhost@ -RescanAllHba -RescanVmfs 
Start-Sleep -Second 10
New-Datastore -Name @option.VolumeName@ -VMHost @option.Vmhost@ -Path "@data.VolumeSerial@" -Vmfs -FileSystemVersion 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment