New Pluralsight course published – Getting Productive with Chef Cookbooks

My latest Pluralsight course has just gone live – Getting Productive with Chef Cookbooks.

Check it out at www.pluralsight.com/courses/chef-cookbooks-getting-productive.

This is my second course for Pluralsight and the second course on Chef – it builds on the lab environment developed in the first course, called Planning and Installing Chef, which you can access at www.pluralsight.com/courses/chef-planning-installing.

Writing and presenting on Chef software has been a really interesting experience. Chef encourages you to change the way you think about infrastructure – for more focus on desired outcomes rather than the methods and processes to get there.

In the course, we take a couple of unconfigured servers – one running Windows Server 2012 R2 and the other running Ubuntu Server 14.04 LTS (both running in Azure) and use Chef to turn them in to multi-tiered web servers hosting a live web application.

Enjoy the course!

 

4 comments to New Pluralsight course published – Getting Productive with Chef Cookbooks

  • Jose Castillo

    James, both your courses are excellent. I am still learning both Azure and Chef and these course are exactly what I need. I do have a couple of questions with respect to the provided ARM powershell scripts. I am getting an error with the script. Since Microsoft recently moved over to the ARM based Azure portal, it seems some of the commands used by your scripts are not only deprecated, but not available. Here is the output of the errors I am getting. While I have been able to work through a couple of them, I can’t get the entire script working which forces me to build some resources manually. Do you have updated scripts available?

    > .\Create-CourseEnvironmentARM.ps1
    Switch-AzureMode : The term ‘Switch-AzureMode’ is not recognized as the name of a cmdlet, function, script file, or
    operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
    again.
    At C:\Users\purplefeetguy\Downloads\Development\IAC\azure-pfllab\Create-CourseEnvironmentARM.ps1:28 char:1
    + Switch-AzureMode AzureResourceManager -Verbose
    + ~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Switch-AzureMode:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Test-AzureResourceGroup : The term ‘Test-AzureResourceGroup’ is not recognized as the name of a cmdlet, function,
    script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
    correct and try again.
    At C:\Users\purplefeetguy\Downloads\Development\IAC\azure-pfllab\Create-CourseEnvironmentARM.ps1:32 char:5
    + if((Test-AzureResourceGroup -ResourceGroupName $GroupName) -eq $false …
    + ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Test-AzureResourceGroup:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    New-AzureResourceGroupDeployment : The term ‘New-AzureResourceGroupDeployment’ is not recognized as the name of a
    cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
    that the path is correct and try again.
    At C:\Users\purplefeetguy\Downloads\Development\IAC\azure-pfllab\Create-CourseEnvironmentARM.ps1:44 char:1
    + New-AzureResourceGroupDeployment `
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (New-AzureResourceGroupDeployment:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    C:\Users\purplefeetguy\Downloads\Development\IAC\azure-pfllab

  • Jose Castillo

    Here are some suggested updates that got me past the errors. I am sure they can be implemented better, but this works for now…

    function New-RandomString {
    $String = $null
    $r = New-Object System.Random
    1..6 | % { $String += [char]$r.next(97,122) }
    $string
    }

    ### Define variables

    $SubscriptionName = ‘Free Trial’
    $Location = ‘Central US’ ### Use “Get-AzureLocation | Where-Object Name -eq ‘ResourceGroup’ | Format-Table Name, LocationsString -Wrap” in ARM mode to find locations which support Resource Groups
    $GroupName = ‘chef-lab’
    $DeploymentName = ‘chef-server-deployment’
    $StorageName = ‘chefstorage’ + (New-RandomString)
    $PublicDNSName = ‘chef-lab-‘ + (New-RandomString)
    $AdminUsername = ‘chef’

    ### Connect to Azure account

    if (Get-AzureSubscription){
    Get-AzureSubscription -SubscriptionName $SubscriptionName | Select-AzureSubscription -Verbose
    }
    else {
    Add-AzureAccount
    Get-AzureSubscription -SubscriptionName $SubscriptionName | Select-AzureSubscription -Verbose
    login azurermaccount
    }

    ## This should no longer be needed in the updated Azure portal
    ## Switch-AzureMode AzureResourceManager -Verbose

    ### Create Resource Group ###

    ## if((Test-AzureResourceGroup -ResourceGroupName $GroupName) -eq $false){
    ## New-AzureResourceGroup -Name $GroupName -Location $Location -Verbose
    ## $ResourceGroup = Get-AzureResourceGroup -Name $GroupName
    ## }
    ## else {$ResourceGroup = Get-AzureResourceGroup -Name $GroupName}

    ## Updated for Azure Resource Manager commands
    if((get-AzureRmResourceGroup -Name $GroupName) -eq $false){
    New-AzureRmResourceGroup -Name $GroupName -Location $Location -Verbose
    $ResourceGroup = Get-AzureRmResourceGroup -Name $GroupName
    }
    else {$ResourceGroup = Get-AzureRmResourceGroup -Name $GroupName}

    $parameters = @{
    ‘newStorageAccountName’=”$StorageName”;
    ‘adminUsername’=”$AdminUsername”;
    ‘dnsNameForPublicIP’=”$PublicDNSName”
    }

    ## Updated to reflect new Azure Resource Manager commands
    ## New-AzureResourceGroupDeployment `
    New-AzureRmResourceGroupDeployment `
    -Name $DeploymentName `
    -ResourceGroupName $ResourceGroup.ResourceGroupName `
    -TemplateFile azuredeploy.json `
    -TemplateParameterObject $parameters `
    -Verbose

  • The bash i thought could be slightly improved by adding a sed replacement. Plus the random string method failed on mac. The following works fine on CentOS and Mac:

    [ijohnson@pppdc9prdclf 2-chef-planning-installing-m2-exercise-files]$ cat GenerateNames.sh
    randomString=”$RANDOM$(date +%s)”
    #`randompass 6`

    azureResourceStorageName=”chefstorage$randomString”
    azurePublicDNSName=”chef-lab-$randomString”

    sed -i -e “s/chefstorage.*/$azureResourceStorageName\”/” azuredeploy.parameters.json
    sed -i -e “s/chef-lab-.*/$azurePublicDNSName\”/” azuredeploy.parameters.json

    echo “newStorageAccountName is equal to \”$azureResourceStorageName\””
    echo “dnsNameForPublicIP is equal to \”$azurePublicDNSName\””
    echo “Please verify these values in the azuredeploy.parameters.json file”

    Feel free to take and use without attribution.

  • Also, for those doing this on hosts behind a firewall with the azure-cli,
    first set your proxies with
    export HTTP_PROXY=(your proxy)
    export HTTPS_PROXY=(your proxy)

    but then do a little bug, turn off telemetry
    cat ~/.azure/telemetry.json
    {
    “telemetry”: false
    }

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>