Quantcast
Channel: windows – Devops and the Public cloud
Viewing all articles
Browse latest Browse all 7

Powershell & user data to start a chef run

$
0
0

This script can be used to configure  an instance on AWS at startup to collect user data which would be the run list in json . This assumes that ruby and the pre-requisite gems have already been installed

#chef-clientrun.ps1

# install chef gem – This ensures only the latest stable version is installed

$installchef= “gem install chef –no-rdoc –no-ri””

# Download userdata

$webclient = new-object system.net.webclient

$awsurl =”http://169.254.169.254/latest/user-data

$targetfile =”c:\chef\etc\runlist.json”

$webClient.DownloadFile(“$awsurl”,”$targetfile”)

# Run chef-client passing json file which contains runlist

$runchef = “C:\Ruby192\bin\chef-client -j”+  $targetfile

invoke-expression $installchef

invoke-expression $runchef



Viewing all articles
Browse latest Browse all 7

Latest Images

Trending Articles





Latest Images