Compare commits

..

No commits in common. "master" and "refacto_bootstrap" have entirely different histories.

6 changed files with 62 additions and 52 deletions

1
.gitignore vendored
View File

@ -1,2 +1 @@
temp/
Host/.*

View File

@ -1,6 +1,47 @@
New-Item -Path "d:\" -Name "VHD" -ItemType "directory"
New-Item -Path "d:\" -Name "VM" -ItemType "directory"
New-Item -Path "d:\VHD" -Name "Base" -ItemType "directory"
Move-Item d:/sources d:/VHD/
New-VHD -ParentPath d:\VHD\source\Base_2016_14393.161220_StdGUI_G2_upd28022017.vhdx -Path d:\VHD\Base\Base_SRV_diff.vhdx -Differencing
New-VHD -ParentPath d:\VHD\source\Master_Win10_20h2_x86_G1.vhdx -Path d:\VHD\Base\Base_CLI_diff.vhdx -Differencing
# Bootstrap script to init Hyper-v
echo "Shamefully made by Alexandre Simao. Pardon-me dear M. Stallman"
echo "GPLv3"
### Define variables
$scripts_path = Read-host "Scripts path with trailling slash?"
$vhd_path = Read-host "VHD path with trailling slash?"
$vm_path = Read-Host "VM path with trailling slash?"
$source_path = Read-host "Actual source path with trailling slash?"
$source_srv_name = Read-Host "SRV source disk name with extension?"
$source_cli_name = Read-Host "CLI source disk name with extension?"
$base_srv = Read-Host "SRV base disk name with extension?"
$base_cli = Read-Host "CLI base disk name with extension?"
$base_vhd_path = "${vhd_path} + "\Base\""
### Store them as ENV vars
$env:SCRIPTS_PATH = ${scripts_path}
$env:VHD_PATH = ${vhd_path}
$env:VM_PATH = ${vm_path}
$env:SOURCE_PATH = ${source_path}
$env:SOURCE_SRV_NAME = ${source_srv_name}
$env:SOURCE_CLI_NAME = ${source_cli_name}
$env:BASE_SRV_NAME = ${base_srv}
$env:BASE_CLI_NAME = ${base_cli}
$env:FULL_PATH = ${full_path}
$env:BASE_VHD_PATH = ${base_vhd_path}
### Let the fuckery begins!
md ${vhd_path}
md ${vhdpath}\Base
md ${vm_path}
Move-Item ${source_path} ${vhd_path}
New-VHD -ParentPath ${vhd_path}\source\${base_srv_name}.vhdx -Path ${vhd_path}\Base\${base_srv_name}.vhdx -Differencing
New-VHD -ParentPath ${vhd_path}\source\${source_cli_name}.vhdx -Path ${vhd_path}\${base_cli_name}.vhdx -Differencing
### Create VMNetworks
New-VMSwitch -name Arc-CLI -SwitchType Private
New-VMSwitch -name Arc-SRV -SwitchType Private
New-VMSwitch -name Bou-LAN -SwitchType Private
New-VMSwitch -name WAN -SwitchType Private
New-VMSwitch -name Aston -NetAdapterName Ethernet -AllowManagementOS $true

View File

@ -17,8 +17,9 @@ cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\SRV-01.vhdx
$Lettre = Mount-VHD -Path "d:\VHD\SRV-01.VHDx" -PassThru | Get-Disk | Get-Partition | Get-Volume | Sort-Object -Property Size -Descending | Select-Object -First 1
$DriveLetter = $Lettre.DriveLetter
$drive = $DriveLetter + ":"
Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination "$Drive\Windows\Panther\Unattend.xml"
Copy-Item D:\Scripts\deploy.cmd -Destination "${Driveletter}:\conf\deploy.cmd"
New-Item -Path "${Driveletter}:\conf\" -Name "Base" -ItemType "directory"
Copy-Item ${scripts_path}\Unattend\FullUnattend-srv.xml -Destination "$Drive\Windows\Panther\Unattend.xml"
Copy-Item ${scripts_path}\deploy.cmd -Destination "${Driveletter}:\conf\deploy.cmd"
mkdir "${Driveletter}:\Tools\Scripts"
Copy-item ${scripts_path}\Guests\SRV-01.ps1 "${Driveletter}:\Tools\scripts\boot.ps1"
@ -49,8 +50,9 @@ cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\SRV-03.vhdx
$Lettre = Mount-VHD -Path "d:\VHD\SRV-03.VHDx" -PassThru | Get-Disk | Get-Partition | Get-Volume | Sort-Object -Property Size -Descending | Select-Object -First 1
$DriveLetter = $Lettre.DriveLetter
$drive = $DriveLetter + ":"
Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination "$Drive\Windows\Panther\Unattend.xml"
Copy-Item D:\Scripts\deploy.cmd -Destination "${Driveletter}:\conf\deploy.cmd"
New-Item -Path "${Driveletter}:\conf\" -Name "Base" -ItemType "directory"
Copy-Item ${scripts_path}\Unattend\FullUnattend-srv.xml -Destination "$Drive\Windows\Panther\Unattend.xml"
Copy-Item ${scripts_path}\deploy.cmd -Destination "${Driveletter}:\conf\deploy.cmd"
mkdir "${Driveletter}:\Tools\Scripts"
Copy-item ${scripts_path}\Guests\SRV-03.ps1 "${Driveletter}:\Tools\scripts\boot.ps1"
@ -83,8 +85,9 @@ cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\RTR-01.vhdx
$Lettre = Mount-VHD -Path "d:\VHD\RTR-01.VHDx" -PassThru | Get-Disk | Get-Partition | Get-Volume | Sort-Object -Property Size -Descending | Select-Object -First 1
$DriveLetter = $Lettre.DriveLetter
$drive = $DriveLetter + ":"
Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination "$Drive\Windows\Panther\Unattend.xml"
Copy-Item D:\Scripts\deploy.cmd -Destination "${Driveletter}:\conf\deploy.cmd"
New-Item -Path "${Driveletter}:\conf\" -Name "Base" -ItemType "directory"
Copy-Item ${scripts_path}\Unattend\FullUnattend-srv.xml -Destination "$Drive\Windows\Panther\Unattend.xml"
Copy-Item ${scripts_path}\deploy.cmd -Destination "${Driveletter}:\conf\deploy.cmd"
mkdir "${Driveletter}:\Tools\Scripts"
Copy-item ${scripts_path}\Guests\RTR-01.ps1 "${Driveletter}:\Tools\scripts\boot.ps1"
@ -119,9 +122,9 @@ cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\RTR-02.vhdx
$Lettre = Mount-VHD -Path "d:\VHD\RTR-02.VHDx" -PassThru | Get-Disk | Get-Partition | Get-Volume | Sort-Object -Property Size -Descending | Select-Object -First 1
$DriveLetter = $Lettre.DriveLetter
$drive = $DriveLetter + ":"
Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination "$Drive\Windows\Panther\Unattend.xml"
Copy-Item D:\Scripts\deploy.cmd -Destination "${Driveletter}:\conf\deploy.cmd"
>>>>>>> parent of ca6ee46 (Feat: Add VNetwork creation)
New-Item -Path "${Driveletter}:\conf\" -Name "Base" -ItemType "directory"
Copy-Item ${scripts_path}\Unattend\FullUnattend-srv.xml -Destination "$Drive\Windows\Panther\Unattend.xml"
Copy-Item ${scripts_path}\deploy.cmd -Destination "${Driveletter}:\conf\deploy.cmd"
mkdir "${Driveletter}:\Tools\Scripts"
Copy-item ${scripts_path}\Guests\RTR-02.ps1 "${Driveletter}:\Tools\scripts\boot.ps1"
@ -156,8 +159,9 @@ cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\RTR-03.vhdx
$Lettre = Mount-VHD -Path "d:\VHD\RTR-03.VHDx" -PassThru | Get-Disk | Get-Partition | Get-Volume | Sort-Object -Property Size -Descending | Select-Object -First 1
$DriveLetter = $Lettre.DriveLetter
$drive = $DriveLetter + ":"
Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination "$Drive\Windows\Panther\Unattend.xml"
Copy-Item D:\Scripts\deploy.cmd -Destination "${Driveletter}:\conf\deploy.cmd"
New-Item -Path "${Driveletter}:\conf\" -Name "Base" -ItemType "directory"
Copy-Item ${scripts_path}\Unattend\FullUnattend-srv.xml -Destination "$Drive\Windows\Panther\Unattend.xml"
Copy-Item ${scripts_path}\deploy.cmd -Destination "${Driveletter}:\conf\deploy.cmd"
mkdir "${Driveletter}:\Tools\Scripts"
Copy-item ${scripts_path}\Guests\RTR-03.ps1 "${Driveletter}:\Tools\scripts\boot.ps1"

View File

@ -1,31 +0,0 @@
# Aston Hyper-V code snipets
## Introduction
As a student at Aston Informatic School we mainly, and until now, exclusively studies Microsoft products.
Because I like to tinker, you'll find here some tools to put an infra in place.
For the moment, no Ansible, no Chef-Infra, no Terraform; no nice feature at all. I hope to resolve that later.
To achieve this ambitious goal, i'll use mainly PowerShell scripts.
## Usage
First of all, here be dragons.
The host folder contain all scripts needed for deploying the infra.
* Bootstrap-Hyper-V.ps1 copy the necessary files (diff disks etc) on the desired folders. It will configure automaticaly all aspects to launch VMs on this atrocious Hyper-v.`v1`
* Create-ALL.ps1 create all VMs with adequate parameters to comply with the school pre-defined infrastructure. It consist on 2 server on a separate network that does AD, DNS, DHCP for one and nothing for the other at the time.`v1`
* Create-SRV.ps1 creates only the poor servers, fixed parameters for the moment.
* Create-CLI.ps1 create only the cursed client, same ase Create-SRV.ps1.
* SRV-Kill.ps1 cease the suffering of the servers.
* ALL-Kill.ps1 cease all the travesty of infrastructure.
## TODO
* Integrate SRV-02 creation and role definition.
* Variable isinde Create-SRV.ps1, Create-CLI.ps1.
* Unmount disk on Kill scripts.
## Credit roll
* Sorry to the free-software community for, in a way, increasing the radiance of the Microsoft "hegemony"
* Richard M. Stallman for his work and his wise teachings
* Sylvain Arrambourg, for his teachings and patience.
* Well, of course my familly, beloved ones and my cat.
* Go to hell Microsoft, may you eternally burn and take with you corporate greed and private code.
## Licence
GPLv3 my dudes!

View File

@ -1,2 +0,0 @@
$cul = "tamere"
d:\scripts\temp\2.ps1

View File

@ -1 +0,0 @@
echo $cul