Initial Chef repository

This commit is contained in:
Greg Karékinian
2015-07-21 19:45:23 +02:00
parent 7e5401fc71
commit ee4079fa85
1151 changed files with 185163 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
#
# Cookbook Name:: iis
# Library:: helper
#
# Author:: Julian C. Dunn <jdunn@chef.io>
#
# Copyright 2013, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
module Opscode
module IIS
# Contains functions that are used throughout this cookbook
module Helper
if RUBY_PLATFORM =~ /mswin|mingw32|windows/
require 'chef/win32/version'
end
require 'rexml/document'
include REXML
include Windows::Helper
def self.older_than_windows2008r2?
if RUBY_PLATFORM =~ /mswin|mingw32|windows/
win_version = Chef::ReservedNames::Win32::Version.new
win_version.windows_server_2008? ||
win_version.windows_vista? ||
win_version.windows_server_2003_r2? ||
win_version.windows_home_server? ||
win_version.windows_server_2003? ||
win_version.windows_xp? ||
win_version.windows_2000?
end
end
def self.older_than_windows2012?
if RUBY_PLATFORM =~ /mswin|mingw32|windows/
win_version = Chef::ReservedNames::Win32::Version.new
win_version.windows_7? ||
win_version.windows_server_2008_r2? ||
win_version.windows_server_2008? ||
win_version.windows_vista? ||
win_version.windows_server_2003_r2? ||
win_version.windows_home_server? ||
win_version.windows_server_2003? ||
win_version.windows_xp? ||
win_version.windows_2000?
end
end
def windows_cleanpath(path)
if !defined?(Chef::Util::PathHelper.cleanpath).nil?
path = Chef::Util::PathHelper.cleanpath(path)
else
path = win_friendly_path(path)
end
# Remove any trailing slashes to prevent them from accidentally escaping any quotes.
path.chomp('/').chomp('\\')
end
def new_value?(document, xpath, value_to_check)
XPath.first(document, xpath).to_s != value_to_check.to_s
end
def new_or_empty_value?(document, xpath, value_to_check)
value_to_check.to_s != '' && new_value?(document, xpath, value_to_check)
end
def appcmd(node)
@appcmd ||= begin
"#{node['iis']['home']}\\appcmd.exe"
end
end
end
end
end

View File

@@ -0,0 +1,68 @@
if defined?(ChefSpec)
def config_iis_config(command)
ChefSpec::Matchers::ResourceMatcher.new(:iis_config, :config, command)
end
[:config, :add, :delete].each do |action|
self.class.send(:define_method, "#{action}_iis_app", proc do |app_name|
ChefSpec::Matchers::ResourceMatcher.new(:iis_app, action, app_name)
end
)
end
[:config].each do |action|
self.class.send(:define_method, "#{action}_iis_lock", proc do |section|
ChefSpec::Matchers::ResourceMatcher.new(:iis_lock, action, section)
end
)
end
[:add, :delete].each do |action|
self.class.send(:define_method, "#{action}_iis_module", proc do |module_name|
ChefSpec::Matchers::ResourceMatcher.new(:iis_module, action, module_name)
end
)
end
[:add, :config, :delete, :start, :stop, :restart, :recycle].each do |action|
self.class.send(:define_method, "#{action}_iis_pool", proc do |pool_name|
ChefSpec::Matchers::ResourceMatcher.new(:iis_pool, action, pool_name)
end
)
end
[:add, :delete, :start, :stop, :restart, :config].each do |action|
self.class.send(:define_method, "#{action}_iis_site", proc do |site_name|
ChefSpec::Matchers::ResourceMatcher.new(:iis_site, action, site_name)
end
)
end
[:config].each do |action|
self.class.send(:define_method, "#{action}_iis_unlock", proc do |section|
ChefSpec::Matchers::ResourceMatcher.new(:iis_unlock, action, section)
end
)
end
[:add, :config, :delete].each do |action|
self.class.send(:define_method, "#{action}_iis_vdir", proc do |section|
ChefSpec::Matchers::ResourceMatcher.new(:iis_vdir, action, section)
end
)
end
define_method = (Gem.loaded_specs['chefspec'].version < Gem::Version.new('4.1.0')) ?
ChefSpec::Runner.method(:define_runner_method) :
ChefSpec.method(:define_matcher)
define_method.call :iis_app
define_method.call :iis_config
define_method.call :iis_lock
define_method.call :iis_module
define_method.call :iis_pool
define_method.call :iis_site
define_method.call :iis_unlock
define_method.call :iis_vdir
end