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!

 

20 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
    }

  • jai prakash

    Hi James,

    Could you please explain in details what is the benefits of having both SCCM and CHEF in same company for managing servers.
    Since deployment, compliance ,build of servers all can be done by SCCM but I am still thinking why we need Chef.
    Could you please provide some light on it ? do you think any benefits of it ?

    Regards
    Jai

    • James

      While ConfigMgr can certainly do the build, it’s not very good at compliance. Additionally, it’s not designed for code-driven infrastructure, integration with source control, automated testing or CI/CD in general. Chef is built around all of those concepts. Also, Chef works well cross-platform, whereas ConfigMgr is very much focused on Windows – support for Linux is there, but the functionality available is a very small subset of what can be done on Windows.

  • harish reddy mandadi

    1)I am trying to runn a PowerShell script (“PSS.ps1”). Its just a basic script. “helloworld” is the content inside PSS.ps1. The error is below
    error:
    helloworld : The term ‘helloworld’ 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\Harish reddy\PSS.ps1:1 char:1
    + helloworld
    + ~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (helloworld:String) [], CommandNotFoundExceptio
    n
    + FullyQualifiedErrorId : CommandNotFoundException
    2) what is create course environmentARM.ps1. whats inside that powershell script

  • harish reddy mandadi

    Hello Jose,
    After I run your code. I still get this error

    error:
    get-AzureRmResourceGroup : Run Login-AzureRmAccount to login.
    At C:\Users\Harish reddy\Create-CourseEnvironmentARM.ps1:41 char:5
    + if((get-AzureRmResourceGroup -Name $GroupName) -eq $false){
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Get-AzureRmResourceGroup], PSInvalidOper
    ationException
    + FullyQualifiedErrorId : InvalidOperation,Microsoft.Azure.Commands.ResourceManager.Cmdle
    ts.Implementation.GetAzureResourceGroupCmdlet

    New-AzureRmResourceGroupDeployment : Cannot validate argument on parameter
    ‘ResourceGroupName’. The argument is null or empty. Provide an argument that is not null or
    empty, and then try the command again.
    At C:\Users\Harish reddy\Create-CourseEnvironmentARM.ps1:57 char:20
    + -ResourceGroupName $ResourceGroup.ResourceGroupName `
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidData: (:) [New-AzureRmResourceGroupDeployment], Paramete
    rBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Azure.Commands.Resou
    rceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet

    Thankyou,
    Harish

  • satish

    Why to do this much resources add, and setup administrator when you can just create a VM & run deb file of server, work station? Why those steps before installing chef-server from deb? In my case, i just created VM & started running deb files of chef-server, ..etc which is working file

  • Anh

    Hi James, I am new to chef and enjoying your “Getting Productive with Chef Cookbooks” course! I was trying to follow along with your all-nodes cookbook but getting HTTPServerException: 412 Precondition Failed! The stacktrace is not very helpful and I am unable to locate any helpful solution on the net – so I decided to ask you directly! Would you be able to help or point me to some place where I can get a solution to this error? knife cookbook list lists all-nodes 0.1.0, chef-client 11.3.0, cron 6.2.1 and logrotate 2.2.0. Please let me know if you need additional info. Thanks in advance for your help in anticipation.

    • James

      Sorry that you’ve run in to issues accessing the necessary course resources. It’s been a while since I wrote that course, so it’s possible that some of the resources are out of date. One thing I will say is that I’m working with Pluralsight to bring all those Chef courses up to date, so keep an eye out in your Pluralsight subscription. Regards, James

  • Anh

    Hi, I am a chef newbie and was trying to follow along with the examples in the Getting Productive with Chef Cookbooks course. I downloaded the windows and chef-handler cookbooks but could not download the lab-windows cookbook. Can someone please provide me with a sample lab-windows.rb role definition? Without the roles cookbook, I am unable to complete the all-nodes run_list, and getting a “HTTPServerException: 412 ‘Precondition Failed’ error!”

  • Hi,

    I was following along Mr Bannan’s “Getting Productive with Chef Cookbooks” course in Pluralsight, and got stuck in the final step of deploying IIS web server on a Node, with the error: “Installing roles and features using Powershell Desired State Configuration is supported only on Server SKU’s. It is not supported on Client SKU.” – this is looking like a serious issue!!! I am using a Windows10 Workstation, and was trying to deploy the IIS web server onto another Windows10 node!!! Is there any work around for the stated problem? Any helpful tips is most welcome. My aim is to be able to successfully automate the web server deployment using Chef. Thanks in advance!

    • James

      Hi – in this case the error is exactly correct. You can’t use PowerShell DSC to install IIS on a Windows 10 operating system. That’s only available on Windows Server, so unfortunately this lab isn’t going to work on a workstation-class Windows OS. You will need to use Windows Server to complete the lab. Regards, James

      • James: thanks very much for the prompt reply with clarification. I was hoping there might be a workaround – now at least I don’t have to waste time trying to find an impossible solution, instead work on configuring the Chef Workstation on a Windows Server! Regards, Anh

  • I was following along Mr Bannan’s “Getting Productive with Chef Cookbooks” course in Pluralsight, and got stuck in the final step of deploying IIS web server on a Node, with the error: “Installing roles and features using Powershell Desired State Configuration is supported only on Server SKU’s. It is not supported on Client SKU.” – this is looking like a serious issue!!! I am using a Windows10 Workstation, and was trying to deploy the IIS web server onto another Windows10 node!!! Is there any work around for the stated problem? Any helpful tips is most welcome. My aim is to be able to successfully automate the web server deployment using Chef. Thanks in advance!

  • This is a New Issue! Not same as my earlier post!

    I was following along Mr Bannan’s “Getting Productive with Chef Cookbooks” course in Pluralsight, and got stuck in the final step of deploying IIS web server on a Node, with the error: “Installing roles and features using Powershell Desired State Configuration is supported only on Server SKU’s. It is not supported on Client SKU.” – this is looking like a serious issue!!! I am using a Windows10 Workstation, and was trying to deploy the IIS web server onto another Windows10 node!!! Is there any work around for the stated problem? Any helpful tips is most welcome. My aim is to be able to successfully automate the web server deployment using Chef. Thanks in advance!

  • Chef Anh

    James, thank you again for your response to my earlier post. “HTTPServerException: 412 ‘Precondition Failed’ error!”, I found out – implies that some dependencies are missing from the cookbook, and needs to be defined in the metadata.rb. Very happy to know that the Pluralsight courses are being updated, that will be very helpful! Regards, Anh [Sorry for the multiple posts, I clicked more than once]

  • Hi James, Anh here again! I provisioned a Windows Server 2016 machine and continued from where I left off last time – in my pursuit to create a Node and deploy IIS on it. This time I am getting “Bundler::HTTPError Could not fetch specs from //www.rubygems.org/” while running exception handlers during installation of Cookbook Gems. I tried to google for some solution or workaround and found there are lot of discussions but all going in different directions! I believe it is trying to get the latest specs but cannot connect; I was able to manually download the latest-specs.4.8.gz and gunzip it but not sure how to make use of it! Just wondering if maybe you can provide some helpful hints, when you get a chance! Thanks much, Anh

  • Ok, I was finally able to resolve that rubygems.org connection problem by getting the right Proxy settings for my org. I then proceeded to work on the SQL Server deployment by using the webapp-windows cookbook and ran into the Error: “FATAL: node[‘sql_server’][‘server_sa_password’] must be set for this cookbook to run! Assuming I can obtain the server_sa_password from the SA/DBA, how would I pass that info in the cookbook? //technet.microsoft.com/library/ms144259 tries to explain but it looks like the password can be set only after the SQLServer is deployed: setup.exe /[Option] /[Option] = {value} … or, is there a workaround?

Leave a Reply to Jose Castillo Cancel 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>