If you do not know how Chef helps with DevOps, I recommend you to watch this conversion https://channel9.msdn.com/events/Seth-on-the-Road/That-Conference-2015/T009, between Matt Stratton, Senior Solutions Architect at Chef and Seth Juarez, Senior Technical Evangelist on the Channel 9 team.
There are lots of tutorials and learning guides available for Chef (https://learn.chef.io/). For all my learnings, I completely depend on virtual machines on cloud, unless there is a specific need or limitation to use an on-premise VM. So when I was going through the Chef tutorials, I had to accommodate some changes based on Azure environment. I am documenting my experiments with Chef on Azure in this series of blog posts.
- Microsoft Azure Subscription
- Git Bash Shell
Create a Virtual Machine for Chef Workstation
Navigate to https://manage.windowsazure.com/ on browser
Click on the +NEW link at the bottom-left corner of the screen.
Click COMPUTE, then VIRTUAL
MACHINE, then FROM GALLERY
Click UBUNTU, then Ubuntu Server 14.04 LTS, then next arrow
Specify virtual machine configuration and click next. Note that I have used ‘mme-chef-ws’ as the name of virtual machine for Chef Workstation. This name will be used in later steps. Change it according to your environment. Also, for simplicity, I have chosen password option instead of SSH key for the VM.
Change virtual machine configuration if required. Add HTTP endpoint to the endpoints (we enable web server as part of chef learning later), and click next
Wait for the created virtual machine to be in running state.
Install Chef Development Kit
The Chef Development Kit (ChefDK) brings the best-of-breed development tools built by the awesome Chef community. Actual download site is https://downloads.chef.io/chef-dk/. However, I have followed steps in another tutorial provided by Chef.
Open Git Bash on your computer and connect to the Chef workstation. Note down the DNS name of virtual machine from the virtual machine details (above picture). Connect to the virtual machine by running the command ‘ssh email@example.com’
Run the command (curl -L http://www.getchef.com/chef/install.sh | sudo bash) to install chef client and tools on workstation.
Learn Chef Basics on Ubuntu
Now the workstation is ready for us to learn the basics of Chef. Now we can follow the tutorial provided on Chef learning site on this virtual machine.
- Configure a resource – https://learn.chef.io/learn-the-basics/ubuntu/configure-a-resource/
- Configure a package and service – https://learn.chef.io/learn-the-basics/ubuntu/configure-a-package-and-service/
- Making recipe more manageable – https://learn.chef.io/learn-the-basics/ubuntu/make-your-recipe-more-manageable/
Next, I will try out configuring Chef Server and node on Azure.
If you would like to use SSH with Linux virtual machines on Azure, there is a great documentation here. One question I have seen in the forum, which is not clearly explained in the documentation is, how do we add a new SSH authorization key, if we missed adding the SSH file, during the creation of virtual machine.
Giving the steps I have followed to setup a new SSH authorization key below:
Step 1: I created a Linux VM (Ubuntu 14) on Azure using quick create VM (linuxvmforssh.cloudapp.net).
Step 2: Executed following commands from Git shell on my Windows 8.1 laptop
GIT> ssh-keygen -t rsa -b 2048 -v -f azurecert.key GIT> scp azurecert.key.pub firstname.lastname@example.org:/home/azureuser GIT> ssh email@example.com azureuser@linuxvmforssh:~$ cat azurecert.key.pub >> .ssh/authorized_keys azureuser@linuxvmforssh:~$ sudo service ssh restart azureuser@linuxvmforssh:~$ exit GIT> ssh -i azurecert.key firstname.lastname@example.org
Hope this helps you to setup new SSH authorized keys for your Linux virtual machines.