# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 name: Chef Recipe Execution on Windows description: This is a sample component that demonstrates how to download and execute a Chef recipe against a Windows server. This sample will install Chef using the Chef Software Install script. For more information about the installation script, review the documentation at https://docs.chef.io/packages/#chef-software-install-script. schemaVersion: 1.0 constants: - ChefInstallationScriptSource: type: string value: 'https://omnitruck.chef.io/install.ps1' - RecipeSource: type: string value: 's3:///' phases: - name: build steps: - name: InstallChef action: ExecutePowerShell inputs: commands: - | $ErrorActionPreference = 'Stop' $source = '{{ ChefInstallationScriptSource }}' Write-Host "Installing Chef using the installation script '$source'" $null = . { Invoke-WebRequest -UseBasicParsing -Uri $source } | Invoke-Expression install -channel stable - name: RecipeDestination action: ExecutePowerShell onFailure: Abort timeoutSeconds: 5 inputs: commands: - Join-Path -Path $env:TEMP -ChildPath 'recipe.rb' - name: DownloadRecipe action: S3Download inputs: - source: '{{ RecipeSource }}' destination: '{{ build.RecipeDestination.outputs.stdout }}' - name: ApplyRecipe action: ExecuteBinary inputs: path: C:\opscode\chef\bin\chef-client arguments: - '--local-mode' - '{{ build.RecipeDestination.outputs.stdout }}' - '--chef-license' - 'accept-no-persist' - name: Cleanup action: DeleteFile inputs: - path: '{{build.RecipeDestination.outputs.stdout}}'"