skyline-docker.ps1
function skyline-docker { [CmdletBinding()] param( [string]$CHOICE1, [string]$CHOICE2, [string]$CHOICE3, [string]$CHOICE4, [string]$CHOICE5 ) switch ( $CHOICE1 ) { docker-prep { $file = checkfile . $file if ($DOCKERPATH -eq $null) { $SAMPLEDOCKERPATH = select-string -path $file -pattern DOCKERPATH if ( $SAMPLEDOCKERPATH.Matches.Count -lt 1) { add-content $file '#DOCKERPATH = "NEED-OVA-PATH"' add-content $file '#DOCKERNAME = "NEED-OVA-NAME"' add-content $file '#DOCKERIP = "NEED-OVA-IP"' add-content $file '#DOCKERNETMASK = "NEED-OVA-NETMASK"' add-content $file '#DOCKERDNS = "NEED-OVA-DNS"' add-content $file '#DOCKERGW = "NEED-OVA-GATEWAY"' add-content $file '#DOCKERPASSWD = "NEED-OVA-PASSWORD"' write-host '' write-host "please update DOCKER entries in $file" write-host '' } } } docker-deploy { $file = checkfile . $file if ($DOCKERPATH -ne $null) { connect-viserver -server $CHOICE2 tagset $dovfConfig = Get-OvfConfiguration $DOCKERPATH $dovfConfig.NetworkMapping.Network_1.Value = $CHOICE5 $dovfConfig.vami.VMware_Skyline_Appliance.gateway.value = $DOCKERGW $dovfConfig.vami.VMware_Skyline_Appliance.DNS.value = $DOCKDERDNS $dovfConfig.vami.VMware_Skyline_Appliance.ip0.value = $DOCKERIP $dovfConfig.vami.VMware_Skyline_Appliance.netmask0.value = $DOCKERNETMASK $dovfConfig.Common.varoot_password.Value = $DOCKERPASSWD Import-VApp -source $OVAPATH -name $DOCKERNAME -OvfConfiguration $dovfConfig -VMHost $CHOICE3 -datastore $CHOICE4 -diskstorageformat thin start-vm -vm $DOCKERNAME -confirm:$false disconnect-viserver -confirm:$false } else { write-host '' write-host "ERROR - cannot execute, please update DOCKER entries in $file" write-host '' } } docker-install { if ($CHOICE2 -eq "self") { mkdir /skyline tdnf install -y docker systemctl enable docker systemctl start docker } else { $encrypted = ConvertTo-SecureString(read-host "Enter a Password" -AsSecureString | ConvertFrom-SecureString) $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($encrypted) $password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr) #$SATVER = (get-module SkylineAutomationToolkit).Version.tostring() plink -ssh root@$CHOICE2 -no-antispoof -batch -pw "$password" 'mkdir /skyline' pscp -pw "$password" "C:\Program Files\WindowsPowerShell\Modules\SkylineAutomationToolkit\$SATVER\SkylineAutomationToolkit-docker2.sh" root@"$CHOICE2":/skyline plink -ssh root@$CHOICE2 -no-antispoof -batch -pw "$password" 'chmod +x /skyline/SkylineAutomationToolkit-docker2.sh' plink -ssh root@$CHOICE2 -no-antispoof -batch -pw "$password" '/skyline/SkylineAutomationToolkit-docker2.sh -install' } } docker-salt { if ($CHOICE2 -eq "self") { write-output "...coming soon..." } else { plink -ssh root@$CHOICE2 -no-antispoof '/skyline/SkylineAutomationToolkit-docker2.sh -install-salt' } } docker-sftp { plink -ssh root@$CHOICE2 -no-antispoof '/skyline/SkylineAutomationToolkit-docker2.sh -install-sftp' } default { '' 'USAGE: skyline-docker ARG VARIABLE' ' (arg1): [docker-prep | docker-deploy | docker-install] [self|hostname]' ' (arg2): [docker-salt | docker-sftp] [self|hostname]' '' createsource } } } #skyline-docker |