Skip to content

Commit

Permalink
Vagrant 1.8.x upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Feb 20, 2016
1 parent 2f079c3 commit 0ca07a6
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 71 deletions.
22 changes: 13 additions & 9 deletions development/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
# vi: set ft=ruby :

$shell_script = <<SCRIPT
#(iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')))>$null 2>&1
#choco install seek-dsc
(New-Object System.Net.WebClient).DownloadFile('https://gallery.technet.microsoft.com/scriptcenter/xWebAdministration-Module-3c8bb6be/file/131367/3/xWebAdministration_1.3.2.zip','c:\\xwebadmin.zip')
choco install 7zip
& 'C:\\Program Files\\7-Zip\\7z.exe' x -y C:\\xwebadmin.zip -o'C:\\Program Files\\WindowsPowerShell\\Modules'
choco install seek-dsc -y
Install-WindowsFeature Web-Server
Get-DSCResource
SCRIPT

Expand All @@ -20,15 +17,22 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "mfellows/windows2012r2"
config.vm.box_version = "1.0.1"
config.vm.box_version = "1.0.0"


hostname = "vagrantdsc.local"
ip_address = "10.0.0.30"
config.vm.guest = :windows
config.vm.communicator = "winrm"

config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true
config.vm.network :forwarded_port, guest: 80, host: 8000, id: "web" # Port forward for IIS
config.vm.network :forwarded_port, guest: 443, host: 8443, id: "ssl" # Port forward for SSL IIS
config.vm.network :forwarded_port, guest: 22, host: 9222, id: "ssh" # Port forward for SSL IIS
config.vm.network "private_network", ip: ip_address

if Vagrant.has_plugin?("vagrant-multi-hostsupdater")
config.multihostsupdater.aliases = {ip_address => [hostname]}
end

config.vm.provider "virtualbox" do |v|
v.gui = true
Expand All @@ -38,7 +42,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision "shell", inline: $shell_script

# Upload Website
config.vm.provision "file", source: "website", destination: "c:\\my-web-app"
config.vm.provision "file", source: "website", destination: "c:\\MyWebApp"

# Run DSC
config.vm.provision "dsc" do |dsc|
Expand Down Expand Up @@ -75,7 +79,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Commandline arguments to the Configuration run
#
# Set of Parameters to pass to the DSC Configuration.
dsc.configuration_params = {"-MachineName" => "localhost"}
dsc.configuration_params = {"-MachineName" => "localhost", "-HostName" => "#{hostname}"}

# The type of synced folders to use when sharing the data
# required for the provisioner to work properly.
Expand Down
13 changes: 7 additions & 6 deletions development/manifests/MyWebsite.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Configuration MyWebsite
{
param ($MachineName)
param ($MachineName, $HostName)

Import-DscResource -Module MyWebapp
Import-DscResource -Module cNetworking
Expand All @@ -17,7 +17,7 @@ Configuration MyWebsite
{
Ensure = "Present"
Name = "Web-Mgmt-Tools"
}
}

cFirewallRule webFirewall
{
Expand All @@ -26,13 +26,14 @@ Configuration MyWebsite
LocalPort = "80"
Protocol = "TCP"
Action = "Allow"
Ensure = "Present"
Ensure = "Present"
}

SimpleWebsite sWebsite
{
WebAppPath = "c:\my-new-webapp"
WebAppPath = "c:\MyWebApp"
DependsOn = '[cWebsite]DefaultWebsite'
}
HostName = $HostName
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,60 +1,46 @@
Configuration SimpleWebsite
Configuration SimpleWebsite
{
param
(
[String]$WebAppPath = "c:\myWebApp",
[String]$WebAppName = "MyWebApp",
[String]$WebAppPath = "c:\myWebApp",
[String]$WebSiteName = "MyWebApp",
[String]$HostNameSuffix = "local",
[String]$HostName = "vagrantdsc.${HostNameSuffix}",
[String]$ApiAppPoolName = "MyWebAppPool",
[HashTable]$AuthenticationInfo = @{Anonymous = "true"; Basic = "false"; Digest = "false"; Windows = "false"}
)

# Import-DscResource -Module cWebAdministration
Import-DscResource -Module xWebAdministration
Import-DscResource -Module cWebAdministration
Import-DscResource -Module cNetworking

# Stop the default website
xWebsite DefaultSite
{
Ensure = "Present"
Name = "Default Web Site"
State = "Stopped"
PhysicalPath = "C:\inetpub\wwwroot"
DependsOn = "[File]websiteIndex"
}

# Create a Web Application Pool
xWebAppPool NewWebAppPool
{
Name = "${WebAppName}AppPool"
Ensure = "Present"
State = "Started"
}

#Create a New Website with Port
xWebSite NewWebSite
{
Name = $WebAppName
Ensure = "Present"
BindingInfo = MSFT_xWebBindingInformation
{
Port = 80
}
PhysicalPath = $WebAppPath
State = "Started"
DependsOn = @("[xWebAppPool]NewWebAppPool")
}

File websiteIndex
# Stop the default website
cWebsite DefaultSite
{
Ensure = "Present"
Type = "File"
DestinationPath = "$WebAppPath\index.html"
SourcePath = "c:\vagrant\website\index.html"
DependsOn = '[File]website'
Ensure = "Absent"
Name = "Default Web Site"
State = "Stopped"
PhysicalPath = "C:\inetpub\wwwroot"
}

File website
cWebsite UrlSvcWebsite
{
Ensure = "Present"
Type = "Directory"
DestinationPath = $WebAppPath
Ensure = "Present"
Name = $WebSiteName
BindingInfo = @(SEEK_cWebBindingInformation
{
Protocol = "http"
Port = 80
IPAddress = "*"
})
AuthenticationInfo = SEEK_cWebAuthenticationInformation { Anonymous = "true" }
HostFileInfo = @(SEEK_cHostEntryFileInformation
{
RequireHostFileEntry = $True
HostEntryName = $HostName
HostIpAddress = "10.0.0.30"
})
PhysicalPath = $WebAppPath
State = "Started"
DependsOn = @("[cWebsite]DefaultSite")
}
}
}
3 changes: 2 additions & 1 deletion development/website/index.html
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Hello from Vagrant DSC!
<h1>Hello from Vagrant DSC!</h1>
<img src="http://www.drodd.com/images10/funny-cat-gifs17.gif" />
14 changes: 7 additions & 7 deletions vagrant-dsc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_development_dependency "rake", '~> 10.3', '>= 10.3.0'
spec.add_development_dependency "bundler", "~> 1.6", '>= 1.6.0'
spec.add_development_dependency "coveralls", "~> 0.7.1", '>= 0.7.1'
spec.add_development_dependency "rspec-core", '~> 3.1', '>= 3.1.0'
spec.add_development_dependency "rspec-expectations", '~> 3.1', '>= 3.1.0'
spec.add_development_dependency "rspec-mocks", '~> 3.1', '>= 3.1.0'
spec.add_development_dependency "rspec-its", "~> 1.0.1", '>= 1.0.0'
spec.add_development_dependency "rake"#, '~> 10.3', '>= 10.3.0'
# spec.add_development_dependency "bundler", "~> 1.6", '>= 1.6.0'
spec.add_development_dependency "coveralls"#, "~> 0.7.1", '>= 0.7.1'
spec.add_development_dependency "rspec-core"#, '~> 3.1', '>= 3.1.0'
spec.add_development_dependency "rspec-expectations"#, '~> 3.1', '>= 3.1.0'
spec.add_development_dependency "rspec-mocks" #, '~> 3.1', '>= 3.1.0'
spec.add_development_dependency "rspec-its" #, "~> 1.0.1", '>= 1.0.0'
end

0 comments on commit 0ca07a6

Please sign in to comment.