Skip to content

Instantly share code, notes, and snippets.

@NAshwini
Last active November 17, 2017 10:22
Show Gist options
  • Save NAshwini/e558cda3ff9b8c57da34ba2b68f54a70 to your computer and use it in GitHub Desktop.
Save NAshwini/e558cda3ff9b8c57da34ba2b68f54a70 to your computer and use it in GitHub Desktop.
Creating aws vm with driver ec2
<powershell>
$user="ashwini"
$password="ec2user@123"
net user /add $user $password;
net localgroup Administrators /add $user;
winrm quickconfig -q
winrm create winrm/config/Listener?Address=*+Transport=HTTP
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="300"}'
winrm set winrm/config '@{MaxTimeoutms="1800000"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
netsh advfirewall firewall add rule name="WinRM 5985" protocol=TCP dir=in localport=5985 action=allow
netsh advfirewall firewall add rule name="WinRM 5986" protocol=TCP dir=in localport=5986 action=allow
NetSh Advfirewall set allprofiles state off
net stop winrm
sc.exe config winrm start=auto # this "sc config winrm start=auto" does not work for some case so added sc.exe
net start winrm
</powershell>
---
driver:
require_chef_omnibus: true
name: ec2
aws_ssh_key_id: ash_new_key
security_group_ids: ["sg-f22ca796"]
region: us-west-2
subnet_id: subnet-2f05544a
availability_zone: b
instance_type: t2.micro
associate_public_ip: true
private_ip_address: '172.31.19.8'
#shared_credentials_profile: tm-intl-dev/ipa-global-ops
retryable_tries: 300
retryable_sleep: 10
tags:
Name: ash-win-kitchen
CreatedBy: chef-kitchen-<%= ENV['USER'] || 'delivery' %>
ProductCode: PRD298
InventoryCode: sys
Environment: dev-dub-inspec
class: adc
product: iad
cluster: awsiesb1
bu: winsys
provisioner:
name: chef_zero
require_chef_omnibus: true # need the RFC 062 exit codes
retry_on_exit_code:
- [35, 1, 20]
max_retries: 10
wait_for_retry: 120
client_rb:
exit_status: :enabled # Opt-in to the standardized exit codes
client_fork: false # Forked instances don't return the real exit code
diff_disabled: true
verifier:
name: inspec
platforms:
- name: windows
transport:
name: winrm
elevated: true
connection_retries: 100
connection_retry_sleep: 4
username: Administrator
ssh_key: C:\Users\MSys\.ssh\ash_new_key.pem
password:
driver:
image_id: ami-47897a3f
image_search:
owner-id: "112368887283" ## TM
name: "Windows_Server-2016-English-Full-*" ## TM
driver_config:
user_data: C:\Users\MSys\Desktop\user_data_ash.ps1
suites:
- name: default
run_list:
- recipe[aws_kitchen_reboot::default]
p "Hello ash-kitchen-test "
#IMP NOTE: check reboot time by 'systeminfo | find "System Boot Time'
# For creation
reboot 'now' do
action :nothing
reason 'Cannot continue Chef run without a reboot.'
delay_mins 2
end
execute 'foo' do
command 'echo rob'
notifies :reboot_now, 'reboot[now]', :immediately
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment