├── .gitignore ├── cookbooks ├── app_ad │ ├── recipes │ │ ├── setup_controller.rb │ │ ├── add_user.rb │ │ ├── join.rb │ │ └── remote_add_user.rb │ ├── resources │ │ ├── dns_server.rb │ │ └── active_directory.rb │ ├── powershell_providers │ │ ├── dns_server │ │ │ └── set.ps1 │ │ └── active_directory │ │ │ ├── join.ps1 │ │ │ └── add_user.ps1 │ ├── metadata.rb │ └── metadata.json ├── blog_engine │ ├── files │ │ └── default │ │ │ ├── bin │ │ │ ├── 7z.dll │ │ │ └── 7z.exe │ │ │ ├── app │ │ │ └── BlogEngine.zip │ │ │ ├── monitors │ │ │ ├── blog_engine_iis_connections.rb │ │ │ ├── blog_engine_iis_bytes.rb │ │ │ └── blog_engine_iis_requests.rb │ │ │ └── simple_app_deploy.ps1 │ ├── README.rdoc │ ├── powershell_providers │ │ └── database │ │ │ ├── _term.ps1 │ │ │ ├── _init.ps1 │ │ │ ├── run_script.ps1 │ │ │ ├── drop.ps1 │ │ │ ├── run_command.ps1 │ │ │ ├── _load_current_resource.ps1 │ │ │ ├── backup.ps1 │ │ │ └── restore.ps1 │ ├── recipes │ │ ├── drop_database.rb │ │ ├── add_monitors.rb │ │ ├── restore_database.rb │ │ ├── backup_database.rb │ │ └── default.rb │ ├── resources │ │ └── database.rb │ └── metadata.rb ├── utilities │ ├── files │ │ ├── install_7zip │ │ │ └── 7z465.exe │ │ ├── ruby │ │ │ └── ruby-1.8.6-p383-i386-mingw32-rc1.7z │ │ └── install_firefox │ │ │ └── firefox_quiet_install.ini │ ├── recipes │ │ ├── default.rb │ │ ├── change_admin_password.rb │ │ ├── system_reboot.rb │ │ ├── system_shutdown.rb │ │ ├── install_ruby.rb │ │ ├── install_firefox.rb │ │ ├── delete_scheduled_task.rb │ │ ├── install_7zip.rb │ │ └── create_scheduled_task.rb │ ├── README.rdoc │ ├── powershell_providers │ │ └── scheduled_tasks │ │ │ ├── _init.ps1 │ │ │ ├── _load_current_resource.ps1 │ │ │ ├── delete.ps1 │ │ │ └── create.ps1 │ ├── resources │ │ └── scheduled_tasks.rb │ ├── metadata.rb │ └── metadata.json ├── aws │ ├── files │ │ └── install_dotnet_sdk │ │ │ └── AWSSDKForNET_1.0.11.msi │ ├── recipes │ │ ├── upload.rb │ │ ├── register_with_elb.rb │ │ ├── deregister_from_elb.rb │ │ ├── download.rb │ │ └── default.rb │ ├── README.rdoc │ ├── powershell_providers │ │ ├── elb │ │ │ ├── _load_current_resource.ps1 │ │ │ ├── _init.ps1 │ │ │ ├── deregister.ps1 │ │ │ └── register.ps1 │ │ └── s3 │ │ │ ├── _load_current_resource.ps1 │ │ │ ├── _init.ps1 │ │ │ ├── get.ps1 │ │ │ └── put.ps1 │ ├── resources │ │ ├── elb.rb │ │ └── s3.rb │ ├── metadata.rb │ └── metadata.json ├── app_iis │ ├── README.rdoc │ ├── recipes │ │ ├── start_default_website.rb │ │ ├── default.rb │ │ ├── update_code_svn.rb │ │ └── update_code_s3.rb │ └── metadata.rb ├── sys_monitoring │ ├── README.rdoc │ ├── metadata.rb │ ├── metadata.json │ ├── files │ │ └── default │ │ │ ├── monitors │ │ │ ├── memory_usage.rb │ │ │ ├── disk_usage.rb │ │ │ └── cpu_load.rb │ │ │ └── collectd │ │ │ └── collectd.rb │ └── recipes │ │ └── default.rb ├── db_sqlserver │ ├── README.rdoc │ ├── powershell_providers │ │ └── database │ │ │ ├── _term.ps1 │ │ │ ├── _init.ps1 │ │ │ ├── run_script.ps1 │ │ │ ├── drop.ps1 │ │ │ ├── run_command.ps1 │ │ │ ├── _load_current_resource.ps1 │ │ │ ├── restore.ps1 │ │ │ └── backup.ps1 │ ├── recipes │ │ ├── drop.rb │ │ ├── enable_sql_service.rb │ │ ├── restore.rb │ │ ├── backup.rb │ │ ├── default.rb │ │ ├── backup_to_s3.rb │ │ └── import_dump_from_s3.rb │ ├── resources │ │ └── database.rb │ └── metadata.rb └── code_checkout │ ├── powershell_providers │ ├── package │ │ ├── _init.ps1 │ │ ├── _load_current_resource.ps1 │ │ └── unpack.ps1 │ └── svn │ │ ├── _init.ps1 │ │ ├── _load_current_resource.ps1 │ │ └── checkout.ps1 │ └── resources │ ├── package.rb │ └── svn.rb ├── README ├── LICENSE ├── Rakefile └── config └── rake.rb /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .rake_test_cache 3 | .idea 4 | nbproject 5 | -------------------------------------------------------------------------------- /cookbooks/app_ad/recipes/setup_controller.rb: -------------------------------------------------------------------------------- 1 | # app_ad::setup_controller 2 | right_link_tag 'provides:ad_role=controller' 3 | -------------------------------------------------------------------------------- /cookbooks/blog_engine/files/default/bin/7z.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/cookbooks_public_windows/master/cookbooks/blog_engine/files/default/bin/7z.dll -------------------------------------------------------------------------------- /cookbooks/blog_engine/files/default/bin/7z.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/cookbooks_public_windows/master/cookbooks/blog_engine/files/default/bin/7z.exe -------------------------------------------------------------------------------- /cookbooks/utilities/files/install_7zip/7z465.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/cookbooks_public_windows/master/cookbooks/utilities/files/install_7zip/7z465.exe -------------------------------------------------------------------------------- /cookbooks/blog_engine/files/default/app/BlogEngine.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/cookbooks_public_windows/master/cookbooks/blog_engine/files/default/app/BlogEngine.zip -------------------------------------------------------------------------------- /cookbooks/utilities/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: utilities 3 | # Recipe:: default 4 | # 5 | # Copyright 2010, RightScale, Inc. 6 | # 7 | # All rights reserved 8 | # 9 | -------------------------------------------------------------------------------- /cookbooks/app_ad/resources/dns_server.rb: -------------------------------------------------------------------------------- 1 | actions :set 2 | 3 | attribute :domain, :kind_of => [ String ], :regex => /^[a-z0-9][a-z0-9\-\.]*$/i, :required => true, :name_attribute => true 4 | 5 | -------------------------------------------------------------------------------- /cookbooks/aws/files/install_dotnet_sdk/AWSSDKForNET_1.0.11.msi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/cookbooks_public_windows/master/cookbooks/aws/files/install_dotnet_sdk/AWSSDKForNET_1.0.11.msi -------------------------------------------------------------------------------- /cookbooks/utilities/files/ruby/ruby-1.8.6-p383-i386-mingw32-rc1.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/cookbooks_public_windows/master/cookbooks/utilities/files/ruby/ruby-1.8.6-p383-i386-mingw32-rc1.7z -------------------------------------------------------------------------------- /cookbooks/utilities/README.rdoc: -------------------------------------------------------------------------------- 1 | = DESCRIPTION: 2 | 3 | Windows utilities recipes. 4 | 5 | = ATTRIBUTES: 6 | 7 | See metadata.rb 8 | 9 | = USAGE: 10 | 11 | Designed to be run within a RightScale ServerTemplate 12 | -------------------------------------------------------------------------------- /cookbooks/app_iis/README.rdoc: -------------------------------------------------------------------------------- 1 | = DESCRIPTION: 2 | 3 | Windows IIS recipes 4 | 5 | = REQUIREMENTS: 6 | 7 | 8 | = ATTRIBUTES: 9 | 10 | See metadata.rb 11 | 12 | = USAGE: 13 | 14 | Designed to be run within a RightScale ServerTemplate 15 | -------------------------------------------------------------------------------- /cookbooks/sys_monitoring/README.rdoc: -------------------------------------------------------------------------------- 1 | = DESCRIPTION: 2 | 3 | Enable monitoring 4 | 5 | = USAGE: 6 | 7 | Add to ServerTemplate to enable monitoring on instances using it. 8 | 9 | Boot Scripts 10 | * default - Install monitoring plugin 11 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/README.rdoc: -------------------------------------------------------------------------------- 1 | = DESCRIPTION: 2 | 3 | SQL Server Recipes and Providers 4 | 5 | = REQUIREMENTS: 6 | 7 | Use on a RightImage which includes SQL Server (2005 or 2008, Express or Standard). 8 | 9 | = USAGE: 10 | 11 | Designed to be run within a RightScale ServerTemplate. 12 | 13 | -------------------------------------------------------------------------------- /cookbooks/app_ad/recipes/add_user.rb: -------------------------------------------------------------------------------- 1 | # app_add::add_user 2 | domain = node[:ad][:domain] 3 | username = node[:ad][:user_username] 4 | password = node[:ad][:user_password] 5 | 6 | log "domain: #{domain}" 7 | log "username: #{username}" 8 | 9 | app_ad_active_directory domain do 10 | user_username username 11 | user_password password 12 | action :add_user 13 | end 14 | -------------------------------------------------------------------------------- /cookbooks/aws/recipes/upload.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: aws 2 | # Recipe:: upload 3 | # 4 | # Copyright 2010, RightScale, Inc. 5 | # 6 | # All rights reserved 7 | 8 | # upload file to s3 9 | aws_s3 "upload to s3" do 10 | access_key_id @node[:aws][:access_key_id] 11 | secret_access_key @node[:aws][:secret_access_key] 12 | s3_bucket @node[:s3][:bucket] 13 | file_path @node[:aws][:file_path] 14 | action :put 15 | end 16 | -------------------------------------------------------------------------------- /cookbooks/app_ad/resources/active_directory.rb: -------------------------------------------------------------------------------- 1 | actions [:add_user, :join] 2 | 3 | attribute :domain, :kind_of => [ String ], :regex => /^[a-z0-9][a-z0-9\-\.]*$/i, :required => true, :name_attribute => true 4 | attribute :user_username, :kind_of => [ String ] 5 | attribute :user_password, :kind_of => [ String ] 6 | attribute :admin_username, :kind_of => [ String ] 7 | attribute :admin_password, :kind_of => [ String ] 8 | 9 | 10 | -------------------------------------------------------------------------------- /cookbooks/aws/recipes/register_with_elb.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: aws 2 | # Recipe:: register_with_elb 3 | # 4 | # Copyright 2010, RightScale, Inc. 5 | # 6 | # All rights reserved 7 | # 8 | 9 | # register instance with elb 10 | aws_elb "register instance provider call" do 11 | access_key_id @node[:aws][:access_key_id] 12 | secret_access_key @node[:aws][:secret_access_key] 13 | elb_name @node[:aws][:elb_name] 14 | action :register 15 | end -------------------------------------------------------------------------------- /cookbooks/sys_monitoring/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "RightScale, Inc." 2 | maintainer_email "support@rightscale.com" 3 | license IO.read(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'LICENSE'))) 4 | description "Send collectd data to RightScale" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 6 | version "0.3.13" 7 | 8 | recipe "sys_monitoring::default", "Install monitoring plugin" 9 | -------------------------------------------------------------------------------- /cookbooks/aws/recipes/deregister_from_elb.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: aws 2 | # Recipe:: deregister_from_elb 3 | # 4 | # Copyright 2010, RightScale, Inc. 5 | # 6 | # All rights reserved 7 | # 8 | 9 | # deregister instance from elb 10 | aws_elb "deregister instance provider call" do 11 | access_key_id @node[:aws][:access_key_id] 12 | secret_access_key @node[:aws][:secret_access_key] 13 | elb_name @node[:aws][:elb_name] 14 | action :deregister 15 | end -------------------------------------------------------------------------------- /cookbooks/app_ad/powershell_providers/dns_server/set.ps1: -------------------------------------------------------------------------------- 1 | $Domain = Get-ChefNode ad, domain 2 | $Ip = [System.Net.Dns]::GetHostByName($Domain).AddressList[0].IPAddressToString 3 | Write-Host "Now using $Ip for DNS resolution" 4 | 5 | $NICs = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $env:ComputerName -Filter "IPEnabled=TRUE" 6 | foreach($NIC in $NICs) { 7 | $NIC.SetDNSServerSearchOrder($Ip) 8 | $NIC.SetDynamicDNSRegistration("TRUE") 9 | } 10 | 11 | -------------------------------------------------------------------------------- /cookbooks/app_ad/powershell_providers/active_directory/join.ps1: -------------------------------------------------------------------------------- 1 | # ActiveDirectoryProvider#join 2 | $Domain = Get-ChefNode ad, domain 3 | $UserName = Get-ChefNode ad, admin_username 4 | $Password = Get-ChefNode ad, admin_password 5 | $Password = ConvertTo-SecureString $Password -AsPlainText -Force 6 | 7 | $UserName = "$Domain\$UserName" 8 | $Cred = New-Object System.Management.Automation.PSCredential $UserName, $Password 9 | Add-Computer -credential $Cred -DomainName $Domain 10 | 11 | -------------------------------------------------------------------------------- /cookbooks/app_ad/recipes/join.rb: -------------------------------------------------------------------------------- 1 | # app_ad::join 2 | 3 | # 1. Retrieve inputs 4 | domain = node[:ad][:domain] 5 | admin_username = node[:ad][:admin_username] 6 | admin_password = node[:ad][:admin_password] 7 | 8 | log "domain: #{domain}" 9 | log "admin username: #{admin_username}" 10 | 11 | # 2. Set DNS Server to be DC 12 | app_ad_dns_server domain do 13 | action :set 14 | end 15 | 16 | ## 3. Join domain 17 | app_ad_active_directory domain do 18 | admin_username admin_username 19 | admin_password admin_password 20 | action :join 21 | end 22 | -------------------------------------------------------------------------------- /cookbooks/utilities/recipes/change_admin_password.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: utilities 2 | # Recipe:: change_admin_password 3 | # 4 | # Copyright 2010, RightScale, Inc. 5 | # 6 | # All rights reserved 7 | 8 | # change admin password 9 | powershell "Changes the administrator password" do 10 | parameters({'ADMIN_PASSWORD' => @node[:utilities][:admin_password]}) 11 | 12 | # Create the powershell script 13 | powershell_script = <<'POWERSHELL_SCRIPT' 14 | net user administrator "$env:ADMIN_PASSWORD" 15 | POWERSHELL_SCRIPT 16 | 17 | source(powershell_script) 18 | end 19 | -------------------------------------------------------------------------------- /cookbooks/app_ad/recipes/remote_add_user.rb: -------------------------------------------------------------------------------- 1 | # app_ad::remote_add_user 2 | 3 | # 1. Retrieve inputs 4 | domain = node[:ad][:domain] 5 | username = node[:ad][:user_username] 6 | password = node[:ad][:user_password] 7 | 8 | log "domain: #{domain}" 9 | log "username: #{username}" 10 | 11 | # 2. Send remote recipe to add user 12 | remote_recipe 'add user' do 13 | recipe 'app_ad::add_user' 14 | attributes({:ad => { :domain => domain, 15 | :user_username => username, 16 | :user_password => password }}) 17 | recipients_tags 'provides:ad_role=controller' 18 | end 19 | 20 | -------------------------------------------------------------------------------- /cookbooks/aws/README.rdoc: -------------------------------------------------------------------------------- 1 | = DESCRIPTION: 2 | 3 | Aws recipes and providers. 4 | 5 | = ATTRIBUTES: 6 | 7 | See metadata.rb 8 | 9 | = USAGE: 10 | 11 | Designed to be run within a RightScale ServerTemplate 12 | 13 | Boot Scripts 14 | * install_dotnet_sdk - Install Amazon Web Services SDK for .NET 15 | * register_with_elb - Register the instance with an Elastic Load Balancer created in the same ec2 region. Requires recipe: 'aws::install_dotnet_sdk' 16 | 17 | Decommission Scripts 18 | * deregister_from_elb - Deregister the instance with an Elastic Load Balancer created in the same ec2 region. Requires recipe: 'aws::install_dotnet_sdk' 19 | -------------------------------------------------------------------------------- /cookbooks/utilities/recipes/system_reboot.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: utilities 2 | # Recipe:: system_reboot 3 | # 4 | # Copyright 2010, RightScale, Inc. 5 | # 6 | # All rights reserved 7 | 8 | powershell "Reboots the system" do 9 | 10 | # Create the powershell script 11 | powershell_script = <<'POWERSHELL_SCRIPT' 12 | $computer = get-content env:computername 13 | $system = Get-WmiObject Win32_OperatingSystem -ComputerName $computer 14 | $system.psbase.Scope.Options.EnablePrivileges = $true 15 | #redirecting the output to $null to avoid script failure 16 | $system.Reboot() > $null 17 | Write-Output "Reboot signal sent!" 18 | POWERSHELL_SCRIPT 19 | 20 | source(powershell_script) 21 | end 22 | -------------------------------------------------------------------------------- /cookbooks/utilities/recipes/system_shutdown.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: utilities 2 | # Recipe:: system_shutdown 3 | # 4 | # Copyright 2010, RightScale, Inc. 5 | # 6 | # All rights reserved 7 | 8 | powershell "Shuts down the system" do 9 | 10 | # Create the powershell script 11 | powershell_script = <<'POWERSHELL_SCRIPT' 12 | $computer = get-content env:computername 13 | $system = Get-WmiObject Win32_OperatingSystem -ComputerName $computer 14 | $system.psbase.Scope.Options.EnablePrivileges = $true 15 | #redirecting the output to $null to avoid script failure 16 | $system.shutdown() > $null 17 | Write-Output "Shutdown signal sent!" 18 | POWERSHELL_SCRIPT 19 | 20 | source(powershell_script) 21 | end 22 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | = RightScale Public Cookbooks for Windows 2 | 3 | = DESCRIPTION 4 | 5 | This repository includes cookbooks used by RightScale's Windows Chef ServerTemplates. 6 | 7 | == Synopsis 8 | 9 | RightScale now supports server configuration using the open source integration 10 | framework called Chef[1]. 11 | 12 | Please contact support@rightscale.com to report any issues. 13 | 14 | == Supported Configuration 15 | 16 | These cookbooks have been tested on the EC2 cloud using the RightScale 17 | platform ServerTemplates. 18 | 19 | == Work in Progress 20 | 21 | RightScale cookbooks are a work in progress, expect more documentation and examples in the near 22 | future. 23 | 24 | = ADDITIONAL RESOURCES 25 | 26 | * [1] Chef is http://wiki.opscode.com/display/chef/Home 27 | 28 | -------------------------------------------------------------------------------- /cookbooks/blog_engine/README.rdoc: -------------------------------------------------------------------------------- 1 | = DESCRIPTION: 2 | 3 | Loads the BlogEngine data into the local SQL Server database and installs the BlogEngine application as the 4 | default web application for IIS. 5 | 6 | = REQUIREMENTS: 7 | 8 | * utilities, and sys_monitoring cookbooks 9 | 10 | = USAGE: 11 | 12 | Designed to be run within a RightScale ServerTemplate. 13 | 14 | Boot Scripts 15 | * default - Loads the database and installs the BlogEngine application as the default IIS site 16 | * add_monitories - Load custom monitors 17 | 18 | Operational Scripts 19 | * backup_database - Backs up the BlogEngine database to a local machine directory. 20 | * restore_database - Restores the BlogEngine database from a local machine directory. 21 | * drop_database - Drops the BlogEngine database. 22 | -------------------------------------------------------------------------------- /cookbooks/utilities/recipes/install_ruby.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: utilities 2 | # Recipe:: install_ruby 3 | # 4 | # Copyright 2010, RightScale, Inc. 5 | # 6 | # All rights reserved 7 | 8 | powershell "Installs Ruby" do 9 | attachments_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'files', 'ruby')) 10 | parameters({'ATTACHMENTS_PATH' => attachments_path}) 11 | 12 | # Create the powershell script 13 | powershell_script = <<'POWERSHELL_SCRIPT' 14 | cmd /c 7z x -y "${env:ATTACHMENTS_PATH}/ruby-1.8.6-p383-i386-mingw32-rc1.7z" 15 | mv ruby-1.8.6-p383-i386-mingw32 c:\Ruby 16 | rm $file 17 | 18 | #Permanently update windows Path 19 | [environment]::SetEnvironmentvariable("Path", $env:Path+";C:\Ruby\bin", "Machine") 20 | POWERSHELL_SCRIPT 21 | 22 | source(powershell_script) 23 | end 24 | -------------------------------------------------------------------------------- /cookbooks/aws/recipes/download.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: aws 2 | # Recipe:: download 3 | # 4 | # Copyright 2010, RightScale, Inc. 5 | # 6 | # All rights reserved 7 | 8 | # download 9 | aws_s3 "downloadmyfile" do 10 | access_key_id @node[:aws][:access_key_id] 11 | secret_access_key @node[:aws][:secret_access_key] 12 | s3_bucket @node[:s3][:bucket] 13 | s3_file @node[:s3][:file] 14 | download_dir @node[:aws][:download_dir] 15 | action :get 16 | end 17 | 18 | powershell "list drive c" do 19 | chef_attribute = Chef::Node::Attribute.new( 20 | {}, 21 | {}, 22 | {}) 23 | parameters(chef_attribute) 24 | 25 | # Create the powershell script 26 | powershell_script = <<'POWERSHELL_SCRIPT' 27 | ls c:\ 28 | POWERSHELL_SCRIPT 29 | 30 | source(powershell_script) 31 | end 32 | -------------------------------------------------------------------------------- /cookbooks/app_ad/powershell_providers/active_directory/add_user.ps1: -------------------------------------------------------------------------------- 1 | # app_ad::add_user 2 | 3 | # 1. Retrieve inputs 4 | $Domain = Get-ChefNode ad, domain 5 | $UserName = Get-ChefNode ad, user_username 6 | $Password = Get-ChefNode ad, user_password 7 | 8 | # 2. Create user 9 | Write-Host "Creating Account for User $userName" 10 | $Domain = $Domain.Split('.') 11 | $Domain = [string]::join(", DC=", $Domain) 12 | $container = [ADSI] "LDAP://CN=Users,DC=$Domain" 13 | $newUser = $container.Create("User", "CN=" + $UserName) 14 | $newUser.Put("sAMAccountName", $UserName) 15 | $newUser.SetInfo() 16 | $newUser.SetPassword($Password) 17 | $newUser.psbase.InvokeSet('AccountDisabled', $false) 18 | $newUser.SetInfo() 19 | 20 | # 3. Add user to 'Remote Desktop Users' group 21 | $remoteUsers = [ADSI] "LDAP://CN=Remote Desktop Users, CN=Builtin, DC=$Domain" 22 | $remoteUsers.add($newUser.psbase.Path) 23 | 24 | -------------------------------------------------------------------------------- /cookbooks/utilities/recipes/install_firefox.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: utilities 2 | # Recipe:: install_firefox 3 | # 4 | # Copyright 2010, RightScale, Inc. 5 | # 6 | # All rights reserved 7 | 8 | powershell "Installs Mozilla Firefox" do 9 | attachments_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'files', 'install_firefox')) 10 | parameters({'ATTACHMENTS_PATH' => attachments_path}) 11 | 12 | # Create the powershell script 13 | powershell_script = <<'POWERSHELL_SCRIPT' 14 | cd "$env:ATTACHMENTS_PATH" 15 | 16 | $file = "Firefox%20Setup%203.6.8.exe" 17 | $url = "http://releases.mozilla.org/pub/mozilla.org/firefox/releases/3.6.8/win32/en-US/"+$file 18 | 19 | $curlPath = join-path $env:ProgramFiles "RightScale\\SandBox\\Git\\bin\\curl.exe" 20 | cmd /c "$curlPath" --max-time 120 -C - -O $url 21 | 22 | cmd /c $file /INI=./firefox_quiet_install.ini 23 | 24 | rm $file 25 | POWERSHELL_SCRIPT 26 | 27 | source(powershell_script) 28 | end 29 | -------------------------------------------------------------------------------- /cookbooks/sys_monitoring/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "recipes": { 3 | "sys_monitoring::default": "Install monitoring plugin" 4 | }, 5 | "groupings": { 6 | }, 7 | "recommendations": { 8 | }, 9 | "version": "0.3.13", 10 | "maintainer": "RightScale, Inc.", 11 | "long_description": "= DESCRIPTION:\n\nEnable monitoring\n\n= USAGE:\n\nAdd to ServerTemplate to enable monitoring on instances using it.\n\nBoot Scripts\n * default - Install monitoring plugin\n", 12 | "description": "Send collectd data to RightScale", 13 | "suggestions": { 14 | }, 15 | "maintainer_email": "support@rightscale.com", 16 | "name": "sys_monitoring", 17 | "conflicting": { 18 | }, 19 | "license": "Copyright (c) 2010 RightScale, Inc.\n\nAll rights reserved - Do Not Redistribute\n", 20 | "providing": { 21 | }, 22 | "dependencies": { 23 | }, 24 | "platforms": { 25 | }, 26 | "attributes": { 27 | }, 28 | "replacing": { 29 | } 30 | } -------------------------------------------------------------------------------- /cookbooks/app_iis/recipes/start_default_website.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: app_iis 2 | # Recipe:: start_default_website 3 | # 4 | # Copyright 2010, RightScale, Inc. 5 | # 6 | # All rights reserved 7 | 8 | # start the default website 9 | powershell "Start Default Web Site and configure AutoStart" do 10 | # Create the powershell script 11 | powershell_script = <<-EOF 12 | #tell the script to "stop" or "continue" when a command fails 13 | $ErrorActionPreference = "stop" 14 | # starts the default website on IIS7 15 | $appcmd_path = $env:systemroot + "\\system32\\inetsrv\\APPCMD.exe" 16 | $appcmd_exists = Test-Path $appcmd_path 17 | if ($appcmd_exists) 18 | { 19 | &$appcmd_path start SITE "Default Web Site" 20 | &$appcmd_path set SITE "Default Web Site" /serverAutoStart:true 21 | } 22 | else 23 | { 24 | Write-Output "APPCMD.EXE is missing on 2003 image, but Default Web Site is starting by default at boot time" 25 | } 26 | EOF 27 | 28 | source(powershell_script) 29 | end 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 RightScale, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | 'Software'), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # 2 | # Rakefile for Chef Server Repository 3 | # 4 | # Author:: Adam Jacob () 5 | # Copyright:: Copyright (c) 2008 Opscode, Inc. 6 | # License:: Apache License, Version 2.0 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | require 'rubygems' 22 | require 'chef' 23 | require 'json' 24 | 25 | # Make sure you have loaded constants first 26 | require File.join(File.dirname(__FILE__), 'config', 'rake') 27 | 28 | # And choosen a VCS 29 | if File.directory?(File.join(TOPDIR, ".svn")) 30 | $vcs = :svn 31 | elsif File.directory?(File.join(TOPDIR, ".git")) 32 | $vcs = :git 33 | end 34 | 35 | load 'chef/tasks/chef_repo.rake' 36 | -------------------------------------------------------------------------------- /cookbooks/code_checkout/powershell_providers/package/_init.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /cookbooks/code_checkout/powershell_providers/svn/_init.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /cookbooks/utilities/powershell_providers/scheduled_tasks/_init.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /cookbooks/aws/powershell_providers/elb/_load_current_resource.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | -------------------------------------------------------------------------------- /cookbooks/aws/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: aws 2 | # Recipe:: default 3 | # 4 | # Copyright 2010, RightScale, Inc. 5 | # 6 | # All rights reserved 7 | 8 | powershell "Install AWS SDK" do 9 | attachments_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'files', 'install_dotnet_sdk')) 10 | parameters({'ATTACHMENTS_PATH' => attachments_path}) 11 | 12 | # Create the powershell script 13 | powershell_script = <<'POWERSHELL_SCRIPT' 14 | $aws_sdk = "AWS SDK for .NET" 15 | 16 | #check to see if the package is already installed 17 | if (Test-Path (${env:programfiles(x86)}+"\"+$aws_sdk)) { 18 | $aws_sdk_path = ${env:programfiles(x86)}+"\"+$aws_sdk 19 | } Elseif (Test-Path (${env:programfiles}+"\"+$aws_sdk)) { 20 | $aws_sdk_path = ${env:programfiles}+"\"+$aws_sdk 21 | } 22 | 23 | if ($aws_sdk_path -ne $null) { 24 | Write-Output "*** AWS SDK for .NET already installed in [$aws_sdk_path]. Skipping installation." 25 | } 26 | Else { 27 | cd "$env:ATTACHMENTS_PATH" 28 | Write-Output "*** Installing AWS SDK for .NET msi" 29 | cmd /c msiexec /package AWSSDKForNET_1.0.11.msi /quiet 30 | } 31 | POWERSHELL_SCRIPT 32 | 33 | source(powershell_script) 34 | end -------------------------------------------------------------------------------- /cookbooks/code_checkout/powershell_providers/svn/_load_current_resource.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | -------------------------------------------------------------------------------- /cookbooks/code_checkout/powershell_providers/package/_load_current_resource.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | -------------------------------------------------------------------------------- /cookbooks/utilities/powershell_providers/scheduled_tasks/_load_current_resource.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | -------------------------------------------------------------------------------- /cookbooks/aws/powershell_providers/s3/_load_current_resource.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # No current resource for elb provider 23 | -------------------------------------------------------------------------------- /cookbooks/blog_engine/powershell_providers/database/_term.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | Write-Debug "Terminated database resource" 23 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/powershell_providers/database/_term.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | Write-Debug "Terminated database resource" 23 | -------------------------------------------------------------------------------- /cookbooks/app_iis/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: app_iis 2 | # Recipe:: default 3 | # 4 | # Copyright (c) 2010 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /cookbooks/code_checkout/resources/package.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 RightScale Inc 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining 5 | # a copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, 8 | # distribute, sublicense, and/or sell copies of the Software, and to 9 | # permit persons to whom the Software is furnished to do so, subject to 10 | # the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be 13 | # included in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | actions :unpack 24 | 25 | attribute :releases_path, :kind_of => [ String ] 26 | attribute :package_path, :kind_of => [ String ] -------------------------------------------------------------------------------- /cookbooks/blog_engine/recipes/drop_database.rb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # Drop the demo database. 23 | blog_engine_database "BlogEngine" do 24 | server_name @node[:db_sqlserver][:server_name] 25 | action :drop 26 | end 27 | -------------------------------------------------------------------------------- /cookbooks/aws/resources/elb.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 RightScale Inc 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining 5 | # a copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, 8 | # distribute, sublicense, and/or sell copies of the Software, and to 9 | # permit persons to whom the Software is furnished to do so, subject to 10 | # the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be 13 | # included in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | actions :register, :deregister 24 | 25 | attribute :access_key_id, :kind_of => [ String ] 26 | attribute :secret_access_key, :kind_of => [ String ] 27 | attribute :elb_name, :kind_of => [ String ] 28 | 29 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/recipes/drop.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: db_sqlserver 2 | # Recipe:: drop 3 | # 4 | # Copyright (c) 2010 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | # Drop database 26 | db_sqlserver_database @node[:db_sqlserver][:database_name] do 27 | server_name @node[:db_sqlserver][:server_name] 28 | action :drop 29 | end 30 | -------------------------------------------------------------------------------- /cookbooks/utilities/recipes/delete_scheduled_task.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: utilities 2 | # Recipe:: delete_scheduled_task 3 | # 4 | # Copyright (c) 2010 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | # Delete the scheduled task 26 | utilities_scheduled_tasks "rs_scheduled_task" do 27 | action :delete 28 | end 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /cookbooks/code_checkout/resources/svn.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 RightScale Inc 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining 5 | # a copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, 8 | # distribute, sublicense, and/or sell copies of the Software, and to 9 | # permit persons to whom the Software is furnished to do so, subject to 10 | # the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be 13 | # included in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | actions :checkout 24 | 25 | attribute :svn_username, :kind_of => [ String ] 26 | attribute :svn_password, :kind_of => [ String ] 27 | attribute :releases_path, :kind_of => [ String ] 28 | attribute :force_checkout, :equal_to => [ true, false ] -------------------------------------------------------------------------------- /cookbooks/blog_engine/recipes/add_monitors.rb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | require 'fileutils' 23 | 24 | ruby 'setup BlogEngine monitoring' do 25 | src_plugin_dir_path = File.join(File.dirname(__FILE__), '..', 'files', 'default', 'monitors', '.') 26 | dst_plugin_dir_path = ENV['RS_MONITORS_DIR'] 27 | FileUtils.cp_r(src_plugin_dir_path, dst_plugin_dir_path) 28 | end 29 | -------------------------------------------------------------------------------- /cookbooks/sys_monitoring/files/default/monitors/memory_usage.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 RightScale Inc 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining 5 | # a copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, 8 | # distribute, sublicense, and/or sell copies of the Software, and to 9 | # permit persons to whom the Software is furnished to do so, subject to 10 | # the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be 13 | # included in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | wmi_query 'Select FreePhysicalMemory from Win32_OperatingSystem' 24 | wmi_query_send_attributes 'FreePhysicalMemory' 25 | collectd_plugin 'memory' 26 | collectd_type 'memory' 27 | collectd_type_instance 'free' 28 | collectd_units_factor 1024 29 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/recipes/enable_sql_service.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: db_sqlserver 2 | # Recipe:: enable_sql_service 3 | # 4 | # Copyright 2010, RightScale, Inc. 5 | # 6 | # All rights reserved 7 | 8 | # enable the SQL service 9 | powershell "Enable the SQL service" do 10 | # Create the powershell script 11 | powershell_script = < $null 14 | if ($Null -eq $serviceController) 15 | { 16 | $sqlServiceName='MSSQLSERVER' 17 | $serviceController = get-service $sqlServiceName 2> $null 18 | if ($Null -eq $serviceController) 19 | { 20 | Write-Error "SQL Server service is not installed" 21 | exit 100 22 | } 23 | } 24 | 25 | if ($serviceController.Status -eq "Stopped") 26 | { 27 | sc.exe config $sqlServiceName start= auto 28 | if ($LastExitCode -eq 0) 29 | { 30 | net start $sqlServiceName 31 | if ($LastExitCode -ne 0) 32 | { 33 | Write-Error "Failed to start $sqlServiceName service" 34 | exit $LastExitCode 35 | } 36 | } 37 | else 38 | { 39 | Write-Error "Failed to enable $sqlServiceName service" 40 | exit $LastExitCode 41 | } 42 | } 43 | else 44 | { 45 | $message = "$sqlServiceName service is already " + $serviceController.Status 46 | Write-Output $message 47 | } 48 | EOF 49 | 50 | source(powershell_script) 51 | end 52 | -------------------------------------------------------------------------------- /cookbooks/utilities/resources/scheduled_tasks.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 RightScale Inc 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining 5 | # a copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, 8 | # distribute, sublicense, and/or sell copies of the Software, and to 9 | # permit persons to whom the Software is furnished to do so, subject to 10 | # the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be 13 | # included in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | actions :create, :delete 24 | 25 | #optional 26 | attribute :task_name, :kind_of => [ String ] 27 | attribute :daily_time, :kind_of => [ String ] 28 | 29 | #required 30 | attribute :command, :kind_of => [ String ] 31 | attribute :hourly_frequency, :kind_of => [ String ] 32 | attribute :username, :kind_of => [ String ] 33 | attribute :password, :kind_of => [ String ] 34 | 35 | 36 | -------------------------------------------------------------------------------- /cookbooks/utilities/recipes/install_7zip.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: utilities 2 | # Recipe:: install_7zip 3 | # 4 | # Copyright 2010, RightScale, Inc. 5 | # 6 | # All rights reserved 7 | 8 | powershell "Installs 7zip" do 9 | attachments_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'files', 'install_7zip')) 10 | parameters({'ATTACHMENTS_PATH' => attachments_path}) 11 | 12 | # Create the powershell script 13 | powershell_script = <<'POWERSHELL_SCRIPT' 14 | #check to see if the package is already installed 15 | if (Test-Path (${env:programfiles(x86)}+"\7-Zip")) { 16 | $7zip_path = ${env:programfiles(x86)}+"\7-Zip" 17 | } Elseif (Test-Path (${env:programfiles}+"\7-Zip")) { 18 | $7zip_path = ${env:programfiles}+"\7-Zip" 19 | } 20 | 21 | if ($7zip_path -ne $null) { 22 | Write-Output "7-Zip package is already installed in [$7zip_path]. Skipping installation." 23 | exit 0 24 | } 25 | 26 | cd "$env:ATTACHMENTS_PATH" 27 | $file="7z465.exe" 28 | cmd /c $file /S 29 | 30 | #Permanently update windows Path 31 | if (Test-Path (${env:programfiles(x86)}+"\7-Zip")) { 32 | [environment]::SetEnvironmentvariable("Path", $env:Path+";"+${env:programfiles(x86)}+"\7-Zip", "Machine") 33 | } Elseif (Test-Path (${env:programfiles}+"\7-Zip")) { 34 | [environment]::SetEnvironmentvariable("Path", $env:Path+";"+${env:programfiles}+"\7-Zip", "Machine") 35 | } Else { 36 | Write-Error "Failed to install 7-Zip. Aborting." 37 | exit 19 38 | } 39 | POWERSHELL_SCRIPT 40 | 41 | source(powershell_script) 42 | end 43 | -------------------------------------------------------------------------------- /cookbooks/blog_engine/files/default/monitors/blog_engine_iis_connections.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 RightScale Inc 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining 5 | # a copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, 8 | # distribute, sublicense, and/or sell copies of the Software, and to 9 | # permit persons to whom the Software is furnished to do so, subject to 10 | # the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be 13 | # included in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | wmi_query_name_attribute 'Name' 24 | wmi_query_send_attributes 'CurrentConnections' 25 | wmi_query "Select #{wmi_query_name_attribute},#{wmi_query_send_attributes} from Win32_PerfRawData_W3SVC_WebService where Name!='_Total'" 26 | collectd_plugin 'iis' 27 | collectd_type 'iis_connections' 28 | collectd_type_instance 'current' 29 | -------------------------------------------------------------------------------- /cookbooks/blog_engine/powershell_providers/database/_init.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # load SQL Server assemblies 23 | [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null 24 | [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended") | Out-Null 25 | [Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") | Out-Null 26 | [Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum") | Out-Null 27 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/powershell_providers/database/_init.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # load SQL Server assemblies 23 | [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null 24 | [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended") | Out-Null 25 | [Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") | Out-Null 26 | [Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum") | Out-Null 27 | -------------------------------------------------------------------------------- /cookbooks/utilities/recipes/create_scheduled_task.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: utilities 2 | # Recipe:: create_scheduled_task 3 | # 4 | # Copyright (c) 2010 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | # create a scheduled the task 26 | utilities_scheduled_tasks "rs_scheduled_task" do 27 | username "administrator" 28 | password @node[:utilities][:admin_password] 29 | command @node[:schtasks][:command] 30 | hourly_frequency @node[:schtasks][:hourly_frequency] 31 | daily_time @node[:schtasks][:daily_time] 32 | action :create 33 | end 34 | -------------------------------------------------------------------------------- /cookbooks/aws/resources/s3.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 RightScale Inc 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining 5 | # a copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, 8 | # distribute, sublicense, and/or sell copies of the Software, and to 9 | # permit persons to whom the Software is furnished to do so, subject to 10 | # the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be 13 | # included in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | actions :get, :put 24 | 25 | #get and put actions 26 | attribute :access_key_id, :kind_of => [ String ] 27 | attribute :secret_access_key, :kind_of => [ String ] 28 | attribute :s3_bucket, :kind_of => [ String ] 29 | attribute :s3_file, :kind_of => [ String ] 30 | 31 | #get action 32 | attribute :download_dir, :kind_of => [ String ] 33 | 34 | #put action 35 | attribute :file_path, :kind_of => [ String ] 36 | attribute :timeout_seconds, :kind_of => [ Integer ] -------------------------------------------------------------------------------- /cookbooks/blog_engine/recipes/restore_database.rb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # loads the demo database from cookbook-relative backup file. 23 | blog_engine_database "BlogEngine" do 24 | machine_type = @node[:kernel][:machine] 25 | 26 | backup_dir_path @node[:db_sqlserver][:backup][:database_backup_dir] 27 | existing_backup_file_name_pattern @node[:db_sqlserver][:backup][:existing_backup_file_name_pattern] 28 | server_name @node[:db_sqlserver][:server_name] 29 | force_restore false 30 | 31 | action :restore 32 | end 33 | -------------------------------------------------------------------------------- /cookbooks/blog_engine/files/default/monitors/blog_engine_iis_bytes.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 RightScale Inc 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining 5 | # a copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, 8 | # distribute, sublicense, and/or sell copies of the Software, and to 9 | # permit persons to whom the Software is furnished to do so, subject to 10 | # the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be 13 | # included in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | wmi_query_name_attribute 'Name' 24 | wmi_query_send_attributes ['BytesReceivedPerSec', 'BytesSentPerSec'] 25 | wmi_query "Select #{wmi_query_name_attribute},#{wmi_query_send_attributes.join(',')} from Win32_PerfRawData_W3SVC_WebService where Name!='_Total'" 26 | collectd_plugin 'iis' 27 | collectd_type 'iis_bytes' 28 | collectd_type_instance 'received_sent' 29 | collectd_sender :counter 30 | -------------------------------------------------------------------------------- /cookbooks/blog_engine/resources/database.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 RightScale Inc 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining 5 | # a copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, 8 | # distribute, sublicense, and/or sell copies of the Software, and to 9 | # permit persons to whom the Software is furnished to do so, subject to 10 | # the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be 13 | # included in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | actions :backup, :drop, :restore, :run_command, :run_script 24 | 25 | attribute :backup_dir_path, :kind_of => [ String ] 26 | attribute :backup_file_name_format, :kind_of => [ String ] 27 | attribute :existing_backup_file_name_pattern, :kind_of => [ String ] 28 | attribute :server_name, :kind_of => [ String ] 29 | attribute :force_restore, :equal_to => [ true, false ] 30 | attribute :commands, :kind_of => [ Array ] 31 | attribute :script_path, :kind_of => [ String ] 32 | -------------------------------------------------------------------------------- /cookbooks/blog_engine/recipes/backup_database.rb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # loads the demo database from cookbook-relative backup file. 23 | blog_engine_database "BlogEngine" do 24 | machine_type = @node[:kernel][:machine] 25 | 26 | backup_dir_path @node[:db_sqlserver][:backup][:database_backup_dir] 27 | backup_file_name_format @node[:db_sqlserver][:backup][:backup_file_name_format] 28 | existing_backup_file_name_pattern @node[:db_sqlserver][:backup][:existing_backup_file_name_pattern] 29 | server_name @node[:db_sqlserver][:server_name] 30 | force_restore false 31 | 32 | action :backup 33 | end 34 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/recipes/restore.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: db_sqlserver 2 | # Recipe:: restore 3 | # 4 | # Copyright (c) 2010 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | # Restore database 26 | db_sqlserver_database @node[:db_sqlserver][:database_name] do 27 | machine_type = @node[:kernel][:machine] 28 | 29 | backup_dir_path @node[:db_sqlserver][:backup][:database_backup_dir] 30 | existing_backup_file_name_pattern @node[:db_sqlserver][:backup][:existing_backup_file_name_pattern] 31 | server_name @node[:db_sqlserver][:server_name] 32 | force_restore @node[:db_sqlserver][:restore][:force_restore] == 'true' 33 | 34 | action :restore 35 | end 36 | -------------------------------------------------------------------------------- /cookbooks/aws/powershell_providers/elb/_init.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | $aws_sdk = "AWS SDK for .NET" 23 | 24 | #check to see if the package is already installed 25 | if (Test-Path (${env:programfiles(x86)}+"\"+$aws_sdk)) { 26 | $aws_sdk_path = ${env:programfiles(x86)}+"\"+$aws_sdk 27 | } Elseif (Test-Path (${env:programfiles}+"\"+$aws_sdk)) { 28 | $aws_sdk_path = ${env:programfiles}+"\"+$aws_sdk 29 | } 30 | 31 | if ($aws_sdk_path -eq $null) { 32 | Write-Error "*** AWS SDK for .NET package is not installed on the system. Aborting." 33 | exit 12 34 | } 35 | 36 | #use the AWS SDK dll 37 | Add-Type -Path "$aws_sdk_path\bin\AWSSDK.dll" 38 | -------------------------------------------------------------------------------- /cookbooks/aws/powershell_providers/s3/_init.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | $aws_sdk = "AWS SDK for .NET" 23 | 24 | #check to see if the package is already installed 25 | if (Test-Path (${env:programfiles(x86)}+"\"+$aws_sdk)) { 26 | $aws_sdk_path = ${env:programfiles(x86)}+"\"+$aws_sdk 27 | } Elseif (Test-Path (${env:programfiles}+"\"+$aws_sdk)) { 28 | $aws_sdk_path = ${env:programfiles}+"\"+$aws_sdk 29 | } 30 | 31 | if ($aws_sdk_path -eq $null) { 32 | Write-Error "*** AWS SDK for .NET package is not installed on the system. Aborting." 33 | exit 12 34 | } 35 | 36 | #use the AWS SDK dll 37 | Add-Type -Path "$aws_sdk_path\bin\AWSSDK.dll" 38 | -------------------------------------------------------------------------------- /cookbooks/app_ad/metadata.rb: -------------------------------------------------------------------------------- 1 | description "ActiveDirectory recipes" 2 | version "0.0.1" 3 | 4 | recipe "app_ad::add_user", "Creates a new Active Directory user account, must be run on Domain Controller" 5 | recipe "app_ad::remote_add_user", "Creates a new Active Directory user account, can be run anywhere" 6 | recipe "app_ad::join", "Join instance to domain" 7 | recipe "app_ad::set_dns_server", "Set DNS server entries" 8 | recipe "app_ad::setup_controller", "Sets up domain controller tag" 9 | 10 | attribute "ad/domain", 11 | :display_name => "Domain name", 12 | :description => "Active Directory domain name", 13 | :recipes => ["app_ad::add_user", "app_ad::remote_add_user", "app_ad::join"], 14 | :required => "required" 15 | 16 | attribute "ad/user_username", 17 | :display_name => "Application username", 18 | :description => "New Active Directory domain account username", 19 | :recipes => ["app_ad::add_user", "app_ad::remote_add_user"], 20 | :required => "required" 21 | 22 | attribute "ad/user_password", 23 | :display_name => "Application password", 24 | :description => "New Active Directory domain account password", 25 | :recipes => ["app_ad::add_user", "app_ad::remote_add_user"], 26 | :required => "required" 27 | 28 | attribute "ad/admin_username", 29 | :display_name => "Domain administrator username", 30 | :description => "Username of domain account used to add computers to domain", 31 | :recipes => ["app_ad::join"], 32 | :required => "required" 33 | 34 | attribute "ad/admin_password", 35 | :display_name => "Domain administrator password", 36 | :description => "Password of domain account used to add computers to the domain", 37 | :recipes => ["app_ad::join"], 38 | :required => "required" 39 | 40 | 41 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/resources/database.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 RightScale Inc 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining 5 | # a copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, 8 | # distribute, sublicense, and/or sell copies of the Software, and to 9 | # permit persons to whom the Software is furnished to do so, subject to 10 | # the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be 13 | # included in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | actions :backup, :drop, :restore, :run_command, :run_script 24 | 25 | attribute :backup_dir_path, :kind_of => [ String ] 26 | attribute :backup_file_name_format, :kind_of => [ String ] 27 | attribute :existing_backup_file_name_pattern, :kind_of => [ String ] 28 | attribute :server_name, :kind_of => [ String ] 29 | attribute :force_restore, :equal_to => [ true, false ] 30 | attribute :commands, :kind_of => [ Array ] 31 | attribute :script_path, :kind_of => [ String ] 32 | attribute :zip_backup, :equal_to => [ true, false ] 33 | attribute :delete_sql_after_zip, :equal_to => [ true, false ] 34 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/recipes/backup.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: db_sqlserver 2 | # Recipe:: backup_to_s3 3 | # 4 | # Copyright (c) 2010 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | # Backup database 26 | db_sqlserver_database @node[:db_sqlserver][:database_name] do 27 | machine_type = @node[:kernel][:machine] 28 | 29 | backup_dir_path @node[:db_sqlserver][:backup][:database_backup_dir] 30 | backup_file_name_format @node[:db_sqlserver][:backup][:backup_file_name_format] 31 | existing_backup_file_name_pattern @node[:db_sqlserver][:backup][:existing_backup_file_name_pattern] 32 | server_name @node[:db_sqlserver][:server_name] 33 | force_restore false 34 | zip_backup false 35 | 36 | action :backup 37 | end -------------------------------------------------------------------------------- /cookbooks/utilities/powershell_providers/scheduled_tasks/delete.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $name = Get-NewResource name 24 | 25 | # "Stop" or "Continue" the powershell script execution when a command fails 26 | $ErrorActionPreference = "Stop" 27 | 28 | #check inputs. 29 | $Error.Clear() 30 | if (($name -eq $NULL) -or ($name -eq "")) 31 | { 32 | Write-Error "Error: 'name' is a required attribute for the 'scheduled_tasks' provider. Aborting..." 33 | exit 140 34 | } 35 | 36 | #remove any characters that might brake the command 37 | $name = $name -replace '[^\w]', '' 38 | 39 | schtasks.exe /delete /F /TN $name 40 | 41 | if (!$?) 42 | { 43 | Write-Error "Error: SCHTASKS execution failed." 44 | exit 141 45 | } 46 | -------------------------------------------------------------------------------- /config/rake.rb: -------------------------------------------------------------------------------- 1 | ### 2 | # Company and SSL Details 3 | ### 4 | 5 | # The company name - used for SSL certificates, and in srvious other places 6 | COMPANY_NAME = "RightScale, Inc." 7 | 8 | # The Country Name to use for SSL Certificates 9 | SSL_COUNTRY_NAME = "US" 10 | 11 | # The State Name to use for SSL Certificates 12 | SSL_STATE_NAME = "CA" 13 | 14 | # The Locality Name for SSL - typically, the city 15 | SSL_LOCALITY_NAME = "Santa Barbara" 16 | 17 | # What department? 18 | SSL_ORGANIZATIONAL_UNIT_NAME = "Support" 19 | 20 | # The SSL contact email address 21 | SSL_EMAIL_ADDRESS = "support@rightscale.com" 22 | 23 | # License for new Cookbooks 24 | # Can be :apachev2 or :none 25 | NEW_COOKBOOK_LICENSE = :none 26 | 27 | ########################## 28 | # Chef Repository Layout # 29 | ########################## 30 | 31 | # Where to install upstream cookbooks for serving 32 | COOKBOOK_PATH = "/srv/chef/cookbooks" 33 | 34 | # Where to install site-local modifications to upstream cookbooks 35 | SITE_COOKBOOK_PATH = "/srv/chef/site-cookbooks" 36 | 37 | # Where to install roles 38 | ROLE_PATH = "/srv/chef/roles" 39 | 40 | # Chef Config Path 41 | CHEF_CONFIG_PATH = "/etc/chef" 42 | 43 | # The location of the Chef Server Config file (on the server) 44 | CHEF_SERVER_CONFIG = File.join(CHEF_CONFIG_PATH, "server.rb") 45 | 46 | # The location of the Chef Client Config file (on the client) 47 | CHEF_CLIENT_CONFIG = File.join(CHEF_CONFIG_PATH, "client.rb") 48 | 49 | ### 50 | # Useful Extras (which you probably don't need to change) 51 | ### 52 | 53 | # The top of the repository checkout 54 | TOPDIR = File.expand_path(File.join(File.dirname(__FILE__), "..")) 55 | 56 | # Where to store certificates generated with ssl_cert 57 | CADIR = File.expand_path(File.join(TOPDIR, "certificates")) 58 | 59 | # Where to store the mtime cache for the recipe/template syntax check 60 | TEST_CACHE = File.expand_path(File.join(TOPDIR, ".rake_test_cache")) -------------------------------------------------------------------------------- /cookbooks/sys_monitoring/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | require 'fileutils' 23 | 24 | # Copy collectd and monitor library file(s). 25 | ruby 'setup monitoring' do 26 | src_dir_path = File.join(File.dirname(__FILE__), '..', 'files', 'default') 27 | dst_dir_path = File.expand_path(File.join(RightScale::RightLinkConfig[:rs_root_path], '..', 'RightLinkService', 'scripts', 'lib')) 28 | FileUtils.mkdir_p(dst_dir_path) 29 | FileUtils.cp_r(File.join(src_dir_path, '.'), dst_dir_path) 30 | end 31 | 32 | # Enable monitoring in the dashboard 33 | right_link_tag 'rs_monitoring:state=active' 34 | 35 | # Configure and enable monitoring script 36 | template File.join(RightScale::RightLinkConfig[:rs_root_path], '..', 'RightLinkService', 'scripts', 'monitoring.rb') do 37 | source 'monitoring.rb.erb' 38 | end 39 | -------------------------------------------------------------------------------- /cookbooks/sys_monitoring/files/default/monitors/disk_usage.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 RightScale Inc 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining 5 | # a copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, 8 | # distribute, sublicense, and/or sell copies of the Software, and to 9 | # permit persons to whom the Software is furnished to do so, subject to 10 | # the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be 13 | # included in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | # Collect and send disk usage 24 | # 25 | # === Return 26 | # true:: Always return true 27 | def run 28 | drives = execute_wmi_query("Select deviceid, freespace, size from win32_logicaldisk") 29 | for drive in drives do 30 | if drive.deviceid =~ /^(\w):$/ 31 | drive_letter = $1 32 | free_space_val = drive.freespace 33 | drive_size_val = drive.size 34 | if is_number?(free_space_val) && is_number?(drive_size_val) 35 | used_space = drive_size_val.to_i - free_space_val.to_i 36 | @logger.debug("Drive #{drive_letter}: has #{free_space_val} free and #{used_space} used space") 37 | gauge('df', '', 'df', "drive_#{drive_letter}", [ used_space, free_space_val.to_i ]) 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: db_sqlserver 2 | # Recipe:: default 3 | # 4 | # Copyright (c) 2010 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | include_recipe 'db_sqlserver::enable_sql_service' 26 | include_recipe 'db_sqlserver::import_dump_from_s3' 27 | 28 | if (@node[:db_sqlserver_default_executed]) 29 | Chef::Log.info("*** Recipe 'db_sqlserver::default' already executed, skipping...") 30 | else 31 | # Create default user 32 | db_sqlserver_database @node[:db_sqlserver][:database_name] do 33 | server_name @node[:db_sqlserver][:server_name] 34 | commands ["CREATE USER [NetworkService] FOR LOGIN [NT AUTHORITY\\NETWORK SERVICE]", 35 | "EXEC sp_addrolemember 'db_datareader', 'NetworkService'", 36 | "EXEC sp_addrolemember 'db_datawriter', 'NetworkService'"] 37 | action :run_command 38 | end 39 | 40 | @node[:db_sqlserver_default_executed] = true 41 | end 42 | -------------------------------------------------------------------------------- /cookbooks/utilities/files/install_firefox/firefox_quiet_install.ini: -------------------------------------------------------------------------------- 1 | [Install] 2 | ; The name of the directory where the application will be installed in the 3 | ; system's program files directory. The security 4 | ; context the installer is running in must have write access to the 5 | ; installation directory. Also, the directory must not exist or if it exists 6 | ; it must be a directory and not a file. If any of these conditions are not met 7 | ; the installer will abort the installation with an error level of 2. If this 8 | ; value is specified then InstallDirectoryPath will be ignored. 9 | ; InstallDirectoryName=Mozilla Firefox 10 | 11 | ; The full path to the directory to install the application. The security 12 | ; context the installer is running in must have write access to the 13 | ; installation directory. Also, the directory must not exist or if it exists 14 | ; it must be a directory and not a file. If any of these conditions are not met 15 | ; the installer will abort the installation with an error level of 2. 16 | ; InstallDirectoryPath=c:\firefox\ 17 | 18 | ; By default all of the following shortcuts are created. To prevent the 19 | ; creation of a shortcut specify false for the shortcut you don't want created. 20 | ; 21 | ; Create a shortcut for the application in the current user's QuickLaunch 22 | ; directory. 23 | QuickLaunchShortcut=false 24 | ; 25 | ; Create a shortcut for the application on the desktop. This will create the 26 | ; shortcut in the All Users Desktop directory and if that fails this will 27 | ; attempt to create the shortcuts in the current user's Start Menu directory. 28 | DesktopShortcut=true 29 | ; 30 | ; Create shortcuts for the application in the Start Menu. This will create the 31 | ; shortcuts in the All Users Start Menu directory and if that fails this will 32 | ; attempt to create the shortcuts in the current user's Start Menu directory. 33 | StartMenuShortcuts=true 34 | 35 | ; The directory name to use for the StartMenu folder. 36 | ; note: if StartMenuShortcuts=false is specified then this will be ignored. 37 | StartMenuDirectoryName=Mozilla Firefox -------------------------------------------------------------------------------- /cookbooks/blog_engine/powershell_providers/database/run_script.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $dbName = Get-NewResource name 24 | $scriptPath = Get-NewResource script_path 25 | $serverName = Get-NewResource server_name 26 | 27 | #check inputs. 28 | $Error.Clear() 29 | if (($dbName -eq $Null) -or ($dbName -eq "")) 30 | { 31 | Write-Error "Invalid or missing database name". 32 | exit 100 33 | } 34 | if (($scriptPath -eq $Null) -or ($scriptPath -eq "")) 35 | { 36 | Write-Error "No SQL commands provided in resource". 37 | exit 101 38 | } 39 | if (($serverName -eq $Null) -or ($serverName -eq "")) 40 | { 41 | Write-Error "Invalid or missing server name". 42 | exit 102 43 | } 44 | if (0 -ne $Error.Count) 45 | { 46 | exit 103 47 | } 48 | 49 | # note use of sqlcmd assumes SQL Server/Express installation puts tools on path. 50 | sqlcmd -S $serverName -d $dbName -i "$scriptPath" | Out-Null 51 | 52 | exit $LastExitCode 53 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/powershell_providers/database/run_script.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $dbName = Get-NewResource name 24 | $scriptPath = Get-NewResource script_path 25 | $serverName = Get-NewResource server_name 26 | 27 | #check inputs. 28 | $Error.Clear() 29 | if (($scriptPath -eq $Null) -or ($scriptPath -eq "")) 30 | { 31 | Write-Error "No SQL commands provided in resource." 32 | exit 101 33 | } 34 | if (($serverName -eq $Null) -or ($serverName -eq "")) 35 | { 36 | Write-Error "Invalid or missing server name." 37 | exit 102 38 | } 39 | if (0 -ne $Error.Count) 40 | { 41 | exit 103 42 | } 43 | 44 | $win_path = ([System.IO.FileInfo]$scriptPath).fullname 45 | 46 | if (test-path $win_path) 47 | { 48 | Write-Output "*** Running [$win_path] with no schema defined." 49 | 50 | # Redirect stdout to null 51 | sqlcmd -S $serverName -i "$win_path" > $null 52 | 53 | exit $LastExitCode 54 | } 55 | else 56 | { 57 | Write-Error "[$win_path] script is missing." 58 | exit 102 59 | } -------------------------------------------------------------------------------- /cookbooks/utilities/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "RightScale, Inc." 2 | maintainer_email "support@rightscale.com" 3 | license IO.read(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'LICENSE'))) 4 | description "Windows Admin recipes and providers" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 6 | version "0.3.2" 7 | 8 | recipe "utilities::default", "Not yet implemented" 9 | recipe "utilities::change_admin_password", "Changes the administrator password" 10 | recipe "utilities::system_reboot", "Reboots the system" 11 | recipe "utilities::system_shutdown", "Shuts down the system" 12 | recipe "utilities::install_firefox", "Installs Mozilla Firefox 3.6" 13 | recipe "utilities::install_7zip", "Installs 7-Zip" 14 | recipe "utilities::install_ruby", "Installs Ruby" 15 | recipe "utilities::create_scheduled_task", "Creates the 'rs_scheduled_task' scheduled task under the 'administrator' user. Uses the SCHTASKS Windows command" 16 | recipe "utilities::delete_scheduled_task", "Deletes the 'rs_scheduled_task' scheduled task under the 'administrator' user. Uses the SCHTASKS Windows command" 17 | 18 | attribute "utilities/admin_password", 19 | :display_name => "New administrator password", 20 | :description => "New administrator password", 21 | :recipes => ["utilities::change_admin_password", "utilities::create_scheduled_task"], 22 | :required => "required" 23 | 24 | attribute "schtasks/command", 25 | :display_name => "Task command", 26 | :description => "Defines the shell command to run. (e.g., dir >> c:\\dir.txt)", 27 | :recipes => ["utilities::create_scheduled_task"], 28 | :required => "required" 29 | 30 | attribute "schtasks/hourly_frequency", 31 | :display_name => "Task Hourly frequency", 32 | :description => "Defines the task frequency in hours. Valid values: 1 up to 24. When 24 is specified the 'Task daily time' input is required also.", 33 | :recipes => ["utilities::create_scheduled_task"], 34 | :required => "required" 35 | 36 | attribute "schtasks/daily_time", 37 | :display_name => "Task daily time", 38 | :description => "The time of the day, based on the server's timezone, to run the task when the 'Hourly frequency' input is set to 24. Format: hh:mm (e.g., 22:30)", 39 | :recipes => ["utilities::create_scheduled_task"], 40 | :required => "optional", 41 | :default => "" 42 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/recipes/backup_to_s3.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: db_sqlserver 2 | # Recipe:: backup_to_s3 3 | # 4 | # Copyright (c) 2010 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | # backs up the database 26 | db_sqlserver_database @node[:db_sqlserver][:database_name] do 27 | machine_type = @node[:kernel][:machine] 28 | backup_dir_path @node[:db_sqlserver][:backup][:database_backup_dir] 29 | backup_file_name_format @node[:db_sqlserver][:backup][:backup_file_name_format] 30 | existing_backup_file_name_pattern @node[:db_sqlserver][:backup][:existing_backup_file_name_pattern] 31 | server_name @node[:db_sqlserver][:server_name] 32 | force_restore false 33 | zip_backup true 34 | delete_sql_after_zip false 35 | action :backup 36 | end 37 | 38 | # upload backup to s3 39 | aws_s3 "upload the latest backup to the s3 bucket" do 40 | access_key_id @node[:aws][:access_key_id] 41 | secret_access_key @node[:aws][:secret_access_key] 42 | s3_bucket @node[:s3][:bucket_backups] 43 | # when file_path is a directory, the latest file in the directory will be uploaded 44 | file_path @node[:db_sqlserver][:backup][:database_backup_dir] 45 | # increase default timeout to 30 minutes. Default is 20(1200 seconds) 46 | timeout_seconds 1800 47 | action :put 48 | end -------------------------------------------------------------------------------- /cookbooks/blog_engine/files/default/monitors/blog_engine_iis_requests.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 RightScale Inc 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining 5 | # a copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, 8 | # distribute, sublicense, and/or sell copies of the Software, and to 9 | # permit persons to whom the Software is furnished to do so, subject to 10 | # the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be 13 | # included in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | wmi_query_name_attribute 'Name' 24 | wmi_query_send_attributes ['CGIRequestsPerSec', 'CopyRequestsPerSec', 25 | 'DeleteRequestsPerSec', 'GetRequestsPerSec', 26 | 'HeadRequestsPerSec', 'ISAPIExtensionRequestsPerSec', 27 | 'LockRequestsPerSec', 'MkcolRequestsPerSec', 28 | 'MoveRequestsPerSec', 'OptionsRequestsPerSec', 29 | 'PostRequestsPerSec', 'PropfindRequestsPerSec', 30 | 'ProppatchRequestsPerSec', 'PutRequestsPerSec', 31 | 'SearchRequestsPerSec', 'TraceRequestsPerSec', 32 | 'UnlockRequestsPerSec'] 33 | wmi_query_required_send ['get', 'post'] 34 | wmi_query "Select #{wmi_query_name_attribute},#{wmi_query_send_attributes.join(",")} from Win32_PerfRawData_W3SVC_WebService where Name!='_Total'" 35 | collectd_plugin 'iis' 36 | collectd_type 'iis_requests' 37 | collectd_type_instance /\A(.*)RequestsPerSec\z/ 38 | collectd_sender :counter 39 | -------------------------------------------------------------------------------- /cookbooks/blog_engine/powershell_providers/database/drop.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $cookbookName = Get-NewResource cookbook_name 24 | $resourceName = Get-NewResource resource_name 25 | $dbName = Get-NewResource name 26 | $nodePath = $cookbookName,$resourceName,$dbName 27 | $serverName = Get-NewResource server_name 28 | 29 | # check if database exists before restoring. 30 | if (!(Get-ChefNode ($nodePath + "exists"))) 31 | { 32 | Write-Warning "Not dropping ""$dbName"" because it does not exist." 33 | exit 0 34 | } 35 | 36 | # connect to server. 37 | $server = New-Object ("Microsoft.SqlServer.Management.Smo.Server") $serverName 38 | 39 | # intentionally fail if asked to drop a system database. 40 | $db = $server.Databases | where { !$_.IsSystemObject_ -and ($_.Name -eq $dbName) } 41 | if ($db) 42 | { 43 | $Error.Clear() 44 | $db.Drop() 45 | if ($Error.Count -eq 0) 46 | { 47 | Write-Output "Dropped database named ""$dbName""" 48 | Set-ChefNode ($nodePath + "exists") $False 49 | Set-NewResource updated $True 50 | exit 0 51 | } 52 | else 53 | { 54 | Write-Error 'Failed to drop ""$dbName.ToString()"" because ""$Error.ToString()""' 55 | exit 100 56 | } 57 | } 58 | else 59 | { 60 | Write-Error "Failed to find a non-system database named ""$dbName""" 61 | exit 101 62 | } 63 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/powershell_providers/database/drop.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $cookbookName = Get-NewResource cookbook_name 24 | $resourceName = Get-NewResource resource_name 25 | $dbName = Get-NewResource name 26 | $nodePath = $cookbookName,$resourceName,$dbName 27 | $serverName = Get-NewResource server_name 28 | 29 | # check if database exists before restoring. 30 | if (!(Get-ChefNode ($nodePath + "exists"))) 31 | { 32 | Write-Warning "Not dropping ""$dbName"" because it does not exist." 33 | exit 0 34 | } 35 | 36 | # connect to server. 37 | $server = New-Object ("Microsoft.SqlServer.Management.Smo.Server") $serverName 38 | 39 | # intentionally fail if asked to drop a system database. 40 | $db = $server.Databases | where { !$_.IsSystemObject_ -and ($_.Name -eq $dbName) } 41 | if ($db) 42 | { 43 | $Error.Clear() 44 | $db.Drop() 45 | if ($Error.Count -eq 0) 46 | { 47 | Write-Output "Dropped database named ""$dbName""" 48 | Set-ChefNode ($nodePath + "exists") $False 49 | Set-NewResource updated $True 50 | exit 0 51 | } 52 | else 53 | { 54 | Write-Error 'Failed to drop ""$dbName.ToString()"" because ""$Error.ToString()""' 55 | exit 100 56 | } 57 | } 58 | else 59 | { 60 | Write-Error "Failed to find a non-system database named ""$dbName""" 61 | exit 101 62 | } 63 | -------------------------------------------------------------------------------- /cookbooks/aws/powershell_providers/elb/deregister.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $accessKeyID = Get-NewResource access_key_id 24 | $secretAccessKey = Get-NewResource secret_access_key 25 | $elbName = Get-NewResource elb_name 26 | 27 | #stop and fail script when a command fails 28 | $ErrorActionPreference="Stop" 29 | 30 | $elb_config = New-Object -TypeName Amazon.ElasticLoadBalancing.AmazonElasticLoadBalancingConfig 31 | 32 | $az = $env:EC2_PLACEMENT_AVAILABILITY_ZONE 33 | $region = $az.substring(0,$az.length-1) 34 | 35 | Write-Output "*** Instance is in region: [$region]" 36 | 37 | $elb_config.WithServiceURL("https://elasticloadbalancing."+$region+".amazonaws.com") 38 | 39 | #create elb client base on the ServiceURL(region) 40 | $client_elb=[Amazon.AWSClientFactory]::CreateAmazonElasticLoadBalancingClient($accessKeyID,$secretAccessKey,$elb_config) 41 | 42 | $elb_deregister_request = New-Object -TypeName Amazon.ElasticLoadBalancing.Model.DeregisterInstancesFromLoadBalancerRequest 43 | 44 | $instance_object=New-Object -TypeName Amazon.ElasticLoadBalancing.Model.Instance 45 | $instance_object.InstanceId=$env:EC2_INSTANCE_ID 46 | 47 | $elb_deregister_request.WithLoadBalancerName($elbName) 48 | $elb_deregister_request.WithInstances($instance_object) 49 | 50 | $elb_register_response=$client_elb.DeregisterInstancesFromLoadBalancer($elb_deregister_request) 51 | 52 | write-output $elb_register_response -------------------------------------------------------------------------------- /cookbooks/blog_engine/powershell_providers/database/run_command.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $dbName = Get-NewResource name 24 | $commands = Get-NewResource commands 25 | $serverName = Get-NewResource server_name 26 | 27 | #check inputs. 28 | $Error.Clear() 29 | if (($dbName -eq $Null) -or ($dbName -eq "")) 30 | { 31 | Write-Error "Invalid or missing database name". 32 | exit 100 33 | } 34 | if (($commands -eq $Null) -or ($commands.Count -eq 0)) 35 | { 36 | Write-Error "No SQL commands provided in resource". 37 | exit 101 38 | } 39 | if (($serverName -eq $Null) -or ($serverName -eq "")) 40 | { 41 | Write-Error "Invalid or missing server name". 42 | exit 102 43 | } 44 | if (0 -ne $Error.Count) 45 | { 46 | exit 103 47 | } 48 | 49 | # client connection. 50 | $sqlClient = new-object System.Data.SqlClient.SqlConnection "server=$serverName;database=$dbName;trusted_connection=true;" 51 | $sqlClient.Open() 52 | if (0 -ne $Error.Count) 53 | { 54 | exit 104 55 | } 56 | 57 | $sqlCommand = New-Object System.Data.SQLClient.SQLCommand 58 | $sqlCommand.Connection = $sqlClient 59 | $result = $True 60 | foreach ($command in $commands) 61 | { 62 | Write-Verbose "Executing ""$command""" 63 | $sqlCommand.CommandText = $command 64 | $rowCount = $sqlCommand.ExecuteNonQuery() 65 | if ($rowCount -ge 0) 66 | { 67 | Write-Verbose "Rows affected = $rowCount" 68 | } 69 | if (0 -ne $Error.Count) 70 | { 71 | $result = $False 72 | break 73 | } 74 | } 75 | $sqlClient.Close() 76 | 77 | if (!$result) 78 | { 79 | exit 105 80 | } 81 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/powershell_providers/database/run_command.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $dbName = Get-NewResource name 24 | $commands = Get-NewResource commands 25 | $serverName = Get-NewResource server_name 26 | 27 | #check inputs. 28 | $Error.Clear() 29 | if (($dbName -eq $Null) -or ($dbName -eq "")) 30 | { 31 | Write-Error "Invalid or missing database name". 32 | exit 100 33 | } 34 | if (($commands -eq $Null) -or ($commands.Count -eq 0)) 35 | { 36 | Write-Error "No SQL commands provided in resource". 37 | exit 101 38 | } 39 | if (($serverName -eq $Null) -or ($serverName -eq "")) 40 | { 41 | Write-Error "Invalid or missing server name". 42 | exit 102 43 | } 44 | if (0 -ne $Error.Count) 45 | { 46 | exit 103 47 | } 48 | 49 | # client connection. 50 | $sqlClient = new-object System.Data.SqlClient.SqlConnection "server=$serverName;database=$dbName;trusted_connection=true;" 51 | $sqlClient.Open() 52 | if (0 -ne $Error.Count) 53 | { 54 | exit 104 55 | } 56 | 57 | $sqlCommand = New-Object System.Data.SQLClient.SQLCommand 58 | $sqlCommand.Connection = $sqlClient 59 | $result = $True 60 | foreach ($command in $commands) 61 | { 62 | Write-Verbose "Executing ""$command""" 63 | $sqlCommand.CommandText = $command 64 | $rowCount = $sqlCommand.ExecuteNonQuery() 65 | if ($rowCount -ge 0) 66 | { 67 | Write-Verbose "Rows affected = $rowCount" 68 | } 69 | if (0 -ne $Error.Count) 70 | { 71 | $result = $False 72 | break 73 | } 74 | } 75 | $sqlClient.Close() 76 | 77 | if (!$result) 78 | { 79 | exit 105 80 | } 81 | -------------------------------------------------------------------------------- /cookbooks/code_checkout/powershell_providers/package/unpack.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $packagePath = Get-NewResource package_path 24 | $releasesPath = Get-NewResource releases_path 25 | 26 | #check inputs. 27 | $Error.Clear() 28 | if (($packagePath -eq $NULL) -or ($packagePath -eq "")) 29 | { 30 | Write-Error "Error: provider requires 'package_path' parameter to be set! Ex: 'c:\\tmp\\app.zip'" 31 | exit 141 32 | } 33 | if (($releasesPath -eq $NULL) -or ($releasesPath -eq "")) 34 | { 35 | Write-Error "Error: provider requires 'root_path' parameter to be set! Ex: 'c:\\inetpub'" 36 | exit 142 37 | } 38 | 39 | #tell the script to "stop" or "continue" when a command fails 40 | $ErrorActionPreference = "stop" 41 | 42 | $releasesPath = Join-Path $releasesPath "" 43 | 44 | if (!(Test-Path $releasesPath)) { 45 | Write-Output "Creating directory: $releasesPath" 46 | New-Item $releasesPath -type directory 47 | } 48 | 49 | $deploy_date = $(get-date -uformat "%Y%m%d%H%M%S") 50 | $deploy_path = Join-Path $releasesPath $deploy_date 51 | 52 | if (!(test-path $packagePath)) 53 | { 54 | Write-Error "Error: [$packagePath] does not exist. Aborting!" 55 | exit 143 56 | } 57 | 58 | Write-Output "Unzpacking [$packagePath] to [$deploy_path]" 59 | 60 | $command='cmd /c 7z x -y "'+$packagePath+'" -o"'+$deploy_path+'""' 61 | 62 | $command_ouput=invoke-expression $command 63 | 64 | if ($command_ouput -match 'Everything is Ok') 65 | { 66 | Set-ChefNode releasesunpackpath $deploy_path 67 | } 68 | else 69 | { 70 | echo $command_ouput 71 | Write-Error "Error: Unzipping failed" 72 | exit 144 73 | } 74 | 75 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/recipes/import_dump_from_s3.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: db_sqlserver 2 | # Recipe:: import_dump_from_s3 3 | # 4 | # Copyright (c) 2010 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | if (@node[:db_sqlserver_import_dump_from_s3_executed]) 26 | Chef::Log.info("*** Recipe 'db_sqlserver::default' already executed, skipping...") 27 | else 28 | # download the sql dump 29 | aws_s3 "Download SqlServer dump from S3 bucket" do 30 | access_key_id @node[:aws][:access_key_id] 31 | secret_access_key @node[:aws][:secret_access_key] 32 | s3_bucket @node[:s3][:bucket_dump] 33 | s3_file @node[:s3][:file_dump] 34 | download_dir "c:/tmp" 35 | action :get 36 | end 37 | 38 | sql_dump=@node[:s3][:file_dump] 39 | 40 | # unpack the dump file. Example: mydump.sql.zip 41 | if (@node[:s3][:file_dump] =~ /(.*)\.(zip|7z|rar)/) 42 | sql_dump=$1 43 | Chef::Log.info("*** Unpacking database dump.") 44 | powershell "Unpacking "+@node[:s3][:file_dump] do 45 | parameters({'PACKAGE' => @node[:s3][:file_dump]}) 46 | # Create the powershell script 47 | powershell_script = <<'POWERSHELL_SCRIPT' 48 | cd c:/tmp 49 | cmd /c 7z x -y "c:/tmp/${env:PACKAGE}" 50 | POWERSHELL_SCRIPT 51 | source(powershell_script) 52 | end 53 | end 54 | 55 | # load the initial demo database from deployed SQL script. 56 | # no schema provided for this import call 57 | db_sqlserver_database "noschemayet" do 58 | server_name @node[:db_sqlserver][:server_name] 59 | script_path "c:/tmp/"+sql_dump 60 | action :run_script 61 | end 62 | 63 | @node[:db_sqlserver_import_dump_from_s3_executed] = true 64 | end -------------------------------------------------------------------------------- /cookbooks/aws/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "RightScale, Inc." 2 | maintainer_email "support@rightscale.com" 3 | license IO.read(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'LICENSE'))) 4 | description "Amazon Web Services recipes and providers for Windows" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 6 | version "0.1.5" 7 | 8 | 9 | recipe "aws::default", "Install Amazon Web Services SDK for .NET" 10 | recipe "aws::register_with_elb", "Register the instance with an Elastic Load Balancer created in the same ec2 region. Requires recipe: 'aws::default'" 11 | recipe "aws::deregister_from_elb", "Deregister the instance with an Elastic Load Balancer created in the same ec2 region. Requires recipe: 'aws::default'" 12 | recipe "aws::download", "Retrieves a file from an S3 bucket" 13 | recipe "aws::upload", "Uploads a file to an S3 bucket" 14 | 15 | 16 | attribute "aws/access_key_id", 17 | :display_name => "Access Key Id", 18 | :description => "This is an Amazon credential. Log in to your AWS account at aws.amazon.com to retrieve you access identifiers. Ex: 1JHQQ4KVEVM02KVEVM02", 19 | :recipes => ["aws::register_with_elb", "aws::deregister_from_elb", "aws::download", "aws::upload"], 20 | :required => "required" 21 | 22 | attribute "aws/secret_access_key", 23 | :display_name => "Secret Access Key", 24 | :description => "This is an Amazon credential. Log in to your AWS account at aws.amazon.com to retrieve your access identifiers. Ex: XVdxPgOM4auGcMlPz61IZGotpr9LzzI07tT8s2Ws", 25 | :recipes => ["aws::register_with_elb", "aws::deregister_from_elb", "aws::download", "aws::upload"], 26 | :required => "required" 27 | 28 | attribute "aws/elb_name", 29 | :display_name => "ELB Name", 30 | :description => "The name of the Elastic Load Balancer to register/deregister the instance with. (e.g., production-elb). The ELB needs to be created and configured prior to the execution of the recipe.", 31 | :recipes => ["aws::register_with_elb", "aws::deregister_from_elb"], 32 | :required => "required" 33 | 34 | attribute "aws/file_path", 35 | :display_name => "File Path", 36 | :description => "The full path to the file to be uploaded. Ex: c:\\tmp\\my.txt", 37 | :recipes => ["aws::upload"], 38 | :required => "required" 39 | 40 | attribute "s3/file", 41 | :display_name => "File", 42 | :description => "File to be retrieved from the s3 bucket. Ex: app.zip", 43 | :recipes => ["aws::download"], 44 | :required => "required" 45 | 46 | attribute "s3/bucket", 47 | :display_name => "Bucket", 48 | :description => "The name of the S3 bucket", 49 | :recipes => ["aws::download", "aws::upload"], 50 | :required => "required" 51 | 52 | attribute "aws/download_dir", 53 | :display_name => "Download Dir", 54 | :description => "The directory where the file from s3 will be downloaded. Ex: c:\\tmp\\", 55 | :recipes => ["aws::download"], 56 | :required => "required" 57 | -------------------------------------------------------------------------------- /cookbooks/aws/powershell_providers/elb/register.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $accessKeyID = Get-NewResource access_key_id 24 | $secretAccessKey = Get-NewResource secret_access_key 25 | $elbName = Get-NewResource elb_name 26 | 27 | #stop and fail script when a command fails 28 | $ErrorActionPreference="Stop" 29 | 30 | $elb_config = New-Object -TypeName Amazon.ElasticLoadBalancing.AmazonElasticLoadBalancingConfig 31 | 32 | $az = $env:EC2_PLACEMENT_AVAILABILITY_ZONE 33 | $region = $az.substring(0,$az.length-1) 34 | 35 | Write-Output "*** Instance is in region: [$region]" 36 | 37 | $elb_config.WithServiceURL("https://elasticloadbalancing."+$region+".amazonaws.com") 38 | 39 | #create elb client base on the ServiceURL(region) 40 | $client_elb=[Amazon.AWSClientFactory]::CreateAmazonElasticLoadBalancingClient($accessKeyID,$secretAccessKey,$elb_config) 41 | 42 | 43 | #Enable the availability zone with the load balancer 44 | $elb_enable_az_request = New-Object -TypeName Amazon.ElasticLoadBalancing.Model.EnableAvailabilityZonesForLoadBalancerRequest 45 | 46 | $elb_enable_az_request.WithAvailabilityZones($az) 47 | $elb_enable_az_request.WithLoadBalancerName($elbName) 48 | 49 | $elb_enable_az_response=$client_elb.EnableAvailabilityZonesForLoadBalancer($elb_enable_az_request) 50 | 51 | #register instance with the ELB 52 | $elb_register_request = New-Object -TypeName Amazon.ElasticLoadBalancing.Model.RegisterInstancesWithLoadBalancerRequest 53 | 54 | $instance_object=New-Object -TypeName Amazon.ElasticLoadBalancing.Model.Instance 55 | $instance_object.InstanceId=$env:EC2_INSTANCE_ID 56 | 57 | $elb_register_request.WithLoadBalancerName($elbName) 58 | $elb_register_request.WithInstances($instance_object) 59 | 60 | $elb_register_response=$client_elb.RegisterInstancesWithLoadBalancer($elb_register_request) 61 | 62 | 63 | -------------------------------------------------------------------------------- /cookbooks/blog_engine/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "RightScale, Inc." 2 | maintainer_email "support@rightscale.com" 3 | license IO.read(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'LICENSE'))) 4 | description "Install and configure the BlogEngine application, see http://www.dotnetblogengine.net" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 6 | version "0.3.15" 7 | 8 | depends 'utilities' 9 | depends 'sys_monitoring' 10 | 11 | recipe 'blog_engine::default', 'Loads the database and installs the BlogEngine application as the default IIS site' 12 | recipe "blog_engine::backup_database", "Backs up the BlogEngine database to a local machine directory." 13 | recipe "blog_engine::restore_database", "Restores the BlogEngine database from a local machine directory." 14 | recipe "blog_engine::drop_database", "Drops the BlogEngine database." 15 | recipe "blog_engine::add_monitors", "Adds monitors for BlogEngine demo." 16 | 17 | attribute 'utilities/admin_password', 18 | :display_name => 'New administrator password', 19 | :description => 'New administrator password', 20 | :recipes => ["blog_engine::default"], 21 | :required => "required" 22 | 23 | attribute "db_sqlserver/server_name", 24 | :display_name => "SQL Server instance network name", 25 | :description => "The network name of the SQL Server instance used by recipes. Ex: localhost\SQLEXPRESS", 26 | :default => "localhost\\SQLEXPRESS", 27 | :recipes => ["blog_engine::default", "blog_engine::backup_database", "blog_engine::restore_database", "blog_engine::drop_database"] 28 | 29 | attribute "db_sqlserver/backup/database_backup_dir", 30 | :display_name => "SQL Server backup .bak directory", 31 | :description => "The local drive path or UNC path to the directory which will contain new SQL Server database backup (.bak) files. Note that network drives are not supported by SQL Server.", 32 | :default => "c:\\datastore\\sqlserver\\databases", 33 | :recipes => ["blog_engine::backup_database", "blog_engine::restore_database"] 34 | 35 | attribute "db_sqlserver/backup/backup_file_name_format", 36 | :display_name => "Backup file name format", 37 | :description => "Format string with Powershell-style string format arguments for creating backup files. The 0 argument represents the database name and the 1 argument represents a generated time stamp.", 38 | :default => "{0}_{1}.bak", 39 | :recipes => ["blog_engine::default", "blog_engine::backup_database", "blog_engine::restore_database"] 40 | 41 | attribute "db_sqlserver/backup/existing_backup_file_name_pattern", 42 | :display_name => "Pattern matching backup file names", 43 | :description => "Wildcard file matching pattern (i.e. not a Regex) with Powershell-style string format arguments for finding backup files. The 0 argument represents the database name and the rest of the pattern should match the file names generated from the backup_file_name_format.", 44 | :default => "{0}_*.bak", 45 | :recipes => ["blog_engine::default", "blog_engine::backup_database", "blog_engine::restore_database"] 46 | -------------------------------------------------------------------------------- /cookbooks/app_iis/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "RightScale, Inc." 2 | maintainer_email "support@rightscale.com" 3 | license IO.read(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'LICENSE'))) 4 | description "IIS recipes" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 6 | version "0.0.5" 7 | 8 | depends 'aws' 9 | 10 | recipe "app_iis::default", "Calls app_iis::update_code_svn" 11 | recipe "app_iis::update_code_svn", "Retrieves code from SVN then sets up website." 12 | recipe "app_iis::update_code_s3", "Retrieves code from s3 then sets up website." 13 | recipe "app_iis::start_default_website", "Starts the website named 'Default Web Site' if it is not already running" 14 | 15 | attribute "svn/repo_path", 16 | :display_name => "SVN Repo Path", 17 | :description => "The URL of your SVN repository where your application code will be checked out from. Ex: http://mysvn.net/app/", 18 | :recipes => ["app_iis::update_code_svn"], 19 | :required => "required" 20 | 21 | attribute "svn/username", 22 | :display_name => "SVN Username", 23 | :description => "The SVN username that is used to checkout the application code from SVN repository", 24 | :recipes => ["app_iis::update_code_svn"], 25 | :required => "optional", 26 | :default => "" 27 | 28 | attribute "svn/password", 29 | :display_name => "SVN Password", 30 | :description => "The SVN password that is used to checkout the application code from SVN repository.", 31 | :recipes => ["app_iis::update_code_svn"], 32 | :required => "optional", 33 | :default => "" 34 | 35 | attribute "svn/force_checkout", 36 | :display_name => "SVN Force Checkout", 37 | :description => "A value of 'false' will attempt an svn update where 'true' will do a full checkout", 38 | :recipes => ["app_iis::update_code_svn"], 39 | :choice => ['true', 'false'], 40 | :required => "required" 41 | 42 | 43 | attribute "aws/access_key_id", 44 | :display_name => "Access Key Id", 45 | :description => "This is an Amazon credential. Log in to your AWS account at aws.amazon.com to retrieve you access identifiers. Ex: 1JHQQ4KVEVM02KVEVM02", 46 | :recipes => ["app_iis::update_code_s3"], 47 | :required => "required" 48 | 49 | attribute "aws/secret_access_key", 50 | :display_name => "Secret Access Key", 51 | :description => "This is an Amazon credential. Log in to your AWS account at aws.amazon.com to retrieve your access identifiers. Ex: XVdxPgOM4auGcMlPz61IZGotpr9LzzI07tT8s2Ws", 52 | :recipes => ["app_iis::update_code_s3"], 53 | :required => "required" 54 | 55 | attribute "s3/application_code_package", 56 | :display_name => "Application Package", 57 | :description => "The name of the application package that can be retrieved from the S3 bucket. Ex: productioncode.zip", 58 | :recipes => ["app_iis::update_code_s3"], 59 | :required => "required" 60 | 61 | attribute "s3/application_code_bucket", 62 | :display_name => "Application Bucket", 63 | :description => "The S3 bucket, where the application can be retrieved. Ex: production-code-bucket", 64 | :recipes => ["app_iis::update_code_s3"], 65 | :required => "required" 66 | -------------------------------------------------------------------------------- /cookbooks/app_iis/recipes/update_code_svn.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: app_iis 2 | # Recipe:: update_code_svn 3 | # 4 | # Copyright (c) 2010 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | # Checkout code in c:\inetpub\releases 26 | code_checkout_svn @node[:svn][:repo_path] do 27 | releases_path "c:/inetpub/releases" 28 | svn_username @node[:svn][:username] 29 | svn_password @node[:svn][:password] 30 | force_checkout @node[:svn][:force_checkout] == 'true' 31 | action :checkout 32 | end 33 | 34 | powershell "Change IIS physical path for Default Website" do 35 | # Create the powershell script 36 | powershell_script = <<'POWERSHELL_SCRIPT' 37 | #tell the script to "stop" or "continue" when a command fails 38 | $ErrorActionPreference = "stop" 39 | 40 | $checkoutpath=invoke-expression 'Get-ChefNode checkoutpath' 41 | 42 | if (Test-Path $checkoutpath -PathType Container) 43 | { 44 | 45 | # change the physicalPath for the IIS site 46 | $appcmd_path = $env:systemroot + "\\system32\\inetsrv\\APPCMD.exe" 47 | if (Test-Path $appcmd_path) 48 | { 49 | &$appcmd_path set SITE "Default Web Site" "/[path='/'].[path='/'].physicalPath:$checkoutpath" 50 | } 51 | else 52 | { 53 | Write-Output "APPCMD.EXE is missing, probably 2003 image. Trying ADSI" 54 | 55 | $siteName = "Default Web Site" 56 | $iis = [ADSI]"IIS://localhost/W3SVC" 57 | $site = $iis.psbase.children | where { $_.keyType -eq "IIsWebServer" -AND $_.ServerComment -eq $siteName } 58 | $path = [ADSI]($site.psbase.path+"/ROOT") 59 | $path.psbase.properties.path[0] = $checkoutpath 60 | #DefaultDoc cannot be configured in web.config for IIS6 61 | $path.psbase.properties.DefaultDoc[0]="default.aspx,index.aspx,Default.htm,Default.asp,index.html,index.htm,iisstart.htm,index.php" 62 | $path.psbase.CommitChanges() 63 | } 64 | } 65 | else 66 | { 67 | Write-Error "Error: Invalid physical path [$checkoutpath]" 68 | exit 135 69 | } 70 | POWERSHELL_SCRIPT 71 | 72 | source(powershell_script) 73 | end 74 | -------------------------------------------------------------------------------- /cookbooks/app_ad/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "providing": { 3 | }, 4 | "description": "ActiveDirectory recipes", 5 | "replacing": { 6 | }, 7 | "groupings": { 8 | }, 9 | "attributes": { 10 | "ad/admin_password": { 11 | "required": "required", 12 | "calculated": false, 13 | "choice": [ 14 | 15 | ], 16 | "type": "string", 17 | "recipes": [ 18 | "app_ad::join" 19 | ], 20 | "display_name": "Domain administrator password", 21 | "description": "Password of domain account used to add computers to the domain" 22 | }, 23 | "ad/user_password": { 24 | "required": "required", 25 | "calculated": false, 26 | "choice": [ 27 | 28 | ], 29 | "type": "string", 30 | "recipes": [ 31 | "app_ad::add_user", 32 | "app_ad::remote_add_user" 33 | ], 34 | "display_name": "Application password", 35 | "description": "New Active Directory domain account password" 36 | }, 37 | "ad/domain": { 38 | "required": "required", 39 | "calculated": false, 40 | "choice": [ 41 | 42 | ], 43 | "type": "string", 44 | "recipes": [ 45 | "app_ad::add_user", 46 | "app_ad::remote_add_user", 47 | "app_ad::join" 48 | ], 49 | "display_name": "Domain name", 50 | "description": "Active Directory domain name" 51 | }, 52 | "ad/admin_username": { 53 | "required": "required", 54 | "calculated": false, 55 | "choice": [ 56 | 57 | ], 58 | "type": "string", 59 | "recipes": [ 60 | "app_ad::join" 61 | ], 62 | "display_name": "Domain administrator username", 63 | "description": "Username of domain account used to add computers to domain" 64 | }, 65 | "ad/user_username": { 66 | "required": "required", 67 | "calculated": false, 68 | "choice": [ 69 | 70 | ], 71 | "type": "string", 72 | "recipes": [ 73 | "app_ad::add_user", 74 | "app_ad::remote_add_user" 75 | ], 76 | "display_name": "Application username", 77 | "description": "New Active Directory domain account username" 78 | } 79 | }, 80 | "long_description": "", 81 | "recipes": { 82 | "app_ad::setup_controller": "Sets up domain controller tag", 83 | "app_ad::join": "Join instance to domain", 84 | "app_ad::remote_add_user": "Creates a new Active Directory user account, can be run anywhere", 85 | "app_ad::add_user": "Creates a new Active Directory user account, must be run on Domain Controller", 86 | "app_ad::set_dns_server": "Set DNS server entries" 87 | }, 88 | "recommendations": { 89 | }, 90 | "dependencies": { 91 | }, 92 | "maintainer": "Your Name", 93 | "suggestions": { 94 | }, 95 | "platforms": { 96 | }, 97 | "name": "app_ad", 98 | "version": "0.0.1", 99 | "license": "Apache v2.0", 100 | "maintainer_email": "youremail@example.com", 101 | "conflicting": { 102 | } 103 | } -------------------------------------------------------------------------------- /cookbooks/blog_engine/recipes/default.rb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | unless @node[:blog_engine_default_executed] 23 | 24 | include_recipe 'utilities::change_admin_password' 25 | include_recipe 'sys_monitoring::default' 26 | include_recipe 'db_sqlserver::enable_sql_service' 27 | 28 | # deploy web app zips to the wwwroot directory. 29 | powershell "Deploy demo web app from cookbook-relative zipped source to wwwroot under IIS" do 30 | seven_zip_exe_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'files', 'default', 'bin', '7z.exe')) 31 | web_app_src_zips = File.expand_path(File.join(File.dirname(__FILE__), '..', 'files', 'default', 'app')) 32 | parameters('WEB_APP_ZIP_DIR_PATH' => web_app_src_zips, 33 | 'CHECK_FOR_EXISTENCE' => 'true', 34 | 'SEVEN_ZIP_EXE_PATH' => seven_zip_exe_path) 35 | 36 | source_file_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'files', 'default', 'simple_app_deploy.ps1')) 37 | source_path(source_file_path) 38 | end 39 | 40 | # load the demo database from deployed SQL script. 41 | blog_engine_database "master" do 42 | server_name @node[:db_sqlserver][:server_name] 43 | commands ["CREATE DATABASE [BlogEngine]"] 44 | action :run_command 45 | end 46 | 47 | # load the initial demo database from deployed SQL script. 48 | blog_engine_database "BlogEngine" do 49 | server_name @node[:db_sqlserver][:server_name] 50 | script_path "c:\\inetpub\\wwwroot\\setup\\SQLServer\\MSSQLSetup1.5.0.0.sql" 51 | action :run_script 52 | end 53 | 54 | # load the initial demo database from deployed SQL script. 55 | blog_engine_database "BlogEngine" do 56 | server_name @node[:db_sqlserver][:server_name] 57 | commands ["CREATE USER [NetworkService] FOR LOGIN [NT AUTHORITY\\NETWORK SERVICE]", 58 | "EXEC sp_addrolemember 'db_datareader', 'NetworkService'", 59 | "EXEC sp_addrolemember 'db_datawriter', 'NetworkService'"] 60 | action :run_command 61 | end 62 | 63 | include_recipe 'app_iis::start_default_website' 64 | 65 | @node[:blog_engine_default_executed] = true 66 | end 67 | -------------------------------------------------------------------------------- /cookbooks/app_iis/recipes/update_code_s3.rb: -------------------------------------------------------------------------------- 1 | # Cookbook Name:: app_iis 2 | # Recipe:: update_code_s3 3 | # 4 | # Copyright (c) 2010 RightScale Inc 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining 7 | # a copy of this software and associated documentation files (the 8 | # "Software"), to deal in the Software without restriction, including 9 | # without limitation the rights to use, copy, modify, merge, publish, 10 | # distribute, sublicense, and/or sell copies of the Software, and to 11 | # permit persons to whom the Software is furnished to do so, subject to 12 | # the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be 15 | # included in all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | # download the sql dump 26 | aws_s3 "Download code from S3 bucket" do 27 | access_key_id @node[:aws][:access_key_id] 28 | secret_access_key @node[:aws][:secret_access_key] 29 | s3_bucket @node[:s3][:application_code_bucket] 30 | s3_file @node[:s3][:application_code_package] 31 | download_dir "c:/tmp" 32 | action :get 33 | end 34 | 35 | 36 | # Unpack code in c:\inetpub\releases 37 | code_checkout_package "Unpacking code in the releases directory" do 38 | releases_path "c:/inetpub/releases" 39 | package_path "c:/tmp/"+@node[:s3][:application_code_package] 40 | action :unpack 41 | end 42 | 43 | 44 | powershell "Change IIS physical path for Default Website" do 45 | # Create the powershell script 46 | powershell_script = <<'POWERSHELL_SCRIPT' 47 | #tell the script to "stop" or "continue" when a command fails 48 | $ErrorActionPreference = "stop" 49 | 50 | $releasesunpackpath=invoke-expression 'Get-ChefNode releasesunpackpath' 51 | 52 | if (Test-Path $releasesunpackpath -PathType Container) 53 | { 54 | 55 | # change the physicalPath for the IIS site 56 | $appcmd_path = $env:systemroot + "\\system32\\inetsrv\\APPCMD.exe" 57 | if (Test-Path $appcmd_path) 58 | { 59 | &$appcmd_path set SITE "Default Web Site" "/[path='/'].[path='/'].physicalPath:$releasesunpackpath" 60 | } 61 | else 62 | { 63 | Write-Output "APPCMD.EXE is missing, probably 2003 image. Trying ADSI" 64 | 65 | $siteName = "Default Web Site" 66 | $iis = [ADSI]"IIS://localhost/W3SVC" 67 | $site = $iis.psbase.children | where { $_.keyType -eq "IIsWebServer" -AND $_.ServerComment -eq $siteName } 68 | $path = [ADSI]($site.psbase.path+"/ROOT") 69 | $path.psbase.properties.path[0] = $releasesunpackpath 70 | #DefaultDoc cannot be configured in web.config for IIS6 71 | $path.psbase.properties.DefaultDoc[0]="default.aspx,index.aspx,Default.htm,Default.asp,index.html,index.htm,iisstart.htm,index.php" 72 | $path.psbase.CommitChanges() 73 | } 74 | } 75 | else 76 | { 77 | Write-Error "Error: Invalid physical path [$releasesunpackpath]" 78 | exit 135 79 | } 80 | POWERSHELL_SCRIPT 81 | 82 | source(powershell_script) 83 | end 84 | -------------------------------------------------------------------------------- /cookbooks/aws/powershell_providers/s3/get.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $accessKeyID = Get-NewResource access_key_id 24 | $secretAccessKey = Get-NewResource secret_access_key 25 | $s3Bucket = Get-NewResource s3_bucket 26 | $s3File = Get-NewResource s3_file 27 | $downloadDir = Get-NewResource download_dir 28 | 29 | #stop and fail script when a command fails 30 | #$ErrorActionPreference="Stop" 31 | 32 | #check inputs. 33 | $Error.Clear() 34 | if (($s3Bucket -eq $NULL) -or ($s3Bucket -eq "")) 35 | { 36 | Write-Error "***Error: provider requires 's3_bucket' parameter to be set!" 37 | exit 112 38 | } 39 | if (($s3File -eq $NULL) -or ($s3File -eq "")) 40 | { 41 | Write-Error "***Error: provider requires 's3_file' parameter to be set!" 42 | exit 113 43 | } 44 | if (($downloadDir -eq $NULL) -or ($downloadDir -eq "")) 45 | { 46 | Write-Error "***Error: provider requires 'download_dir' parameter to be set!" 47 | exit 114 48 | } 49 | if (($accessKeyID -eq $NULL) -or ($accessKeyID -eq "")) 50 | { 51 | Write-Error "***Error: provider requires 'access_key_id' parameter to be set!" 52 | exit 115 53 | } 54 | if (($secretAccessKey -eq $NULL) -or ($secretAccessKey -eq "")) 55 | { 56 | Write-Error "***Error: provider requires 'secret_access_key' parameter to be set!" 57 | exit 116 58 | } 59 | 60 | $client=[Amazon.AWSClientFactory]::CreateAmazonS3Client($accessKeyID,$secretAccessKey) 61 | 62 | if (!(Test-Path $downloadDir)) 63 | { 64 | Write-output "***Directory [$downloadDir] missing, creating it." 65 | New-Item $downloadDir -type directory 66 | } 67 | 68 | $targetpath = join-path ($downloadDir) $s3File 69 | Write-output "***Downloading key[$s3File] from bucket[$s3Bucket] to [$targetpath]" 70 | 71 | $get_request = New-Object -TypeName Amazon.S3.Model.GetObjectRequest 72 | $get_request.BucketName = $s3Bucket 73 | $get_request.key = $s3File 74 | 75 | $S3Response = $client.GetObject($get_request) #NOTE: download defaults to ... minute timeout. 76 | #If download fails it will throw an exception and $S3Response will be $null 77 | if($S3Response -eq $null){ 78 | Write-Error "***ERROR: Amazon S3 get requrest failed. Script halted." 79 | exit 1 80 | } 81 | 82 | $responsestream=$S3Response.ResponseStream 83 | 84 | # create the target file on the local system and the download buffer 85 | $targetfile = New-Object IO.FileStream ($targetpath,[IO.FileMode]::Create) 86 | [byte[]]$readbuffer = New-Object byte[] 1024 87 | 88 | # loop through the download stream and send the data to the target file 89 | do{ 90 | $readlength = $responsestream.Read($readbuffer,0,1024) 91 | $targetfile.Write($readbuffer,0,$readlength) 92 | } 93 | while ($readlength -ne 0) 94 | 95 | $targetfile.close() 96 | -------------------------------------------------------------------------------- /cookbooks/utilities/powershell_providers/scheduled_tasks/create.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $name = Get-NewResource name 24 | $username = Get-NewResource username 25 | $password = Get-NewResource password 26 | $command = Get-NewResource command 27 | 28 | $dailyTime = Get-NewResource daily_time 29 | $hourlyFrequency = Get-NewResource hourly_frequency 30 | 31 | # "Stop" or "Continue" the powershell script execution when a command fails 32 | $ErrorActionPreference = "Stop" 33 | 34 | #check inputs. 35 | $Error.Clear() 36 | if (($name -eq $NULL) -or ($name -eq "")) 37 | { 38 | Write-Error "Error: 'name' is a required attribute for the 'scheduled_tasks' provider. Aborting..." 39 | exit 131 40 | } 41 | if (($username -eq $NULL) -or ($username -eq "")) 42 | { 43 | Write-Error "Error: 'username' is a required attribute for the 'scheduled_tasks' provider. Aborting..." 44 | exit 132 45 | } 46 | if (($password -eq $NULL) -or ($password -eq "")) 47 | { 48 | Write-Error "Error: 'password' is a required attribute for the 'scheduled_tasks' provider. Aborting..." 49 | exit 133 50 | } 51 | if (($hourlyFrequency -eq $NULL) -or ($hourlyFrequency -eq "")) 52 | { 53 | Write-Error "Error: 'hourly_frequency' is a required attribute for the 'scheduled_tasks' provider. Aborting..." 54 | exit 134 55 | } 56 | 57 | #remove any characters that might brake the command 58 | $name = $name -replace '[^\w]', '' 59 | 60 | Write-Output "Converting hourly frequency [$hourlyFrequency] into an integer." 61 | $hourlyFrequency=[int]$hourlyFrequency 62 | 63 | if ((($dailyTime -eq $NULL) -or ($dailyTime -eq "")) -and ($hourly_frequency -eq 24)) 64 | { 65 | Write-Error "Error: 'daily_time' is a required attribute for the 'scheduled_tasks' provider when 'hourly_frequency=24'. Aborting..." 66 | exit 135 67 | } 68 | 69 | 70 | if ($hourlyFrequency -ge 1 -and $hourlyFrequency -le 23) 71 | { 72 | Write-Output "Setting task name [$name] with hourly frequency [$hourlyFrequency]" 73 | schtasks.exe /Create /F /SC HOURLY /MO $hourlyFrequency /RU $username /RP $password /TN $name /TR "$command" 74 | } 75 | elseif ($hourlyFrequency -eq 24) 76 | { 77 | if (!($dailyTime -match "^[0-2]\d:[0-5]\d$")) 78 | { 79 | Write-Error "Error: The 'daily_time' attribute[$dailyTime] is incorrect. Please use the 'hh:mm' format." 80 | exit 136 81 | } 82 | Write-Output "Setting task name [$name] daily at [$dailyTime]" 83 | schtasks.exe /Create /F /SC DAILY /ST $dailyTime /RU $username /RP $password /TN $name /TR "$command" 84 | } 85 | else 86 | { 87 | Write-Error "Error: Hourly frequency is not between 1 and 24, aborting..." 88 | exit 137 89 | } 90 | 91 | if (!$?) 92 | { 93 | Write-Error "Error: SCHTASKS execution failed." 94 | exit 138 95 | } 96 | 97 | #/Query /TN available only in 2008 98 | #schtasks.exe /Query /TN $name -------------------------------------------------------------------------------- /cookbooks/code_checkout/powershell_providers/svn/checkout.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $svnPath = Get-NewResource name 24 | $svnUsername = Get-NewResource svn_username 25 | $svnPassword = Get-NewResource svn_password 26 | 27 | $forceCheckout = Get-NewResource force_checkout 28 | $releasesPath = Get-NewResource releases_path 29 | 30 | #check inputs. 31 | $Error.Clear() 32 | if (($svnPath -eq $NULL) -or ($svnPath -eq "")) 33 | { 34 | Write-Error "Error: provider requires a 'name' parameter to be set! Ex: 'http://example.com/svn/trunk'" 35 | exit 131 36 | } 37 | if (($releasesPath -eq $NULL) -or ($releasesPath -eq "")) 38 | { 39 | Write-Error "Error: provider requires 'root_path' parameter to be set! Ex: 'c:\\inetpub'" 40 | exit 132 41 | } 42 | 43 | if ($svnUsername -eq $NULL) 44 | { 45 | $svnUsername="" 46 | } 47 | if ($svnPassword -eq $NULL) 48 | { 49 | $svnPassword="" 50 | } 51 | 52 | #tell the script to "stop" or "continue" when a command fails 53 | $ErrorActionPreference = "stop" 54 | 55 | $releasesPath = Join-Path $releasesPath "" 56 | 57 | if (!(Test-Path $releasesPath)) { 58 | Write-Output "Creating directory: $releasesPath" 59 | New-Item $releasesPath -type directory 60 | } 61 | 62 | $deploy_date = $(get-date -uformat "%Y%m%d%H%M%S") 63 | $deploy_path = Join-Path $releasesPath $deploy_date 64 | 65 | Write-Output "Creating new releases directory [$deploy_path]" 66 | 67 | $latest_release=Get-ChildItem $releasesPath | Sort-Object Name -descending | Select-Object Name | Select-Object -first 1 68 | if (($latest_release -eq $null) -or ($forceCheckout -eq "true")) 69 | { 70 | New-Item $deploy_path -type directory 71 | Write-Output "SVN checkout in [$deploy_path]" 72 | } 73 | else 74 | { 75 | $latest_release = Join-Path $releasesPath $latest_release.Name 76 | 77 | Write-Output "xcopy from [$latest_release] to [$deploy_path]" 78 | 79 | xcopy $latest_release $deploy_path /E /I /Q /H /K /Y 80 | 81 | if ($LastExitCode -eq 0) 82 | { 83 | Write-Output "SVN update in [$deploy_path]" 84 | } 85 | else 86 | { 87 | Write-Warning "xcopy failed, proceeding with a full checkout in [$deploy_path]" 88 | if (Test-Path $deploy_path) 89 | { 90 | Write-Output "Deleting directory [$deploy_path]" 91 | Remove-Item $deploy_path -r -force 92 | } 93 | Write-Output "Creating new releases directory [$deploy_path]" 94 | New-Item $deploy_path -type directory 95 | } 96 | } 97 | 98 | svn.cmd --quiet --non-interactive --no-auth-cache --username `"$svnUsername`" --password `"$svnPassword`" checkout $svnPath $deploy_path 99 | 100 | if ($LastExitCode -ne 0) 101 | { 102 | Write-Error "Error: SVN checkout failed" 103 | exit 133 104 | } 105 | else 106 | { 107 | Set-ChefNode checkoutpath $deploy_path 108 | } 109 | -------------------------------------------------------------------------------- /cookbooks/blog_engine/powershell_providers/database/_load_current_resource.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $cookbookName = Get-NewResource cookbook_name 24 | $resourceName = Get-NewResource resource_name 25 | $dbName = Get-NewResource name 26 | $nodePath = $cookbookName,$resourceName,$dbName 27 | $serverName = Get-NewResource server_name 28 | 29 | # initialize hash representing current state of database, if necessary. 30 | $dbData = Get-ChefNode $nodePath 31 | if ($dbData -eq $NULL) 32 | { 33 | $dbData = @{ exists = $False } 34 | Set-ChefNode $nodePath -HashValue $dbData 35 | Write-Verbose "Initialized ""$nodePath""" 36 | } 37 | else 38 | { 39 | Write-Warning "Skipping initialization of ""$nodePath""" 40 | exit 0 41 | } 42 | 43 | # connect to server. 44 | $server = New-Object ("Microsoft.SqlServer.Management.Smo.Server") $serverName 45 | 46 | # query for database by name to get current resource details. 47 | $Error.Clear() 48 | $db = $server.Databases | where { $_.name -eq $dbName } 49 | if ($Error.count -ne 0) 50 | { 51 | Write-Error "Failed to connect to ""$serverName""" 52 | exit 100 53 | } 54 | if ($db) 55 | { 56 | # set "exists". 57 | Set-ChefNode ($nodePath + "exists") $True 58 | 59 | # get the list of backup files applied to this server 60 | $command = "SELECT [bmf].[physical_device_name] AS restore_file_path 61 | FROM msdb..restorehistory rs 62 | INNER JOIN msdb..backupset bs ON [rs].[backup_set_id] = [bs].[backup_set_id] 63 | INNER JOIN msdb..backupmediafamily bmf ON [bs].[media_set_id] = [bmf].[media_set_id] 64 | WHERE rs.destination_database_name = '{0}'" -f $dbName 65 | 66 | $resultSet = $server.ConnectionContext.ExecuteWithResults($command) 67 | 68 | # build a hash of already-restored .bak file paths (for idempotency checks, 69 | # etc.) using the file name as the key and the full path as value. 70 | $restoreFilePaths = @{} 71 | foreach ($table in $resultSet.Tables) 72 | { 73 | foreach ($row in $table.Rows) 74 | { 75 | $restoreFilePath = $row.Item("restore_file_path") 76 | if ("$restoreFilePath" -ne "") 77 | { 78 | $restoreFileName = Split-Path -leaf $restoreFilePath 79 | if ("$restoreFileName" -ne "") 80 | { 81 | # hashes in powershell have case-insensitive keys, but the 82 | # equivalent hash in the Chef node will be case-sensitive so 83 | # use a lowercase key to make it possible to query the value 84 | # directly from the Chef node. 85 | $restoreFilePaths.($restoreFileName.ToLower()) = $restoreFilePath 86 | } 87 | } 88 | } 89 | } 90 | Set-ChefNode ($nodePath + "restore_file_paths") -HashValue $restoreFilePaths 91 | } 92 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/powershell_providers/database/_load_current_resource.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $cookbookName = Get-NewResource cookbook_name 24 | $resourceName = Get-NewResource resource_name 25 | $dbName = Get-NewResource name 26 | $nodePath = $cookbookName,$resourceName,$dbName 27 | $serverName = Get-NewResource server_name 28 | 29 | # initialize hash representing current state of database, if necessary. 30 | $dbData = Get-ChefNode $nodePath 31 | if ($dbData -eq $NULL) 32 | { 33 | $dbData = @{ exists = $False } 34 | Set-ChefNode $nodePath -HashValue $dbData 35 | Write-Verbose "Initialized ""$nodePath""" 36 | } 37 | else 38 | { 39 | Write-Warning "Skipping initialization of ""$nodePath""" 40 | exit 0 41 | } 42 | 43 | # connect to server. 44 | $server = New-Object ("Microsoft.SqlServer.Management.Smo.Server") $serverName 45 | 46 | # query for database by name to get current resource details. 47 | $Error.Clear() 48 | $db = $server.Databases | where { $_.name -eq $dbName } 49 | if ($Error.count -ne 0) 50 | { 51 | Write-Error "Failed to connect to ""$serverName""" 52 | exit 100 53 | } 54 | if ($db) 55 | { 56 | # set "exists". 57 | Set-ChefNode ($nodePath + "exists") $True 58 | 59 | # get the list of backup files applied to this server 60 | $command = "SELECT [bmf].[physical_device_name] AS restore_file_path 61 | FROM msdb..restorehistory rs 62 | INNER JOIN msdb..backupset bs ON [rs].[backup_set_id] = [bs].[backup_set_id] 63 | INNER JOIN msdb..backupmediafamily bmf ON [bs].[media_set_id] = [bmf].[media_set_id] 64 | WHERE rs.destination_database_name = '{0}'" -f $dbName 65 | 66 | $resultSet = $server.ConnectionContext.ExecuteWithResults($command) 67 | 68 | # build a hash of already-restored .bak file paths (for idempotency checks, 69 | # etc.) using the file name as the key and the full path as value. 70 | $restoreFilePaths = @{} 71 | foreach ($table in $resultSet.Tables) 72 | { 73 | foreach ($row in $table.Rows) 74 | { 75 | $restoreFilePath = $row.Item("restore_file_path") 76 | if ("$restoreFilePath" -ne "") 77 | { 78 | $restoreFileName = Split-Path -leaf $restoreFilePath 79 | if ("$restoreFileName" -ne "") 80 | { 81 | # hashes in powershell have case-insensitive keys, but the 82 | # equivalent hash in the Chef node will be case-sensitive so 83 | # use a lowercase key to make it possible to query the value 84 | # directly from the Chef node. 85 | $restoreFilePaths.($restoreFileName.ToLower()) = $restoreFilePath 86 | } 87 | } 88 | } 89 | } 90 | Set-ChefNode ($nodePath + "restore_file_paths") -HashValue $restoreFilePaths 91 | } 92 | -------------------------------------------------------------------------------- /cookbooks/blog_engine/powershell_providers/database/backup.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $cookbookName = Get-NewResource cookbook_name 24 | $resourceName = Get-NewResource resource_name 25 | $dbName = Get-NewResource name 26 | $nodePath = $cookbookName,$resourceName,$dbName 27 | $serverName = Get-NewResource server_name 28 | $backupDirPath = Get-NewResource backup_dir_path 29 | $existingBackupFileNamePattern = (Get-NewResource existing_backup_file_name_pattern) -f $dbName 30 | $backupFileNameFormat = Get-NewResource backup_file_name_format 31 | 32 | # check if database exists before backing up. 33 | if (!(Get-ChefNode ($nodePath + "exists"))) 34 | { 35 | Write-Warning "Not backing up ""$dbName"" because it does not exist." 36 | exit 0 37 | } 38 | 39 | # connect to server. 40 | $server = New-Object ("Microsoft.SqlServer.Management.Smo.Server") $serverName 41 | 42 | # force creation of backup directory or ignore if already exists. 43 | if (!(Test-Path $backupDirPath)) 44 | { 45 | md $backupDirPath | Out-Null 46 | } 47 | $backupDir = Get-Item $backupDirPath -ea Stop 48 | $backupDirPath = $backupDir.FullName 49 | Write-Verbose "Using backup directory ""$backupDirPath""" 50 | 51 | # rename existing .bak to .old after deleting existing .old files. 52 | # TODO: cleanup old backup files by some algorithm (allow 3 per database, older than 1 week, etc.) 53 | foreach ($oldBackupFile in $backupDir.GetFiles("*.old")) { del $oldBackupFile.FullName } 54 | foreach ($backupFile in $backupDir.GetFiles($backupFileNamePattern)) { ren $backupFile.FullName ($backupFile.Name + ".old") } 55 | 56 | # iterate user databases (ignoring system databases) and backup any found. 57 | $db = $server.Databases | where { !$_.IsSystemObject_ -and ($_.Name -eq $dbName) } 58 | if ($db) 59 | { 60 | $dbName = $db.Name 61 | $timestamp = Get-Date -format yyyyMMddHHmmss 62 | $backupFileName = $backupFileNameFormat -f $dbName, $timestamp 63 | $backupFilePath = $backupDirPath + "\" + $backupFileName 64 | 65 | $backup = New-Object ("Microsoft.SqlServer.Management.Smo.Backup") 66 | $backup.Action = "Database" # full databse backup. TODO: also backup the transaction log. 67 | $backup.BackupSetDescription = "Full backup of $dbName" 68 | $backup.BackupSetName = "$dbName backup" 69 | $backup.Database = $dbName 70 | $backup.MediaDescription = "Disk" 71 | $backup.LogTruncation = "Truncate" 72 | $backup.Devices.AddDevice($backupFilePath, "File") 73 | 74 | $Error.Clear() 75 | $backup.SqlBackup($server) 76 | if ($Error.Count -eq 0) 77 | { 78 | "Backed up database named ""$dbName"" to ""$backupFilePath""" 79 | } 80 | else 81 | { 82 | # report error but keep trying to backup additional databases. 83 | Write-Error "Failed to backup ""$dbName""" 84 | Write-Warning "SQL Server fails to backup/restore to/from network drives but will accept the equivalent UNC path so long as the database user has sufficient network privileges. Ensure that the SQL_BACKUP_DIR_PATH environment variable does not refer to a shared drive." 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /cookbooks/aws/powershell_providers/s3/put.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $accessKeyID = Get-NewResource access_key_id 24 | $secretAccessKey = Get-NewResource secret_access_key 25 | $s3Bucket = Get-NewResource s3_bucket 26 | $s3File = Get-NewResource s3_file 27 | $filePath = Get-NewResource file_path 28 | $timeoutSeconds = Get-NewResource timeout_seconds 29 | 30 | #stop and fail script when a command fails 31 | $ErrorActionPreference="Stop" 32 | 33 | #check inputs. 34 | $Error.Clear() 35 | if (($s3Bucket -eq $NULL) -or ($s3Bucket -eq "")) 36 | { 37 | Write-Error "***Error: provider requires 's3_bucket' parameter to be set!" 38 | exit 117 39 | } 40 | if (($filePath -eq $NULL) -or ($filePath -eq "")) 41 | { 42 | Write-Error "***Error: provider requires 'file_path' parameter to be set!" 43 | exit 118 44 | } 45 | if (($accessKeyID -eq $NULL) -or ($accessKeyID -eq "")) 46 | { 47 | Write-Error "***Error: provider requires 'access_key_id' parameter to be set!" 48 | exit 119 49 | } 50 | if (($secretAccessKey -eq $NULL) -or ($secretAccessKey -eq "")) 51 | { 52 | Write-Error "***Error: provider requires 'secret_access_key' parameter to be set!" 53 | exit 120 54 | } 55 | 56 | $client=[Amazon.AWSClientFactory]::CreateAmazonS3Client($accessKeyID,$secretAccessKey) 57 | 58 | $fileObject = [System.IO.FileInfo]$filePath 59 | 60 | #if fileObject is a directory, uploading the latest file from the directory 61 | if (test-path $fileObject.FullName -PathType Container) 62 | { 63 | Write-Output("***["+$fileObject.FullName+"] is a directory, trying to find the latest file inside.") 64 | $latest_file=Get-ChildItem -force $fileObject.FullName | Where-Object { !($_.Attributes -match "Directory") } | Sort-Object LastWriteTime -descending | Select-Object Name, FullName | Select-Object -first 1 65 | if ($latest_file -eq $null) 66 | { 67 | Write-Error("***["+$fileObject.FullName+"] directory has no file, aborting...") 68 | exit 120 69 | } 70 | else 71 | { 72 | $fileObject=$latest_file 73 | Write-Output("***The latest file in ["+$fileObject.FullName+"] directory is ["+$fileObject.Name+"]") 74 | } 75 | } 76 | 77 | 78 | if (($s3File -eq $NULL) -or ($s3File -eq "")) 79 | { 80 | $s3File = $fileObject.Name 81 | } 82 | 83 | Write-Output("***Uploading file["+$fileObject.Name+"] to bucket[$s3Bucket] as[$s3File]") 84 | 85 | $request = New-Object -TypeName Amazon.S3.Model.PutObjectRequest 86 | [void]$request.WithFilePath($fileObject.FullName) 87 | [void]$request.WithBucketName($s3Bucket) 88 | [void]$request.WithKey($s3File) 89 | 90 | #NOTE: upload defaults to 20 minute timeout. 91 | if ($timeoutSeconds -is [int]) 92 | { 93 | #timeout is in miliseconds 94 | $request.timeout=1000*$timeoutSeconds 95 | } 96 | 97 | #If download fails it will throw an exception and $S3Response will be $null 98 | $S3Response = $client.PutObject($request) 99 | 100 | if($S3Response -eq $null) 101 | { 102 | Write-Error "ERROR: Amazon S3 put requrest failed. Aborting..." 103 | exit 121 104 | } 105 | else 106 | { 107 | Write-Output "***Upload successfully. AWS Response:"$S3Response 108 | } -------------------------------------------------------------------------------- /cookbooks/utilities/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "replacing": { 3 | 4 | }, 5 | "recipes": { 6 | "utilities::install_firefox": "Installs Mozilla Firefox 3.6", 7 | "utilities::install_ruby": "Installs Ruby", 8 | "utilities::install_7zip": "Installs 7-Zip", 9 | "utilities::system_reboot": "Reboots the system", 10 | "utilities::delete_scheduled_task": "Deletes the 'rs_scheduled_task' scheduled task under the 'administrator' user. Uses the SCHTASKS Windows command", 11 | "utilities::default": "Not yet implemented", 12 | "utilities::create_scheduled_task": "Creates the 'rs_scheduled_task' scheduled task under the 'administrator' user. Uses the SCHTASKS Windows command", 13 | "utilities::change_admin_password": "Changes the administrator password", 14 | "utilities::system_shutdown": "Shuts down the system" 15 | }, 16 | "groupings": { 17 | 18 | }, 19 | "long_description": "= DESCRIPTION:\n\nWindows utilities recipes.\n\n= ATTRIBUTES:\n\nSee metadata.rb\n\n= USAGE:\n\nDesigned to be run within a RightScale ServerTemplate\n", 20 | "recommendations": { 21 | 22 | }, 23 | "license": "Copyright (c) 2010 RightScale, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n", 24 | "attributes": { 25 | "schtasks/daily_time": { 26 | "required": "optional", 27 | "calculated": false, 28 | "choice": [ 29 | 30 | ], 31 | "default": "", 32 | "type": "string", 33 | "recipes": [ 34 | "utilities::create_scheduled_task" 35 | ], 36 | "display_name": "Task daily time", 37 | "description": "The time of the day, based on the server's timezone, to run the task when the 'Hourly frequency' input is set to 24. Format: hh:mm (e.g., 22:30)" 38 | }, 39 | "utilities/admin_password": { 40 | "required": "required", 41 | "calculated": false, 42 | "choice": [ 43 | 44 | ], 45 | "type": "string", 46 | "recipes": [ 47 | "utilities::change_admin_password", 48 | "utilities::create_scheduled_task" 49 | ], 50 | "display_name": "New administrator password", 51 | "description": "New administrator password" 52 | }, 53 | "schtasks/hourly_frequency": { 54 | "required": "required", 55 | "calculated": false, 56 | "choice": [ 57 | 58 | ], 59 | "type": "string", 60 | "recipes": [ 61 | "utilities::create_scheduled_task" 62 | ], 63 | "display_name": "Task Hourly frequency", 64 | "description": "Defines the task frequency in hours. Valid values: 1 up to 24. When 24 is specified the 'Task daily time' input is required also." 65 | }, 66 | "schtasks/command": { 67 | "required": "required", 68 | "calculated": false, 69 | "choice": [ 70 | 71 | ], 72 | "type": "string", 73 | "recipes": [ 74 | "utilities::create_scheduled_task" 75 | ], 76 | "display_name": "Task command", 77 | "description": "Defines the shell command to run. (e.g., dir >> c:\\dir.txt)" 78 | } 79 | }, 80 | "maintainer": "RightScale, Inc.", 81 | "suggestions": { 82 | 83 | }, 84 | "dependencies": { 85 | 86 | }, 87 | "maintainer_email": "support@rightscale.com", 88 | "conflicting": { 89 | 90 | }, 91 | "platforms": { 92 | 93 | }, 94 | "description": "Windows Admin recipes and providers", 95 | "name": "utilities", 96 | "version": "0.3.2", 97 | "providing": { 98 | 99 | } 100 | } -------------------------------------------------------------------------------- /cookbooks/blog_engine/files/default/simple_app_deploy.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # Deploys all web app from zipped source to wwwroot under IIS. 23 | $checkForExistence = "$env:CHECK_FOR_EXISTENCE" -ne "false" 24 | $sevenZipExePath = $env:SEVEN_ZIP_EXE_PATH 25 | $webAppZipDirPath = $env:WEB_APP_ZIP_DIR_PATH 26 | 27 | # check inputs. 28 | if ("$webAppZipDirPath" -eq "") 29 | { 30 | Write-Error "The WEB_APP_ZIP_DIR_PATH environment variable was not set" 31 | exit 100 32 | } 33 | if (("$sevenZipExePath" -eq "") -or !(test-path $sevenZipExePath)) 34 | { 35 | Write-Error "The SEVEN_ZIP_EXE_PATH environment variable was not set or is invalid." 36 | exit 101 37 | } 38 | 39 | # wwwroot is always found at the same location (at least for simple deployment). 40 | $wwwRootDirPath = "C:\Inetpub\wwwroot" 41 | $wwwRootDir = Get-Item $wwwRootDirPath -ea Stop 42 | $webAppZipDir = Get-Item $webAppZipDirPath -ea Stop 43 | $webAppZipDirPath = $webAppZipDir.FullName 44 | 45 | # need a shell application COM object for unzipping 46 | $shellApplication = New-Object -com shell.application 47 | $zipFilesToExtract = $webAppZipDir.GetFiles("*.zip") 48 | 49 | # check existence, if requested. 50 | $doInstall = $true 51 | $webConfigFileName = "web.config" 52 | if ($checkForExistence -and (test-path (join-path $wwwRootDirPath $webConfigFileName))) 53 | { 54 | $doInstall = $false 55 | } 56 | 57 | if ($doInstall -eq $true) 58 | { 59 | # require existing web application directory. 60 | Write-Verbose "Deploying webapps from ""$webAppZipDirPath""" 61 | Write-Verbose "Deploying webapps to ""$wwwRootDirPath""" 62 | 63 | # clean out any leftover files in wwwroot (from installing IIS, etc.) 64 | Write-Verbose "Cleaning ""$wwwRootDirPath"" prior to deployment..." 65 | $Error.Clear() 66 | foreach ($item in (dir $wwwRootDirPath)) { Remove-Item $item.FullName -recurse } 67 | if ($Error.Count -ne 0) 68 | { 69 | Write-Error "Failed to clean the ""$wwwRootDirPath"" directory. Some files may still be in use." 70 | exit 102 71 | } 72 | 73 | # iterate webapp files unzipping each to the wwwroot location. if there are 74 | # multiple .zip files, they must not have colliding file names (i.e. we cannot 75 | # deploy multiple web apps to the wwwroot directory, but different pieces 76 | # of the same web app can be deployed from multiple .zip files). 77 | foreach ($webAppZipFile in $zipFilesToExtract) 78 | { 79 | $webAppZipFilePath = $webAppZipFile.FullName 80 | Write-Verbose "Unzipping ""$webAppZipFilePath"" to ""$wwwRootDirPath""" 81 | 82 | # use bundled 7-zip for simplicity; if multiple recipes depend on 7-zip 83 | # then it should be installed by recipe. 84 | Write-Verbose """$sevenZipExePath"" x ""$webAppZipFilePath"" ""-o$wwwRootDirPath"" -r" 85 | & "$sevenZipExePath" x "$webAppZipFilePath" "-o$wwwRootDirPath" -r | Out-Null 86 | if ($LastExitCode -ne 0) 87 | { 88 | Write-Error "Unzip failed." 89 | exit 103 90 | } 91 | 92 | # verify config file exists. 93 | $webConfigDstFile = Join-path $wwwRootDirPath $webConfigFileName | Get-Item -ea SilentlyContinue 94 | if ("$webConfigDstFile" -eq "") 95 | { 96 | Write-Error "Failed to deploy ""$webConfigFileName"" to ""$wwwRootDirPath""" 97 | exit 104 98 | } 99 | 100 | # note that we currently do not modify the connection strings for web apps and 101 | # just assume they are pre-configured for the instance's server name, etc. 102 | } 103 | } 104 | else 105 | { 106 | Write-Output "Web application already exists, no need to deploy." 107 | } 108 | -------------------------------------------------------------------------------- /cookbooks/blog_engine/powershell_providers/database/restore.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $cookbookName = Get-NewResource cookbook_name 24 | $resourceName = Get-NewResource resource_name 25 | $dbName = Get-NewResource name 26 | $nodePath = $cookbookName,$resourceName,$dbName 27 | $serverName = Get-NewResource server_name 28 | $backupDirPath = Get-NewResource backup_dir_path 29 | $forceRestore = Get-NewResource force_restore 30 | $backupFileNamePattern = (Get-NewResource existing_backup_file_name_pattern) -f $dbName 31 | 32 | # check if database exists before restoring. 33 | if (!$forceRestore -and (Get-ChefNode ($nodePath + "exists"))) 34 | { 35 | Write-Warning "Not restoring ""$dbName"" because it already exists." 36 | exit 0 37 | } 38 | 39 | # connect to server. 40 | $server = New-Object ("Microsoft.SqlServer.Management.Smo.Server") $serverName 41 | 42 | # require existing backup directory. 43 | $backupDir = Get-Item $backupDirPath -ea Stop 44 | $backupDirPath = $backupDir.FullName 45 | Write-Verbose "Using backup directory ""$backupDirPath""" 46 | 47 | # select backup file for restore by first match of backup file pattern. 48 | $backupFiles = $backupDir.GetFiles($backupFileNamePattern) 49 | 50 | if ($backupFile = $backupFiles[0]) 51 | { 52 | # check restore history to see if this revision has already been applied, 53 | # even if the database was subsequently dropped. this is intended to support 54 | # script idempotency, but the behavior can be overridden by setting the 55 | # force_restore flag on the resource. 56 | $backupFilePath = $backupFile.FullName 57 | $backupFileName = Split-Path -leaf $backupFilePath 58 | if (!$forceRestore) 59 | { 60 | $restoredFilePath = Get-ChefNode ($nodePath + "restore_file_paths" + $backupFileName.ToLower()) 61 | if ($restoredFilePath) 62 | { 63 | Write-Warning "Not restoring ""$backupFilePath"" because an equivalent database was already restored from ""$restoredFilePath""." 64 | exit 0 65 | } 66 | } 67 | 68 | $backupDevice = New-Object("Microsoft.SqlServer.Management.Smo.BackupDeviceItem") ($backupFilePath, "File") 69 | $restore = New-Object("Microsoft.SqlServer.Management.Smo.Restore") 70 | 71 | $restore.Devices.Add($backupDevice) 72 | $restore.NoRecovery = $false 73 | $restore.ReplaceDatabase = $true 74 | 75 | $Error.Clear() 76 | $backupHeader = $restore.ReadBackupHeader($server) 77 | if ($Error.Count -ne 0) 78 | { 79 | Write-Error "Failed to read backup header from ""$backupFilePath""" 80 | Write-Warning "SQL Server fails to backup/restore to/from network drives but will accept the equivalent UNC path so long as the database user has sufficient network privileges. Ensure that the SQL_BACKUP_DIR_PATH environment variable does not refer to a shared drive." 81 | exit 100 82 | } 83 | $headerDbName = $backupHeader.Rows[0]["DatabaseName"] 84 | if ($headerDbName -ne $dbName) 85 | { 86 | Write-Error "Name of database read from backup header ""$headerDbName"" does not match ""$dbName""". 87 | exit 101 88 | } 89 | $restore.Database = $headerDbName 90 | 91 | # restore. 92 | $restore.SqlRestore($server) 93 | if ($Error.Count -eq 0) 94 | { 95 | Write-Output "Restored database named ""$dbName"" from ""$backupFilePath""" 96 | Set-ChefNode ($nodePath + "exists") $True 97 | Set-ChefNode ($nodePath + "restore_file_paths" + $backupFileName.ToLower()) $backupFilePath 98 | Set-NewResource updated $True 99 | exit 0 100 | } 101 | else 102 | { 103 | Write-Error "Failed to restore database named ""$dbName"" from ""$backupFilePath""" 104 | exit 103 105 | } 106 | } 107 | else 108 | { 109 | Write-Error "There was no backup file matching ""$backupFileNamePattern"" to restore." 110 | exit 104 111 | } 112 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/powershell_providers/database/restore.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $cookbookName = Get-NewResource cookbook_name 24 | $resourceName = Get-NewResource resource_name 25 | $dbName = Get-NewResource name 26 | $nodePath = $cookbookName,$resourceName,$dbName 27 | $serverName = Get-NewResource server_name 28 | $backupDirPath = Get-NewResource backup_dir_path 29 | $forceRestore = Get-NewResource force_restore 30 | $backupFileNamePattern = (Get-NewResource existing_backup_file_name_pattern) -f $dbName 31 | 32 | # check if database exists before restoring. 33 | if (!$forceRestore -and (Get-ChefNode ($nodePath + "exists"))) 34 | { 35 | Write-Warning "Not restoring ""$dbName"" because it already exists." 36 | exit 0 37 | } 38 | 39 | # connect to server. 40 | $server = New-Object ("Microsoft.SqlServer.Management.Smo.Server") $serverName 41 | 42 | # require existing backup directory. 43 | $backupDir = Get-Item $backupDirPath -ea Stop 44 | $backupDirPath = $backupDir.FullName 45 | Write-Verbose "Using backup directory ""$backupDirPath""" 46 | 47 | # select backup file for restore by first match of backup file pattern. 48 | $backupFiles = $backupDir.GetFiles($backupFileNamePattern) 49 | 50 | if ($backupFile = $backupFiles[0]) 51 | { 52 | # check restore history to see if this revision has already been applied, 53 | # even if the database was subsequently dropped. this is intended to support 54 | # script idempotency, but the behavior can be overridden by setting the 55 | # force_restore flag on the resource. 56 | $backupFilePath = $backupFile.FullName 57 | $backupFileName = Split-Path -leaf $backupFilePath 58 | if (!$forceRestore) 59 | { 60 | $restoredFilePath = Get-ChefNode ($nodePath + "restore_file_paths" + $backupFileName.ToLower()) 61 | if ($restoredFilePath) 62 | { 63 | Write-Warning "Not restoring ""$backupFilePath"" because an equivalent database was already restored from ""$restoredFilePath""." 64 | exit 0 65 | } 66 | } 67 | 68 | $backupDevice = New-Object("Microsoft.SqlServer.Management.Smo.BackupDeviceItem") ($backupFilePath, "File") 69 | $restore = New-Object("Microsoft.SqlServer.Management.Smo.Restore") 70 | 71 | $restore.Devices.Add($backupDevice) 72 | $restore.NoRecovery = $false 73 | $restore.ReplaceDatabase = $true 74 | 75 | $Error.Clear() 76 | $backupHeader = $restore.ReadBackupHeader($server) 77 | if ($Error.Count -ne 0) 78 | { 79 | Write-Error "Failed to read backup header from ""$backupFilePath""" 80 | Write-Warning "SQL Server fails to backup/restore to/from network drives but will accept the equivalent UNC path so long as the database user has sufficient network privileges. Ensure that the SQL_BACKUP_DIR_PATH environment variable does not refer to a shared drive." 81 | exit 100 82 | } 83 | $headerDbName = $backupHeader.Rows[0]["DatabaseName"] 84 | if ($headerDbName -ne $dbName) 85 | { 86 | Write-Error "Name of database read from backup header ""$headerDbName"" does not match ""$dbName""". 87 | exit 101 88 | } 89 | $restore.Database = $headerDbName 90 | 91 | # restore. 92 | $restore.SqlRestore($server) 93 | if ($Error.Count -eq 0) 94 | { 95 | Write-Output "Restored database named ""$dbName"" from ""$backupFilePath""" 96 | Set-ChefNode ($nodePath + "exists") $True 97 | Set-ChefNode ($nodePath + "restore_file_paths" + $backupFileName.ToLower()) $backupFilePath 98 | Set-NewResource updated $True 99 | exit 0 100 | } 101 | else 102 | { 103 | Write-Error "Failed to restore database named ""$dbName"" from ""$backupFilePath""" 104 | exit 103 105 | } 106 | } 107 | else 108 | { 109 | Write-Error "There was no backup file matching ""$backupFileNamePattern"" to restore." 110 | exit 104 111 | } 112 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/powershell_providers/database/backup.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 RightScale Inc 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining 4 | # a copy of this software and associated documentation files (the 5 | # "Software"), to deal in the Software without restriction, including 6 | # without limitation the rights to use, copy, modify, merge, publish, 7 | # distribute, sublicense, and/or sell copies of the Software, and to 8 | # permit persons to whom the Software is furnished to do so, subject to 9 | # the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | # locals. 23 | $cookbookName = Get-NewResource cookbook_name 24 | $resourceName = Get-NewResource resource_name 25 | $dbName = Get-NewResource name 26 | $nodePath = $cookbookName,$resourceName,$dbName 27 | $serverName = Get-NewResource server_name 28 | $backupDirPath = Get-NewResource backup_dir_path 29 | $existingBackupFileNamePattern = (Get-NewResource existing_backup_file_name_pattern) -f $dbName 30 | $backupFileNameFormat = Get-NewResource backup_file_name_format 31 | $zipBackup = Get-NewResource zip_backup 32 | $deleteSqlAfterZip = Get-NewResource delete_sql_after_zip 33 | 34 | # check if database exists before backing up. 35 | if (!(Get-ChefNode ($nodePath + "exists"))) 36 | { 37 | Write-Warning "Not backing up ""$dbName"" because it does not exist." 38 | exit 0 39 | } 40 | 41 | # connect to server. 42 | $server = New-Object ("Microsoft.SqlServer.Management.Smo.Server") $serverName 43 | 44 | # force creation of backup directory or ignore if already exists. 45 | if (!(Test-Path $backupDirPath)) 46 | { 47 | md $backupDirPath | Out-Null 48 | } 49 | $backupDir = Get-Item $backupDirPath -ea Stop 50 | $backupDirPath = $backupDir.FullName 51 | Write-Output "Using backup directory ""$backupDirPath""" 52 | 53 | # rename existing .bak to .old after deleting existing .old files. 54 | # TODO: cleanup old backup files by some algorithm (allow 3 per database, older than 1 week, etc.) 55 | foreach ($oldBackupFile in $backupDir.GetFiles("*.old")) { del $oldBackupFile.FullName } 56 | foreach ($backupFile in $backupDir.GetFiles($backupFileNamePattern)) { ren $backupFile.FullName ($backupFile.Name + ".old") } 57 | 58 | # iterate user databases (ignoring system databases) and backup any found. 59 | $db = $server.Databases | where { !$_.IsSystemObject_ -and ($_.Name -eq $dbName) } 60 | if ($db) 61 | { 62 | $dbName = $db.Name 63 | $timestamp = Get-Date -format yyyyMMddHHmmss 64 | $backupFileName = $backupFileNameFormat -f $dbName, $timestamp 65 | $backupFilePath = Join-Path $backupDirPath $backupFileName 66 | 67 | $backup = New-Object ("Microsoft.SqlServer.Management.Smo.Backup") 68 | $backup.Action = "Database" # full database backup. TODO: also backup the transaction log. 69 | $backup.BackupSetDescription = "Full backup of $dbName" 70 | $backup.BackupSetName = "$dbName backup" 71 | $backup.Database = $dbName 72 | $backup.MediaDescription = "Disk" 73 | $backup.LogTruncation = "Truncate" 74 | $backup.Devices.AddDevice($backupFilePath, "File") 75 | 76 | $Error.Clear() 77 | $backup.SqlBackup($server) 78 | if ($Error.Count -eq 0) 79 | { 80 | Write-Output "Backed up database named ""$dbName"" to ""$backupFilePath""" 81 | if ($zipBackup -eq "true") 82 | { 83 | Write-Output "Zipping the backup" 84 | $output=invoke-expression 'cmd /c 7z a -tzip "$backupFilePath.zip" $backupFilePath' 85 | Write-Output $output 86 | if ($output -match "Everything is Ok") 87 | { 88 | if ($deleteSqlAfterZip -eq "true") 89 | { 90 | Write-Output "Deleting the bak file" 91 | Remove-Item $backupFilePath 92 | } 93 | Set-ChefNode backupfilename $backupFileName".zip" 94 | } 95 | } 96 | else 97 | { 98 | Set-ChefNode backupfilename $backupFileName 99 | } 100 | } 101 | else 102 | { 103 | # report error but keep trying to backup additional databases. 104 | Write-Error "Failed to backup ""$dbName""" 105 | Write-Warning "SQL Server fails to backup/restore to/from network drives but will accept the equivalent UNC path so long as the database user has sufficient network privileges. Ensure that the SQL_BACKUP_DIR_PATH environment variable does not refer to a shared drive." 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /cookbooks/aws/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "recipes": { 3 | "aws::deregister_from_elb": "Deregister the instance with an Elastic Load Balancer created in the same ec2 region. Requires recipe: 'aws::default'", 4 | "aws::default": "Install Amazon Web Services SDK for .NET", 5 | "aws::register_with_elb": "Register the instance with an Elastic Load Balancer created in the same ec2 region. Requires recipe: 'aws::default'", 6 | "aws::upload": "Uploads a file to an S3 bucket", 7 | "aws::download": "Retrieves a file from an S3 bucket" 8 | }, 9 | "groupings": { 10 | }, 11 | "recommendations": { 12 | }, 13 | "version": "0.1.5", 14 | "maintainer": "RightScale, Inc.", 15 | "long_description": "= DESCRIPTION:\n\nAws recipes and providers.\n\n= ATTRIBUTES:\n\nSee metadata.rb\n\n= USAGE:\n\nDesigned to be run within a RightScale ServerTemplate\n\nBoot Scripts\n* install_dotnet_sdk - Install Amazon Web Services SDK for .NET\n* register_with_elb - Register the instance with an Elastic Load Balancer created in the same ec2 region. Requires recipe: 'aws::install_dotnet_sdk'\n\nDecommission Scripts\n* deregister_from_elb - Deregister the instance with an Elastic Load Balancer created in the same ec2 region. Requires recipe: 'aws::install_dotnet_sdk'\n", 16 | "description": "Amazon Web Services recipes and providers for Windows", 17 | "suggestions": { 18 | }, 19 | "maintainer_email": "support@rightscale.com", 20 | "name": "aws", 21 | "conflicting": { 22 | }, 23 | "license": "Copyright (c) 2010 RightScale, Inc.\n\nAll rights reserved - Do Not Redistribute\n", 24 | "providing": { 25 | }, 26 | "dependencies": { 27 | }, 28 | "platforms": { 29 | }, 30 | "attributes": { 31 | "aws/file_path": { 32 | "calculated": false, 33 | "type": "string", 34 | "choice": [ 35 | 36 | ], 37 | "description": "The full path to the file to be uploaded. Ex: c:\\tmp\\my.txt", 38 | "display_name": "File Path", 39 | "recipes": [ 40 | "aws::upload" 41 | ], 42 | "required": "required" 43 | }, 44 | "s3/bucket": { 45 | "calculated": false, 46 | "type": "string", 47 | "choice": [ 48 | 49 | ], 50 | "description": "The name of the S3 bucket", 51 | "display_name": "Bucket", 52 | "recipes": [ 53 | "aws::download", 54 | "aws::upload" 55 | ], 56 | "required": "required" 57 | }, 58 | "s3/file": { 59 | "calculated": false, 60 | "type": "string", 61 | "choice": [ 62 | 63 | ], 64 | "description": "File to be retrieved from the s3 bucket. Ex: app.zip", 65 | "display_name": "File", 66 | "recipes": [ 67 | "aws::download" 68 | ], 69 | "required": "required" 70 | }, 71 | "aws/access_key_id": { 72 | "calculated": false, 73 | "type": "string", 74 | "choice": [ 75 | 76 | ], 77 | "description": "This is an Amazon credential. Log in to your AWS account at aws.amazon.com to retrieve you access identifiers. Ex: 1JHQQ4KVEVM02KVEVM02", 78 | "display_name": "Access Key Id", 79 | "recipes": [ 80 | "aws::register_with_elb", 81 | "aws::deregister_from_elb", 82 | "aws::download", 83 | "aws::upload" 84 | ], 85 | "required": "required" 86 | }, 87 | "aws/elb_name": { 88 | "calculated": false, 89 | "type": "string", 90 | "choice": [ 91 | 92 | ], 93 | "description": "The name of the Elastic Load Balancer to register/deregister the instance with. (e.g., production-elb). The ELB needs to be created and configured prior to the execution of the recipe.", 94 | "display_name": "ELB Name", 95 | "recipes": [ 96 | "aws::register_with_elb", 97 | "aws::deregister_from_elb" 98 | ], 99 | "required": "required" 100 | }, 101 | "aws/secret_access_key": { 102 | "calculated": false, 103 | "type": "string", 104 | "choice": [ 105 | 106 | ], 107 | "description": "This is an Amazon credential. Log in to your AWS account at aws.amazon.com to retrieve your access identifiers. Ex: XVdxPgOM4auGcMlPz61IZGotpr9LzzI07tT8s2Ws", 108 | "display_name": "Secret Access Key", 109 | "recipes": [ 110 | "aws::register_with_elb", 111 | "aws::deregister_from_elb", 112 | "aws::download", 113 | "aws::upload" 114 | ], 115 | "required": "required" 116 | }, 117 | "aws/download_dir": { 118 | "calculated": false, 119 | "type": "string", 120 | "choice": [ 121 | 122 | ], 123 | "description": "The directory where the file from s3 will be downloaded. Ex: c:\\tmp\\", 124 | "display_name": "Download Dir", 125 | "recipes": [ 126 | "aws::download" 127 | ], 128 | "required": "required" 129 | } 130 | }, 131 | "replacing": { 132 | } 133 | } -------------------------------------------------------------------------------- /cookbooks/sys_monitoring/files/default/collectd/collectd.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 RightScale Inc 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining 5 | # a copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, 8 | # distribute, sublicense, and/or sell copies of the Software, and to 9 | # permit persons to whom the Software is furnished to do so, subject to 10 | # the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be 13 | # included in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | class Collectd 24 | # Encode a string (type 0, null terminated string) 25 | def self.string(type, str) 26 | str += "\000" 27 | [type, str.length+4].pack("nn") + str 28 | end 29 | 30 | # Encode an integer 31 | def self.number(type, num) 32 | [type, 12].pack("nn") + [num >> 32, num & 0xffffffff].pack("NN") 33 | end 34 | 35 | # Create a collectd collection object tied to a specific destination server and port. 36 | # The host parameter is the hostname sent to collectd, typically `hostname -f`.strip 37 | # The use of the interval is unclear, it's simply sent to collectd with every packet... 38 | def initialize(server, port, host, interval) 39 | @sock = UDPSocket.new(Socket::AF_INET) 40 | @sock.connect(server, port) 41 | @interval = interval 42 | @host = host 43 | start 44 | end 45 | 46 | # Start a fresh packet, this is usually not called directly. Issues a time marker using either 47 | # the passed time (unix time integer) or the same time as the previous packet (useful when 48 | # overrunning from one packet to the next) 49 | def start(time=nil) 50 | @pkt = Collectd.string(0, @host) 51 | @time = time if time 52 | @pkt << Collectd.number(1, @time) if @time 53 | @pkt << Collectd.number(7, @interval) 54 | @plugin = @plugin_instance = @tipe = @tipe_instance = nil 55 | end 56 | # Send the current packet 57 | def flush 58 | @sock.send(@pkt.to_s, 0) rescue SystemCallError 59 | end 60 | # Check the length of the current packet and flush it if we reach a high-water mark 61 | def chk 62 | if @pkt.size > 900 # arbitrary flush, 1024 is the max allowed 63 | flush 64 | #sleep(0.01) # don't overwhelm output buffers 65 | start 66 | end 67 | end 68 | 69 | # Issue time, plugin, plugin_instance, type, and type_instance markers. These are not typically called 70 | # directly 71 | def time(t) @pkt << Collectd.number(1, @time = t) unless @time == t; end 72 | def plugin(p) @pkt << Collectd.string(2, @plugin = p) unless @plugin == p; end 73 | def plugin_instance(p) @pkt << Collectd.string(3, @plugin_instance = p) unless @plugin_instance == p; end 74 | def tipe(p) @pkt << Collectd.string(4, @tipe = p) unless @tipe == p; end 75 | def tipe_instance(p) @pkt << Collectd.string(5, @tipe_instance = p) unless @tipe_instance == p; end 76 | 77 | # Send a data point consisting of one or multiple values. Multiple values are used for RRDs with multiple 78 | # data series (DS's in RRD terms). An examples of a multi-valued RRDs in the collectd types is disk_write 79 | # with a 'read' and a 'write' value. 80 | # Arguments: pl=plugin, pi=plugin_instance, t=type, ti=type_instance, values: array of [type, value] 81 | # Eg.: values('disk', 'sda0', 'disk', 'ops', [[:counter, 1034], [:counter, 345]]) 82 | @@type_code = {:gauge => 1, :counter => 0, :derive => 2, :absolute => 3} 83 | def values(pl, pi, t, ti, values) 84 | chk 85 | plugin(pl); plugin_instance(pi) 86 | tipe(t); tipe_instance(ti) 87 | @pkt << [6, 4+2+values.size*9, values.size].pack("nnn") 88 | @pkt << values.map{|t,v| [@@type_code[t]].pack("C")}.join 89 | @pkt << values.map{|t,v| t == :gauge ? [v].pack("E") : [v>>32, v & 0xffffffff].pack("NN")}.join 90 | end 91 | 92 | # Send a data point with one or multiple gauge values 93 | def gauge (pl, pi, t, ti, value) values(pl, pi, t, ti, Array(value).map{|v| [:gauge, v]}); end 94 | # Send a data point with one or multiple counter values 95 | def counter (pl, pi, t, ti, value) values(pl, pi, t, ti, Array(value).map{|v| [:counter, v]}); end 96 | # Send a data point with one or multiple derive values 97 | def derive (pl, pi, t, ti, value) values(pl, pi, t, ti, Array(value).map{|v| [:derive, v]}); end 98 | # Send a data point with one or multiple absolute values 99 | def absolute(pl, pi, t, ti, value) values(pl, pi, t, ti, Array(value).map{|v| [:absolute, v]}); end 100 | 101 | def to_s; @pkt; end 102 | end 103 | -------------------------------------------------------------------------------- /cookbooks/db_sqlserver/metadata.rb: -------------------------------------------------------------------------------- 1 | maintainer "RightScale, Inc." 2 | maintainer_email "support@rightscale.com" 3 | license IO.read(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'LICENSE'))) 4 | description "Microsoft SQL Server recipes and providers" 5 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc')) 6 | version "0.3.8" 7 | 8 | 9 | recipe 'db_sqlserver::default', 'Sets up default user and enables SQL service.' 10 | recipe "db_sqlserver::backup", "Backs up database to a local machine directory." 11 | recipe "db_sqlserver::backup_to_s3", "Backs up database to S3." 12 | recipe "db_sqlserver::restore", "Restores database from a local machine directory." 13 | recipe "db_sqlserver::drop", "Drops a database." 14 | recipe "db_sqlserver::import_dump_from_s3", 'Downloads SQL dump from S3 bucket and imports it into database.' 15 | recipe "db_sqlserver::enable_sql_service", "Enables the SQL Server service if disabled" 16 | 17 | 18 | attribute "db_sqlserver/server_name", 19 | :display_name => "SQL Server instance network name", 20 | :description => "The network name of the SQL Server instance used by recipes. Ex: 'localhost\\SQLEXPRESS' for SQL EXPRESS or 'localhost' for SQL STANDARD", 21 | :recipes => ["db_sqlserver::default", "db_sqlserver::import_dump_from_s3", "db_sqlserver::backup", "db_sqlserver::backup_to_s3", "db_sqlserver::restore", "db_sqlserver::drop"], 22 | :required => "required" 23 | 24 | attribute "db_sqlserver/database_name", 25 | :display_name => "SQL Server database name", 26 | :description => "SQL Server database(schema) name. Ex: production", 27 | :recipes => ["db_sqlserver::default", "db_sqlserver::import_dump_from_s3", "db_sqlserver::backup", "db_sqlserver::backup_to_s3", "db_sqlserver::restore", "db_sqlserver::drop"], 28 | :required => "required" 29 | 30 | attribute "db_sqlserver/backup/database_backup_dir", 31 | :display_name => "SQL Server backup .bak directory", 32 | :description => "The local drive path or UNC path to the directory which will contain new SQL Server database backup (.bak) files. Note that network drives are not supported by SQL Server.", 33 | :default => "c:\\datastore\\sqlserver\\databases", 34 | :recipes => ["db_sqlserver::backup", "db_sqlserver::backup_to_s3", "db_sqlserver::restore"] 35 | 36 | attribute "db_sqlserver/backup/backup_file_name_format", 37 | :display_name => "Backup file name format", 38 | :description => "Format string with Powershell-style string format arguments for creating backup files. The 0 argument represents the database name and the 1 argument represents a generated time stamp. Ex: {0}_{1}.bak", 39 | :default => "{0}_{1}.bak", 40 | :recipes => ["db_sqlserver::default", "db_sqlserver::import_dump_from_s3", "db_sqlserver::backup", "db_sqlserver::backup_to_s3", "db_sqlserver::restore"] 41 | 42 | attribute "db_sqlserver/backup/existing_backup_file_name_pattern", 43 | :display_name => "Pattern matching backup file names", 44 | :description => "Wildcard file matching pattern (i.e. not a Regex) with Powershell-style string format arguments for finding backup files. The 0 argument represents the database name and the rest of the pattern should match the file names generated from the backup_file_name_format. Ex: {0}_*.bak", 45 | :default => "{0}_*.bak", 46 | :recipes => ["db_sqlserver::default", "db_sqlserver::import_dump_from_s3", "db_sqlserver::backup", "db_sqlserver::backup_to_s3", "db_sqlserver::restore"] 47 | 48 | attribute "db_sqlserver/restore/force_restore", 49 | :display_name => "Force restore", 50 | :description => "Whether to force restoring backup on top of any pre-existing database", 51 | :recipes => ["db_sqlserver::restore"], 52 | :choice => ['true', 'false'], 53 | :default => "false" 54 | 55 | attribute "s3/file_dump", 56 | :display_name => "Sql dump file", 57 | :description => "Sql dump file to be retrieved from the s3 bucket. Ex: production-dump.sql or production-dump.sql.zip", 58 | :recipes => ["db_sqlserver::default", "db_sqlserver::import_dump_from_s3"], 59 | :required => "required" 60 | 61 | attribute "s3/bucket_dump", 62 | :display_name => "Bucket for sql dump", 63 | :description => "The name of the S3 bucket. Ex: production-bucket-dumps", 64 | :recipes => ["db_sqlserver::default", "db_sqlserver::import_dump_from_s3"], 65 | :required => "required" 66 | 67 | attribute "s3/bucket_backups", 68 | :display_name => "Bucket to store backups", 69 | :description => "The name of the S3 bucket. Ex: production-bucket-backup", 70 | :recipes => ["db_sqlserver::backup_to_s3"], 71 | :required => "required" 72 | 73 | attribute "aws/access_key_id", 74 | :display_name => "Access Key Id", 75 | :description => "This is an Amazon credential. Log in to your AWS account at aws.amazon.com to retrieve you access identifiers. Ex: 1JHQQ4KVEVM02KVEVM02", 76 | :recipes => ["db_sqlserver::default", "db_sqlserver::import_dump_from_s3", "db_sqlserver::backup_to_s3"], 77 | :required => "required" 78 | 79 | attribute "aws/secret_access_key", 80 | :display_name => "Secret Access Key", 81 | :description => "This is an Amazon credential. Log in to your AWS account at aws.amazon.com to retrieve your access identifiers. Ex: XVdxPgOM4auGcMlPz61IZGotpr9LzzI07tT8s2Ws", 82 | :recipes => ["db_sqlserver::default", "db_sqlserver::import_dump_from_s3", "db_sqlserver::backup_to_s3"], 83 | :required => "required" 84 | -------------------------------------------------------------------------------- /cookbooks/sys_monitoring/files/default/monitors/cpu_load.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2010 RightScale Inc 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining 5 | # a copy of this software and associated documentation files (the 6 | # "Software"), to deal in the Software without restriction, including 7 | # without limitation the rights to use, copy, modify, merge, publish, 8 | # distribute, sublicense, and/or sell copies of the Software, and to 9 | # permit persons to whom the Software is furnished to do so, subject to 10 | # the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be 13 | # included in all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | priority :highest # cpu_load is always visible and very time sensitive. 24 | 25 | # Initialize the last cpu count 26 | # 27 | # === Return 28 | # true:: Always return true 29 | def init 30 | @last_cpus = nil 31 | true 32 | end 33 | 34 | # Collect and send CPU load information 35 | # 36 | # === Return 37 | # true:: Always return true 38 | def run 39 | wmi_processor_attributes = ['Name', 40 | 'TimeStamp_Sys100NS', 41 | 'PercentIdleTime', 42 | 'PercentUserTime', 43 | 'PercentPrivilegedTime', 44 | 'PercentInterruptTime'] 45 | wmi_query = "Select #{wmi_processor_attributes.join(", ")} from Win32_PerfRawData_PerfOS_Processor where Name != '_Total'" 46 | @logger.debug("WMI query = #{wmi_query}") 47 | wmi_result = execute_wmi_query(wmi_query) 48 | cpus = {} 49 | for cpu in wmi_result do 50 | cpu_name = cpu.Name 51 | cpu_values = {} 52 | cpus[cpu_name] = cpu_values 53 | 54 | cpu_values[:idle] = normalize_raw_value(cpu.PercentIdleTime) 55 | cpu_values[:interrupt] = normalize_raw_value(cpu.PercentInterruptTime) 56 | cpu_values[:system] = normalize_raw_value(cpu.PercentPrivilegedTime) 57 | cpu_values[:user] = normalize_raw_value(cpu.PercentUserTime) 58 | 59 | cpu_values[:wmi_time] = normalize_raw_value(cpu.TimeStamp_Sys100NS) 60 | cpu_values[:clock_time] = current_time 61 | 62 | # in WMI, system time includes interrupt and DPC time (deferred 63 | # procedure calls). subtract out interrupt time so that we can display 64 | # it separately. DPC is not displayable with Sketchy, so ignore it. 65 | cpu_values[:system] -= cpu_values[:interrupt] 66 | 67 | # as a sanity check, ensure values are strictly increasing from last 68 | # sample. this avoids spikes (negative value to unsigned integer) 69 | # resulting from subtracting interrupt from system (due ultimately to 70 | # small errors in WMI vs. clock time). 71 | if @last_cpus && (last_cpu_values = @last_cpus[cpu_name]) 72 | cpu_values.keys.each do |k| 73 | if cpu_values[k] < last_cpu_values[k] 74 | cpu_values[k] = last_cpu_values[k] 75 | end 76 | end 77 | end 78 | 79 | # add counters 80 | counter('cpu', cpu_name, 'cpu', 'idle', cpu_values[:idle]) 81 | counter('cpu', cpu_name, 'cpu', 'system', cpu_values[:system]) 82 | counter('cpu', cpu_name, 'cpu', 'interrupt', cpu_values[:interrupt]) 83 | counter('cpu', cpu_name, 'cpu', 'user', cpu_values[:user]) 84 | 85 | # logger. 86 | if @logger.debug? 87 | @logger.debug("Sending CPU(#{cpu_name}) idle(#{cpu_values[:idle]}) user(#{cpu_values[:user]}) system(#{cpu_values[:system]}) interrupt(#{cpu_values[:interrupt]}) clock(#{cpu_values[:clock_time]})") 88 | if @last_cpus && (last_cpu_values = @last_cpus[cpu_name]) 89 | 90 | # WMI percentages. 91 | idle_percentage = calculate_wmi_percentage(:idle, cpu_values, last_cpu_values) 92 | interrupt_percentage = calculate_wmi_percentage(:interrupt, cpu_values, last_cpu_values) 93 | system_percentage = calculate_wmi_percentage(:system, cpu_values, last_cpu_values) 94 | user_percentage = calculate_wmi_percentage(:user, cpu_values, last_cpu_values) 95 | total_percentage = idle_percentage + interrupt_percentage + system_percentage + user_percentage 96 | delta_time = cpu_values[:wmi_time] - last_cpu_values[:wmi_time] 97 | @logger.debug("WMI calculation: idle=#{idle_percentage}% user=#{user_percentage}% system=#{system_percentage}% interrupt=#{interrupt_percentage}% total=#{total_percentage}% delta_time=#{delta_time}") 98 | 99 | # collectd percentages. 100 | idle_percentage = calculate_collectd_percentage(:idle, cpu_values, last_cpu_values) 101 | interrupt_percentage = calculate_collectd_percentage(:interrupt, cpu_values, last_cpu_values) 102 | system_percentage = calculate_collectd_percentage(:system, cpu_values, last_cpu_values) 103 | user_percentage = calculate_collectd_percentage(:user, cpu_values, last_cpu_values) 104 | total_percentage = idle_percentage + interrupt_percentage + system_percentage + user_percentage 105 | delta_time = 100 * (cpu_values[:clock_time] - last_cpu_values[:clock_time]) 106 | @logger.debug("collectd calculation: idle=#{idle_percentage}% user=#{user_percentage}% system=#{system_percentage}% interrupt=#{interrupt_percentage}% total=#{total_percentage}% delta_time=#{delta_time}") 107 | end 108 | end 109 | end 110 | @last_cpus = cpus 111 | 112 | true 113 | end 114 | --------------------------------------------------------------------------------