diff --git a/.gitignore b/.gitignore index cee1221..6c3818b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ +.*.sw? +pkg +spec/fixtures +.rspec_system +.vagrant *.iml -Gemfile.lock -/.idea/* +.idea/ +.bundle/ diff --git a/Gemfile b/Gemfile index 2d92eea..411fcfb 100644 --- a/Gemfile +++ b/Gemfile @@ -1,14 +1,21 @@ -# A sample Gemfile source "http://rubygems.org" -gem 'puppet-lint' -gem 'test-unit' -gem 'rake' -gem 'rspec', '2.13.0' -gem 'rspec-core', '2.13.1' -gem 'rspec-expectations', '2.13.0' -gem 'rspec-mocks', '2.13.1' -gem 'puppet', '3.2.1' -gem 'rspec-puppet', '0.1.6' -gem 'puppetlabs_spec_helper', '0.4.1' +group :test do + gem "rake" + gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.4.0' + gem "puppet-lint" + gem "rspec-puppet", :git => 'https://github.com/rodjek/rspec-puppet.git' + gem "puppet-syntax" + gem "puppetlabs_spec_helper" + gem "rspec", "2.99.0" +end +group :development do + gem "travis" + gem "travis-lint" + gem "beaker" + gem "beaker-rspec" + gem "vagrant-wrapper" + gem "puppet-blacksmith" + gem "guard-rake" +end diff --git a/Rakefile b/Rakefile index 19363d5..b67d40d 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,42 @@ -require 'rubygems' require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-lint' +require 'puppet-lint/tasks/puppet-lint' +require 'puppet-syntax/tasks/puppet-syntax' + +# These two gems aren't always present, for instance +# on Travis with --without development +begin + require 'puppet_blacksmith/rake_tasks' +rescue LoadError +end + PuppetLint.configuration.send("disable_80chars") -PuppetLint.configuration.send("disable_documentation") +PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}" +PuppetLint.configuration.fail_on_warnings = true + +# Forsake support for Puppet 2.6.2 for the benefit of cleaner code. +# http://puppet-lint.com/checks/class_parameter_defaults/ +PuppetLint.configuration.send('disable_class_parameter_defaults') +# http://puppet-lint.com/checks/class_inherits_from_params_class/ +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +# http://puppet-lint.com/checks/quoted_booleans/ +PuppetLint.configuration.send('disable_quoted_booleans') + +exclude_paths = [ + "pkg/**/*", + "vendor/**/*", + "spec/**/*", +] +PuppetLint.configuration.ignore_paths = exclude_paths +PuppetSyntax.exclude_paths = exclude_paths + +desc "Run acceptance tests" +RSpec::Core::RakeTask.new(:acceptance) do |t| + t.pattern = 'spec/acceptance' +end + +desc "Run syntax, lint, and spec tests." +task :test => [ + :syntax, + :lint, + :spec, +] diff --git a/manifests/createpath.pp b/manifests/createpath.pp index 2e5f5c4..751f83e 100644 --- a/manifests/createpath.pp +++ b/manifests/createpath.pp @@ -1,3 +1,4 @@ +# define iis::createpath($site_path = undef) { include 'iis::param::powershell' diff --git a/manifests/init.pp b/manifests/init.pp index 0dd2d92..35547cc 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,3 +1,4 @@ +# class iis { iis::manage_app_pool {'www.internalapi.co.uk': enable_32_bit => true, diff --git a/manifests/manage_app_pool.pp b/manifests/manage_app_pool.pp index 3e7d9a3..c1fc89e 100644 --- a/manifests/manage_app_pool.pp +++ b/manifests/manage_app_pool.pp @@ -1,3 +1,4 @@ +# define iis::manage_app_pool($app_pool_name = $title, $enable_32_bit = false, $managed_runtime_version = 'v4.0', $managed_pipeline_mode = 'Integrated', $ensure = 'present') { validate_bool($enable_32_bit) diff --git a/manifests/manage_binding.pp b/manifests/manage_binding.pp index ffb2bc8..11412dd 100644 --- a/manifests/manage_binding.pp +++ b/manifests/manage_binding.pp @@ -1,3 +1,4 @@ +# define iis::manage_binding($site_name, $protocol, $port, $host_header = '', $ip_address = '*', $certificate_thumbprint = '', $ensure = 'present') { include 'iis::param::powershell' diff --git a/manifests/manage_site.pp b/manifests/manage_site.pp index ae227a7..f1ca29a 100644 --- a/manifests/manage_site.pp +++ b/manifests/manage_site.pp @@ -1,3 +1,4 @@ +# define iis::manage_site($site_path, $app_pool, $host_header = '', $site_name = $title, $port = '80', $ip_address = '*', $ensure = 'present', $ssl = 'false') { include 'iis::param::powershell' diff --git a/manifests/manage_site_state.pp b/manifests/manage_site_state.pp index 8b13085..a4da2a0 100644 --- a/manifests/manage_site_state.pp +++ b/manifests/manage_site_state.pp @@ -1,3 +1,4 @@ +# define iis::manage_site_state($site_name, $ensure = 'running') { include 'iis::param::powershell' diff --git a/manifests/manage_virtual_application.pp b/manifests/manage_virtual_application.pp index 1f1ee6c..da7e50e 100644 --- a/manifests/manage_virtual_application.pp +++ b/manifests/manage_virtual_application.pp @@ -1,3 +1,4 @@ +# define iis::manage_virtual_application($site_name, $site_path, $app_pool, $virtual_application_name = $title, $ensure = 'present') { include 'iis::param::powershell' diff --git a/manifests/param/powershell.pp b/manifests/param/powershell.pp index 2950643..685c19f 100644 --- a/manifests/param/powershell.pp +++ b/manifests/param/powershell.pp @@ -1,3 +1,4 @@ +# class iis::param::powershell { $executable = 'powershell.exe' $exec_policy = '-ExecutionPolicy RemoteSigned' diff --git a/spec/defines/manage_app_pool_spec.rb b/spec/defines/manage_app_pool_spec.rb index 8bc6fb3..0f8432d 100644 --- a/spec/defines/manage_app_pool_spec.rb +++ b/spec/defines/manage_app_pool_spec.rb @@ -7,7 +7,7 @@ let(:title) { 'myAppPool.example.com' } let(:params) { { :enable_32_bit => true, :managed_runtime_version => 'v4.0' } } - it { should include_class('iis::param::powershell') } + it { should contain_class('iis::param::powershell') } it { should contain_exec('Create-myAppPool.example.com').with( { :command => "#{powershell} -Command \"Import-Module WebAdministration; New-Item \\\"IIS:\\AppPools\\myAppPool.example.com\\\"\"", @@ -30,7 +30,7 @@ describe 'when managing the iis application pool without passing parameters' do let(:title) { 'myAppPool.example.com' } - it { should include_class('iis::param::powershell') } + it { should contain_class('iis::param::powershell') } it { should contain_exec('Create-myAppPool.example.com').with( { :command => "#{powershell} -Command \"Import-Module WebAdministration; New-Item \\\"IIS:\\AppPools\\myAppPool.example.com\\\"\"", diff --git a/spec/defines/manage_binding_spec.rb b/spec/defines/manage_binding_spec.rb index 863fa6b..80a84b9 100644 --- a/spec/defines/manage_binding_spec.rb +++ b/spec/defines/manage_binding_spec.rb @@ -12,7 +12,7 @@ :port => '80', } } - it { should include_class('iis::param::powershell') } + it { should contain_class('iis::param::powershell') } it { should contain_exec('CreateBinding-myWebSite-port-80').with({ 'command' => "#{powershell} -Command \"Import-Module WebAdministration; New-WebBinding -Name \\\"myWebSite\\\" -Port 80 -Protocol \\\"http\\\" -HostHeader \\\"myHost.example.com\\\" -IPAddress \\\"*\\\"\"", diff --git a/spec/defines/manage_site_spec.rb b/spec/defines/manage_site_spec.rb index e58ecfc..1eb7168 100644 --- a/spec/defines/manage_site_spec.rb +++ b/spec/defines/manage_site_spec.rb @@ -11,7 +11,7 @@ :site_path => 'C:\inetpub\wwwroot\myWebSite', } } - it { should include_class('iis::param::powershell') } + it { should contain_class('iis::param::powershell') } it { should contain_exec('CreateSite-myWebSite').with({ 'command' => "#{powershell} -Command \"Import-Module WebAdministration; $id = (Get-WebSite | foreach {$_.id} | sort -Descending | select -first 1) + 1; New-WebSite -Name \\\"myWebSite\\\" -Port 80 -IP * -HostHeader \\\"myHost.example.com\\\" -PhysicalPath \\\"C:\\inetpub\\wwwroot\\myWebSite\\\" -ApplicationPool \\\"myAppPool.example.com\\\" -Ssl:$false -ID $id \"", @@ -40,7 +40,7 @@ :ensure => 'present', }} - it { should include_class('iis::param::powershell') } + it { should contain_class('iis::param::powershell') } it { should contain_exec('CreateSite-myWebSite').with({ 'command' => "#{powershell} -Command \"Import-Module WebAdministration; $id = (Get-WebSite | foreach {$_.id} | sort -Descending | select -first 1) + 1; New-WebSite -Name \\\"myWebSite\\\" -Port 1080 -IP 127.0.0.1 -HostHeader \\\"myHost.example.com\\\" -PhysicalPath \\\"C:\\inetpub\\wwwroot\\path\\\" -ApplicationPool \\\"myAppPool.example.com\\\" -Ssl:$false -ID $id \"", diff --git a/spec/defines/manage_site_state_spec.rb b/spec/defines/manage_site_state_spec.rb index c4070f1..01bc8ca 100644 --- a/spec/defines/manage_site_state_spec.rb +++ b/spec/defines/manage_site_state_spec.rb @@ -10,7 +10,7 @@ :ensure => 'running', } } - it { should include_class('iis::param::powershell') } + it { should contain_class('iis::param::powershell') } it { should contain_exec('StartSite-DefaultWebsite').with({ 'command' => "#{powershell} -Command \"Import-Module WebAdministration; Start-Website -Name \\\"DefaultWebsite\\\"\"", @@ -25,7 +25,7 @@ :ensure => 'true', } } - it { should include_class('iis::param::powershell') } + it { should contain_class('iis::param::powershell') } it { should contain_exec('StartSite-DefaultWebsite').with({ 'command' => "#{powershell} -Command \"Import-Module WebAdministration; Start-Website -Name \\\"DefaultWebsite\\\"\"", @@ -40,7 +40,7 @@ :ensure => 'stopped', } } - it { should include_class('iis::param::powershell') } + it { should contain_class('iis::param::powershell') } it { should contain_exec('StopSite-DefaultWebsite').with({ 'command' => "#{powershell} -Command \"Import-Module WebAdministration; Stop-Website -Name \\\"DefaultWebsite\\\"\"", @@ -55,7 +55,7 @@ :ensure => 'false', } } - it { should include_class('iis::param::powershell') } + it { should contain_class('iis::param::powershell') } it { should contain_exec('StopSite-DefaultWebsite').with({ 'command' => "#{powershell} -Command \"Import-Module WebAdministration; Stop-Website -Name \\\"DefaultWebsite\\\"\"", diff --git a/spec/defines/manage_virtual_application_spec.rb b/spec/defines/manage_virtual_application_spec.rb index e8a8548..6fd3508 100644 --- a/spec/defines/manage_virtual_application_spec.rb +++ b/spec/defines/manage_virtual_application_spec.rb @@ -11,7 +11,7 @@ :app_pool => 'myAppPool.example.com', }} - it { should include_class('iis::param::powershell') } + it { should contain_class('iis::param::powershell') } it { should contain_exec('CreateVirtualApplication-myWebSite-mySite').with({ 'command' => "#{powershell} -Command \"Import-Module WebAdministration; New-WebApplication -Name mySite -Site myWebSite -PhysicalPath C:\\inetpub\\wwwroot\\myHost -ApplicationPool myAppPool.example.com\"",