-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap_windows.ps1
35 lines (29 loc) · 963 Bytes
/
bootstrap_windows.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
param (
[string]$ChefServerUrl,
[string[]]$Recipe,
[string]$Environment,
[string]$BasePath = 'c:/chef' )
if (Test-Path "$BasePath/client.rb")
{
Remove-Item "$BasePath/client.rb"
}
new-item -path "$BasePath/client.rb" -type file
Add-Content "$BasePath/client.rb" -Encoding Ascii -Value @"
log_level :info
log_location STDOUT
chef_server_url $ChefServerUrl
validation_key 'c:/chef/validation.pem'
validation_client_name 'onecloud-validator'
ssl_verify_mode :verify_none
"@
if (Test-Path "$BasePath/first-boot.json")
{
Remove-Item "$BasePath/first-boot.json"
}
new-item -path "$BasePath/first-boot.json" -type file
$runlist = $recipe | foreach {$text = ""} {
$text += "recipe[$_],"
} {$text.trim().trim(',')}
Add-Content "$BasePath/first-boot.json" -Encoding Ascii -Value "{`"run_list`": `"[$runlist]`"}"
$FIRSTBOOTJSON = "$BasePath/first-boot.json"
chef-client -j $FIRSTBOOTJSON --environment $environment