Last active
June 28, 2023 05:21
-
-
Save PlagueHO/d9595cae1788f436b97bd4c90d50d72e to your computer and use it in GitHub Desktop.
Revisions
-
PlagueHO revised this gist
Oct 16, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -50,7 +50,7 @@ Configuration ContainerHostDsc # Perform this after setting the Environment variable # so that PowerShell and other consoles can access it. xPendingReboot Reboot { Name = "Reboot After Containers" } # Install the Docker Daemon as a service -
PlagueHO revised this gist
Oct 16, 2016 . 1 changed file with 13 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -15,23 +15,20 @@ Configuration ContainerHostDsc Node $AllNodes.NodeName { # Install containers feature WindowsFeature ContainerInstall { Ensure = "Present" Name = "Containers" } # Download Docker Engine xRemoteFile DockerEngineDownload { DestinationPath = $ProgramFiles Uri = $DockerUri MatchSource = $False } # Extract Docker Engine zip file xArchive DockerEngineExtract { Destination = $ProgramFiles Path = $DockerZipPath Ensure = 'Present' @@ -41,26 +38,23 @@ Configuration ContainerHostDsc } # Add Docker to the Path xEnvironment DockerPath { Ensure = 'Present' Name = 'Path' Value = $DockerPath Path = $True DependsOn = '[xArchive]DockerEngineExtract' } # Reboot the system to complete Containers feature setup # Perform this after setting the Environment variable # so that PowerShell and other consoles can access it. xPendingReboot Reboot { Name = "Reboot After Containers" } # Install the Docker Daemon as a service Script DockerService { SetScript = { $DockerDPath = (Join-Path -Path $Using:DockerPath -ChildPath 'dockerd.exe') & $DockerDPath @('--register-service') @@ -81,8 +75,7 @@ Configuration ContainerHostDsc # Start up the Docker Service and ensure it is set # to start up automatically. xServiceSet DockerService { Ensure = 'Present' Name = 'Docker' StartupType = 'Automatic' @@ -93,15 +86,13 @@ Configuration ContainerHostDsc } # Configure the LCM Configuration ConfigureLCM { Node $AllNodes.NodeName { LocalConfigurationManager { RebootNodeIfNeeded = $true RefreshMode = 'Push' ConfigurationMode = 'ApplyAndAutoCorrect' ActionAfterReboot = 'ContinueConfiguration' } } } -
PlagueHO created this gist
Oct 15, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,140 @@ Configuration ContainerHostDsc { # Set up general parameters used to determine paths where Docker will # be installed to and downloaded from. $ProgramFiles = $ENV:ProgramFiles $DockerPath = Join-Path -Path $ProgramFiles -ChildPath 'Docker' $DockerZipFileName = 'docker.zip' $DockerZipPath = Join-Path -Path $ProgramFiles -ChildPath $DockerZipFilename $DockerUri = 'https://download.docker.com/components/engine/windows-server/cs-1.12/docker.zip' Import-DscResource -ModuleName PSDesiredStateConfiguration Import-DscResource -ModuleName xPSDesiredStateConfiguration Import-DscResource -ModuleName xPendingReboot Node $AllNodes.NodeName { # Install containers feature WindowsFeature ContainerInstall { Ensure = "Present" Name = "Containers" } # Download Docker Engine xRemoteFile DockerEngineDownload { DestinationPath = $ProgramFiles Uri = $DockerUri MatchSource = $False } # Extract Docker Engine zip file xArchive DockerEngineExtract { Destination = $ProgramFiles Path = $DockerZipPath Ensure = 'Present' Validate = $false Force = $true DependsOn = '[xRemoteFile]DockerEngineDownload' } # Add Docker to the Path xEnvironment DockerPath { Ensure = 'Present' Name = 'Path' Value = $DockerPath Path = $True DependsOn = '[xArchive]DockerEngineExtract' } # Reboot the system to complete Containers feature setup # Perform this after setting the Environment variable # so that PowerShell and other consoles can access it. xPendingReboot Reboot { Name = "Reboot After Containers" } # Install the Docker Daemon as a service Script DockerService { SetScript = { $DockerDPath = (Join-Path -Path $Using:DockerPath -ChildPath 'dockerd.exe') & $DockerDPath @('--register-service') } GetScript = { return @{ 'Service' = (Get-Service -Name Docker).Name } } TestScript = { if (Get-Service -Name Docker -ErrorAction SilentlyContinue) { return $True } return $False } DependsOn = '[xArchive]DockerEngineExtract' } # Start up the Docker Service and ensure it is set # to start up automatically. xServiceSet DockerService { Ensure = 'Present' Name = 'Docker' StartupType = 'Automatic' State = 'Running' DependsOn = '[Script]DockerService' } } } # Configure the LCM Configuration ConfigureLCM { Node $AllNodes.NodeName { LocalConfigurationManager { RebootNodeIfNeeded = $true RefreshMode = 'Push' ConfigurationMode = 'ApplyAndAutoCorrect' ActionAfterReboot = 'ContinueConfiguration' } } } # Configuration Data $ConfigData = @{ AllNodes = @( @{ NodeName = 'localhost' } ) } # Compile the LCM Config ConfigureLCM ` -OutputPath . ` -ConfigurationData $ConfigData # Apply the LCM Config Set-DscLocalConfigurationManager ` -Path .\ConfigureLCM\ ` -ComputerName Localhost ` -Verbose # Compile the Node Config ContainerHostDsc ` -OutputPath . ` -ConfigurationData $ConfigData # Apply the DSC Configuration Start-DscConfiguration ` -Path .\ContainerHostDsc\ ` -ComputerName Localhost ` -Wait ` -Force ` -Verbose