├── lib ├── vagrant-dsc │ ├── version.rb │ ├── powershell │ │ └── configure_dsc.ps1 │ ├── plugin.rb │ ├── locales │ │ └── en.yml │ ├── templates │ │ └── runner.ps1.erb │ ├── config.rb │ └── provisioner.rb └── vagrant-dsc.rb ├── development ├── web │ ├── website │ │ └── index.html │ ├── modules │ │ └── MyWebapp │ │ │ ├── MyWebapp.psd1 │ │ │ └── DSCResources │ │ │ └── SimpleWebsite │ │ │ ├── SimpleWebsite.psd1 │ │ │ └── SimpleWebsite.schema.psm1 │ ├── manifests │ │ ├── MyConfig.psd1 │ │ └── MyWebsite.ps1 │ └── Vagrantfile └── reboot │ ├── manifests │ ├── LCMConfig.ps1 │ └── Reboot.ps1 │ └── Vagrantfile ├── appveyor.yml ├── Gemfile ├── .gitignore ├── .vscode └── launch.json ├── Rakefile ├── .travis.yml ├── spec ├── spec_helper.rb ├── base.rb └── provisioner │ ├── config_spec.rb │ └── provisioner_spec.rb ├── LICENSE.txt ├── vagrant-dsc.gemspec └── README.md /lib/vagrant-dsc/version.rb: -------------------------------------------------------------------------------- 1 | module Vagrant 2 | module Dsc 3 | VERSION = "2.0.0" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /development/web/website/index.html: -------------------------------------------------------------------------------- 1 |

Hello from Vagrant DSC!

2 | 3 | -------------------------------------------------------------------------------- /development/web/modules/MyWebapp/MyWebapp.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mefellows/vagrant-dsc/HEAD/development/web/modules/MyWebapp/MyWebapp.psd1 -------------------------------------------------------------------------------- /development/web/modules/MyWebapp/DSCResources/SimpleWebsite/SimpleWebsite.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mefellows/vagrant-dsc/HEAD/development/web/modules/MyWebapp/DSCResources/SimpleWebsite/SimpleWebsite.psd1 -------------------------------------------------------------------------------- /development/web/manifests/MyConfig.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | AllNodes = 3 | @( 4 | @{ 5 | NodeName = "localhost"; 6 | PSDscAllowPlainTextPassword = $true; 7 | RebootIfNeeded = $True; 8 | } 9 | ) 10 | } -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | install: 2 | - set PATH=C:\Ruby22\bin;%PATH% 3 | - gem install bundler -v 1.12.5 4 | - bundle _1.12.5_ install 5 | 6 | build: off 7 | 8 | before_test: 9 | - ruby -v 10 | - gem -v 11 | - bundle -v 12 | 13 | test_script: 14 | - bundle _1.12.5_ exec rake spec 15 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in vagrant-dsc.gemspec 4 | gemspec 5 | 6 | group :development do 7 | gem "vagrant", git: "https://github.com/mitchellh/vagrant.git" 8 | end 9 | 10 | group :plugins do 11 | gem "vagrant-dsc", path: "." 12 | end -------------------------------------------------------------------------------- /development/reboot/manifests/LCMConfig.ps1: -------------------------------------------------------------------------------- 1 | [DSCLocalConfigurationManager()] 2 | configuration LCMConfig 3 | { 4 | Node localhost 5 | { 6 | Settings 7 | { 8 | RebootNodeIfNeeded = $true 9 | ActionAfterReboot = "ContinueConfiguration" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | Gemfile.lock 7 | InstalledFiles 8 | _yardoc 9 | coverage 10 | doc/ 11 | lib/bundler/man 12 | pkg 13 | rdoc 14 | spec/reports 15 | test/tmp 16 | test/version_tmp 17 | tmp 18 | *.bundle 19 | *.so 20 | *.o 21 | *.a 22 | mkmf.log 23 | .vagrant 24 | .idea 25 | bin/ -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Launch Tests", 6 | "type": "Ruby", 7 | "request": "launch", 8 | "cwd": "${workspaceRoot}", 9 | "program": "${workspaceRoot}/bin/rake", 10 | "args": [ 11 | "spec" 12 | ] 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require 'rspec/core/rake_task' 3 | task :default => [:test, :quality] 4 | # Remove 'install' task as the gem is installed to Vagrant, not to system 5 | Rake::Task[:install].clear 6 | namespace :test do 7 | RSpec::Core::RakeTask.new('unit') do |task| 8 | task.pattern = 'spec/**/*_spec.rb' 9 | end 10 | end 11 | desc "Run all tests" 12 | task :test => ['test:unit'] 13 | task :spec => :test -------------------------------------------------------------------------------- /lib/vagrant-dsc/powershell/configure_dsc.ps1: -------------------------------------------------------------------------------- 1 | # Sets up DSC 2 | echo 'Setting up DSC components' 3 | 4 | $ChocoInstallPathOld = "$env:SystemDrive\Chocolatey\bin" 5 | $ChocoInstallPath = "$env:SystemDrive\ProgramData\Chocolatey\bin" 6 | 7 | # Install chocolatey 8 | if ( !(Get-Command "choco") -and !(Test-Path $ChocoInstallPath)) { 9 | iex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1')) 10 | } 11 | 12 | choco install DotNet4.5 13 | choco install powershell4 -------------------------------------------------------------------------------- /lib/vagrant-dsc.rb: -------------------------------------------------------------------------------- 1 | require "pathname" 2 | 3 | require "vagrant-dsc/plugin" 4 | 5 | module VagrantPlugins 6 | module DSC 7 | lib_path = Pathname.new(File.expand_path("../vagrant-dsc", __FILE__)) 8 | autoload :Action, lib_path.join("action") 9 | autoload :Errors, lib_path.join("errors") 10 | 11 | # This returns the path to the source of this plugin. 12 | # 13 | # @return [Pathname] 14 | def self.source_root 15 | @source_root ||= Pathname.new(File.expand_path("../lib", __FILE__)) 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /lib/vagrant-dsc/plugin.rb: -------------------------------------------------------------------------------- 1 | require "vagrant" 2 | 3 | module VagrantPlugins 4 | module DSC 5 | class Plugin < Vagrant.plugin("2") 6 | name "DSC" 7 | description <<-DESC 8 | Provides support for provisioning your virtual machines with 9 | DSC either using a local `DSC` Configuration or a DSC server. 10 | DESC 11 | 12 | config(:dsc, :provisioner) do 13 | require_relative 'config' 14 | Config 15 | end 16 | 17 | provisioner(:dsc) do 18 | require_relative 'provisioner' 19 | Provisioner 20 | end 21 | end 22 | end 23 | end -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | before_install: 3 | - rvm @global do gem uninstall bundler --all --executables 4 | - gem uninstall bundler --all --executables 5 | - gem install bundler --version '1.12.5' 6 | rvm: 7 | - 2.2.3 8 | - ruby-head 9 | matrix: 10 | allow_failures: 11 | - rvm: ruby-head 12 | fast_finish: true 13 | env: 14 | matrix: 15 | - VAGRANT_VERSION=v1.8.5 16 | global: 17 | secure: d34dSoYsh9C9tCgAeKp3TIYdxPlrGh1j+x01Igg7Ku0rmmv0f1+NSZOcSpgbf5daXFk1i5mQrRcYjIVOclGAlCXM7IKWfDyefstmYl+2+Hjv4LGJHQNvBTz02MerfKlUef2HMAt3HJsNvwhqvIVrHetC6ZeSaFtupWqhuXWgREQ= 18 | script: bundle exec rake test:unit 19 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'simplecov' 2 | require 'coveralls' 3 | 4 | require 'vagrant-dsc/version' 5 | require 'vagrant-dsc/plugin' 6 | require 'rspec/its' 7 | require 'base' 8 | 9 | SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([ 10 | SimpleCov::Formatter::HTMLFormatter, 11 | Coveralls::SimpleCov::Formatter 12 | ]) 13 | 14 | SimpleCov.start do 15 | coverage_dir('tmp/coverage') 16 | add_filter '/spec/' 17 | end 18 | 19 | RSpec.configure do |config| 20 | config.expect_with :rspec do |c| 21 | c.syntax = :expect 22 | end 23 | config.color = true 24 | config.tty = true 25 | # config.raise_errors_for_deprecations! 26 | end -------------------------------------------------------------------------------- /development/reboot/manifests/Reboot.ps1: -------------------------------------------------------------------------------- 1 | Configuration Reboot 2 | { 3 | Import-DscResource -ModuleName 'PSDesiredStateConfiguration' 4 | 5 | Script Reboot 6 | { 7 | TestScript = { 8 | return (Test-Path HKLM:\SOFTWARE\MyMainKey\RebootKey) 9 | } 10 | SetScript = { 11 | New-Item -Path HKLM:\SOFTWARE\MyMainKey\RebootKey -Force 12 | $global:DSCMachineStatus = 1 13 | 14 | } 15 | GetScript = { return @{result = 'result'}} 16 | } 17 | 18 | Script Error 19 | { 20 | TestScript = { 21 | throw "This did not work" 22 | return $true 23 | } 24 | SetScript = { 25 | 26 | } 27 | GetScript = { return @{result = 'result'}} 28 | DependsOn = "[Script]Reboot" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /development/web/manifests/MyWebsite.ps1: -------------------------------------------------------------------------------- 1 | Configuration MyWebsite 2 | { 3 | param ($MachineName, $HostName) 4 | 5 | Import-DscResource -Module MyWebapp 6 | Import-DscResource -Module cNetworking 7 | 8 | Node $MachineName 9 | { 10 | WindowsFeature IIS 11 | { 12 | Ensure = "Present" 13 | Name = "Web-Server" 14 | } 15 | 16 | WindowsFeature IISManagerFeature 17 | { 18 | Ensure = "Present" 19 | Name = "Web-Mgmt-Tools" 20 | } 21 | 22 | cFirewallRule webFirewall 23 | { 24 | Name = "WebFirewallOpen" 25 | Direction = "Inbound" 26 | LocalPort = "80" 27 | Protocol = "TCP" 28 | Action = "Allow" 29 | Ensure = "Present" 30 | } 31 | 32 | SimpleWebsite sWebsite 33 | { 34 | WebAppPath = "c:\MyWebApp" 35 | DependsOn = '[cWebsite]DefaultWebsite' 36 | HostName = $HostName 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Matt Fellows 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /development/reboot/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | $shell_script = <