Setup Chef Node on Microsoft Azure
This is the third post in the Chef and Microsoft Azure blog series. You can read the previous ones at:
- https://manesh.me/2015/10/17/setup-chef-workstation-on-microsoft-azure/
- https://manesh.me/2015/10/19/setup-chef-server-on-microsoft-azure/
These blog posts will help you to learn Chef, by going through all the tutorials provided by Chef – https://learn.chef.io/tutorials/ – from Microsoft Azure. In the previous posts, we have gone through the setup of a workstation as well as server. In this post, I am exploring the tutorial https://learn.chef.io/manage-a-node/ubuntu/bootstrap-your-node/
One feedback I received is to automate using script as much as possible, than going through the web user interface. I will try to use scripts to the maximum extent possible.
Prerequisites
- Microsoft Azure Subscription
- Have gone through previous two posts in this series
Setup Sequence
- Install Azure CLI & Login
- Create Virtual Machine for Node
- Bootstrap & Verify Node
Install Azure CLI and Login
Let us make sure that we have Azure CLI on the workstation server. Execute the following commands from the workstation (We have an Ubuntu 14.04 image for the workstation).
# https://azure.microsoft.com/en-us/documentation/articles/xplat-cli-install/#install-and-use-nodejs-and-npm
sudo apt-get install nodejs-legacy sudo apt-get install npm sudo npm install -g azure-cli |
Login to Azure service from CLI. I have written a detailed step by step guidance for the same at https://manesh.me/2015/10/15/options-for-azure-cli-logins-step-by-step-guidance/. If you are looking for complete automation without any user interaction, check out the login option using service principal.
# https://manesh.me/2015/10/15/options-for-azure-cli-logins-step-by-step-guidance/
azure –version azure login |
Create Virtual Machine for Node
Next, let us create a new virtual machine to act as the Chef Node. We are executing following commands from the workstation.
# list all azure vm images for Ubuntu 14.04
azure vm image list | grep -i Ubuntu-14_04 # Note that latest image is coming at the end in the list # Note that image name is second item in the item row # Get the latest (last) image from the list imagename=`azure vm image list | grep -i Ubuntu-14_04 |tail -1 | awk ‘{print $2}’` # Learn about azure vm create options azure help vm create # Create a new vm for Chef Node # vm create [options] <dns-name> <image> [userName] [password] # SSH port 22 is enabled in endpoints as we use option -e azure vm create -e -z Small -l “South Central US” mme-chef-node1 $imagename azureuser Demo@Pass1 # Wait for couple of minutes and ensure that Status of vm created is ReadyRole azure vm list |
Bootstrap and Verify Node
From the workstation, execute the bootstrap command remotely to bootstrap the node.
# ensure you are executing these from chef-repo directory
cd cd chef-repo # test connection to server, we should see contoso-validator knife client list # knife bootstrap ADDRESS -x USER -P PASSWORD –sudo –use-sudo-password –node-name NAME knife bootstrap mme-chef-node1.cloudapp.net -x azureuser -P Demo@Pass1 –sudo –use-sudo-password –node-name mme-chef-node1 # verify that node is successfully bootstrapped knife node list |
Also, you can see the node listed in the Chef Management Portal.
Next Blog
Next, I will try out authoring some basic cookbooks and applying that policy to the node.
Posted on 2015/10/20, in DevOps, Microsoft Azure and tagged Azure CLI, Chef, Cloud, DevOps, Microsoft Azure, Ubuntu. Bookmark the permalink. 2 Comments.
Pingback: Writing cookbook on Microsoft Azure | Imagine - Experiment - Realize
Pingback: Getting started with Chef on Microsoft Azure | Imagine - Experiment - Realize