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:

  1. https://manesh.me/2015/10/17/setup-chef-workstation-on-microsoft-azure/
  2. 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.

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.

About Manesh

Manesh is a software consultant and solutions architect specializing in cloud, data, Linux and devops in the azure realm with key focus on hybrid workloads. He has been working on Azure technologies since its inception and has helped many enterprises to onboard and adapt to Azure cloud, build solutions for datacenter scale / high consumer applications and services. Currently, he is Microsoft certified for Developing Microsoft Azure Solutions (70-532), Implementing Microsoft Azure Infrastructure Solutions(70-533) and Architecting Microsoft Azure Solutions (70-534).

Posted on 2015/10/20, in DevOps, Microsoft Azure and tagged , , , , , . Bookmark the permalink. 2 Comments.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

https://hyper-v.nu/

My views on technology

Virtualization and some coffee

My views on technology

Thomas Maurer

Cloud and Datacenter Blog focusing on Microsoft Azure

Cloud Administrator in Azure World

Begin Your Azure Management Journey with the Cloud Administrator

%d bloggers like this: