Last active
August 29, 2015 14:10
-
-
Save dennypc/9569df590dea5b8e7a58 to your computer and use it in GitHub Desktop.
Vagrant Provisioning with Powershell DSC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param | |
( | |
[string]$nodeName = "localhost", | |
[string]$mofFolder = "C:\tmp\MOF\", | |
[ValidateNotNullOrEmpty()][string]$webProjectHome | |
) | |
Write-Host "MySite DSC Config :: nodeName=$nodeName, mofFolder=$mofFolder, webProjectHome=$webProjectHome" | |
# Clean up any existing MOF files | |
if (Test-Path($mofFolder)) | |
{ | |
Remove-Item $mofFolder -Recurse -Force | |
} | |
# Create MOF folder and set it as current location | |
New-Item -ItemType directory -Path $mofFolder | Out-Null | |
Set-Location $mofFolder | Out-Null | |
Configuration MySite | |
{ | |
param | |
( | |
[Parameter(Mandatory)] | |
[ValidateNotNullOrEmpty()] | |
[string] | |
$NodeName, | |
[string] | |
$SourcePath | |
) | |
Import-DscResource -Module xWebAdministration | |
Node $NodeName | |
{ | |
WindowsFeature IIS | |
{ | |
Ensure = "Present" | |
Name = "Web-Server" | |
} | |
File WebProject | |
{ | |
Ensure = "Present" | |
SourcePath = $SourcePath | |
DestinationPath = "C:\inetpub\wwwroot" | |
Recurse = $true | |
Type = "Directory" | |
} | |
xWebsite DefaultSite | |
{ | |
Ensure = "Present" | |
Name = "Default Web Site" | |
State = "Started" | |
PhysicalPath = "C:\inetpub\wwwroot" | |
DependsOn = @("[WindowsFeature]IIS", "[File]WebProject") | |
} | |
} | |
} | |
# DSC configuration data | |
$ConfigurationData = @{ | |
AllNodes = @( | |
@{ | |
NodeName = "*" | |
PSDscAllowPlainTextPassword = $true | |
} | |
) | |
} | |
MySite -ConfigurationData $ConfigurationData -NodeName $nodeName -SourcePath $webProjectHome |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment