Skip to content

Instantly share code, notes, and snippets.

@zl4bv
Last active August 29, 2015 14:21
Show Gist options
  • Save zl4bv/ed5a1b11ecdc610518d2 to your computer and use it in GitHub Desktop.
Save zl4bv/ed5a1b11ecdc610518d2 to your computer and use it in GitHub Desktop.
---
driver:
name: ec2
aws_ssh_key_id: test-kitchen
security_group_ids: ["sg-aaaaaaaa"]
region: ap-southeast-2
subnet_id: subnet-bbbbbbbb
instance_type: t2.micro
user_data: ec2-user-data.ps1.base64
transport:
name: winrm
connection_timeout: 10
connection_retries: 600
connection_retry_sleep: 10
max_wait_until_ready: 1200
username: kitchen
password: K1tch3nR0ck5
platforms:
- name: windows2012r2
driver:
image_id: ami-a9077a93
provisioner:
name: chef_solo
suites:
- name: default
run_list:
- recipe[chocolatey::default]
source 'https://supermarket.chef.io'
cookbook 'chocolatey'
<powershell>
write-output "Running User Data Script"
write-host "(host) Running User Data Script"
cmd.exe /c net user /add kitchen K1tch3nR0ck5
cmd.exe /c net localgroup Administrators kitchen /add
Set-ExecutionPolicy -ExecutionPolicy bypass -Force
# RDP
#cmd.exe /c netsh advfirewall firewall add rule name="Open Port 3389" dir=in action=allow protocol=TCP localport=3389
#cmd.exe /c reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
# WinRM
write-output "Setting up WinRM"
write-host "(host) setting up WinRM"
cmd.exe /c winrm quickconfig -q
cmd.exe /c winrm quickconfig '-transport:http'
cmd.exe /c winrm set "winrm/config" '@{MaxTimeoutms="1800000"}'
cmd.exe /c winrm set "winrm/config/winrs" '@{MaxMemoryPerShellMB="1024"}'
cmd.exe /c winrm set "winrm/config/service" '@{AllowUnencrypted="true"}'
cmd.exe /c winrm set "winrm/config/client" '@{AllowUnencrypted="true"}'
cmd.exe /c winrm set "winrm/config/service/auth" '@{Basic="true"}'
cmd.exe /c winrm set "winrm/config/client/auth" '@{Basic="true"}'
cmd.exe /c winrm set "winrm/config/service/auth" '@{CredSSP="true"}'
cmd.exe /c winrm set "winrm/config/listener?Address=*+Transport=HTTP" '@{Port="5985"}'
cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
cmd.exe /c netsh advfirewall set publicprofile state off
cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985"
cmd.exe /c net stop winrm
cmd.exe /c sc config winrm start= auto
cmd.exe /c net start winrm
cmd.exe /c wmic useraccount where "name='kitchen'" set PasswordExpires=FALSE
</powershell>
source 'https://rubygems.org'
gem 'berkshelf'
gem 'test-kitchen'
gem 'kitchen-ec2'
gem 'winrm-transport'
$ kitchen test -l DEBUG
-----> Starting Kitchen (v1.4.0)
D Berksfile found at /home/ben/tktest/Berksfile, loading Berkshelf
D Berkshelf 3.2.4 library loaded
D Winrm Transport requested, loading WinRM::Transport gem (~> 1.0)
D WinRM::Transport 1.0.1 library loaded
-----> Cleaning up any prior instances of <default-windows2012r2>
-----> Destroying <default-windows2012r2>...
Finished destroying <default-windows2012r2> (0m0.00s).
-----> Testing <default-windows2012r2>
-----> Creating <default-windows2012r2>...
Creating <>...
If you are not using an account that qualifies under the AWS
free-tier, you may be charged to run these suites. The charge
should be minimal, but neither Test Kitchen nor its maintainers
are responsible for your incurred costs.
D Creating EC2 Instance..
Instance <i-3a78e3e6> requested.
EC2 instance <i-3a78e3e6> created.
Waited 0/300s for instance <i-3a78e3e6> to become ready.
Waited 5/300s for instance <i-3a78e3e6> to become ready.
Waited 10/300s for instance <i-3a78e3e6> to become ready.
Waited 15/300s for instance <i-3a78e3e6> to become ready.
Waited 20/300s for instance <i-3a78e3e6> to become ready.
Waited 25/300s for instance <i-3a78e3e6> to become ready.
EC2 instance <i-3a78e3e6> ready.
D [WinRM] opening remote shell on plaintext::http://ec2-52-64-46-171.ap-southeast-2.compute.amazonaws.com:5985/wsman<{:disable_sspi=>true, :basic_auth_only=>true, :user=>"kitchen", :pass=>"K1tch3nR0ck5"}>
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #create action: [execution expired]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
D ------Exception-------
D Class: Kitchen::ActionFailed
D Message: Failed to complete #create action: [execution expired]
D ---Nested Exception---
D Class: HTTPClient::ConnectTimeoutError
D Message: execution expired
D ------Backtrace-------
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/httpclient-2.6.0.1/lib/httpclient/session.rb:799:in `initialize'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/httpclient-2.6.0.1/lib/httpclient/session.rb:799:in `new'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/httpclient-2.6.0.1/lib/httpclient/session.rb:799:in `create_socket'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/httpclient-2.6.0.1/lib/httpclient/session.rb:747:in `block in connect'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/httpclient-2.6.0.1/lib/httpclient/session.rb:746:in `connect'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/httpclient-2.6.0.1/lib/httpclient/session.rb:612:in `query'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/httpclient-2.6.0.1/lib/httpclient/session.rb:164:in `query'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/httpclient-2.6.0.1/lib/httpclient.rb:1191:in `do_get_block'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/httpclient-2.6.0.1/lib/httpclient.rb:974:in `block in do_request'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/httpclient-2.6.0.1/lib/httpclient.rb:1082:in `protect_keep_alive_disconnected'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/httpclient-2.6.0.1/lib/httpclient.rb:969:in `do_request'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/httpclient-2.6.0.1/lib/httpclient.rb:822:in `request'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/httpclient-2.6.0.1/lib/httpclient.rb:725:in `post'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/winrm-1.3.3/lib/winrm/http/transport.rb:47:in `send_request'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/winrm-1.3.3/lib/winrm/winrm_service.rb:430:in `send_message'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/winrm-1.3.3/lib/winrm/winrm_service.rb:126:in `open_shell'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/winrm-transport-1.0.1/lib/winrm/transport/command_executor.rb:78:in `open'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/transport/winrm.rb:226:in `block in establish_shell'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/transport/winrm.rb:338:in `retryable'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/transport/winrm.rb:224:in `establish_shell'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/transport/winrm.rb:367:in `session'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/transport/winrm.rb:128:in `wait_until_ready'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/kitchen-ec2-0.9.1/lib/kitchen/driver/ec2.rb:218:in `create'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/instance.rb:424:in `public_send'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/instance.rb:424:in `block in perform_action'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/instance.rb:488:in `call'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/instance.rb:488:in `synchronize_or_call'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/instance.rb:453:in `block in action'
D /home/ben/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/instance.rb:452:in `action'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/instance.rb:424:in `perform_action'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/instance.rb:352:in `create_action'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/instance.rb:341:in `block in transition_to'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/instance.rb:340:in `each'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/instance.rb:340:in `transition_to'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/instance.rb:160:in `verify'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/instance.rb:189:in `block in test'
D /home/ben/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/instance.rb:185:in `test'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/command.rb:176:in `public_send'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/test-kitchen-1.4.0/lib/kitchen/command.rb:176:in `block (2 levels) in run_action'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `call'
D /home/ben/.rvm/gems/ruby-1.9.3-p551/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'
D ----------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment