Category Archives: DevOps
Setup Chef Server on Microsoft Azure
This is the second post in the Chef and Microsoft Azure blog series. You can read the first blog in this series at https://manesh.me/2015/10/17/setup-chef-workstation-on-microsoft-azure/
In this blog, I am exploring how to setup a Chef Server on Microsoft Azure. For most part, I followed the steps suggested in https://docs.chef.io/azure_portal.html
Prerequisites
- Microsoft Azure Subscription
Setup Sequence
- Create Virtual Machine
- Set DNS Name Label for virtual machine
- Configure Chef Server
- Create Organization
- Establish Connectivity from Workstation
Create Virtual Machine
Navigate to https://portal.azure.com and login using your credentials.
Click New, then Compute, then Marketplace
Search for Chef Server, then select Chef Server 12, BYOL.
Note: Chef provides a fully functional Chef server that can be launched from the Azure Marketplace. This server is preconfigured with Chef Server, the Chef Management console, Chef reporting, and Chef Analytics. This configuration is free to use for deployments under 25 nodes, and can be licensed for deployments beyond 25 nodes.
Choose Resource Manager as the deployment model and click Create
Provide basic settings and click OK.
Click Size, then A5 Standard, then Select
Click Settings and then OK. Choose the default options, unless you want to change something.
Click Summary, review summary and click OK
Click Buy on left menu, review offer details and click Buy button
Wait for the newly created server to be in Running state.
Set DNS Name Label for virtual machine
Click Virtual machines, then mme-chef-server
Click on IP Address
Click on Settings, then Configuration
Update DNS name label and click Save
DNS name for the virtual machine in this case is ‘mme-chef-server.southcentralus.cloudapp.azure.com’. Wait for 5 minutes and check if you are able to ssh to the server using ‘ssh chefadmin@mme-chef-server.southcentralus.cloudapp.azure.com‘
Configure Chef Server
Open Git Bash and run the following commands.
# Here chefadmin is the admin user created during virtual machine creation.
# Provide DNS name label of the virtual machine ssh chefadmin@mme-chef-server.southcentralus.cloudapp.azure.com #sudo chef-setup -u <username> -p <password> -d <fqdn> #Here username is a new user, which will be created in this process. # You will use this username to connect form portal sudo chef-setup -u admin -p Demo@Pass1 –d mme-chef-server.southcentralus.cloudapp.azure.com |
Create Organization
Browse https://mme-chef-server.southcentralus.cloudapp.azure.com
Enter Username (specified during chef-setup), Password (specified during chef-setup) and click Sign In
Click Create New Organization
Provide Full Name, Short Name, then click Create Organization
Click on Administration, then Organizations, then contoso
Click Starter Kit, then Download Starter Kit
Click Proceed
Save chef-starter.zip locally. In my machine (Windows Laptop), it saved by default in the Downloads folder.
Establish Connectivity from Workstation
Copy the downloaded chef-starter.zip from local machine to Chef Workstation (I am copying it to workstation, I created as per the first blog in this series). I used the following command to copy the file from Git Bash. You might have to change according to your environment.
scp Downloads/chef-starter.zip azureuser@mme-chef-ws.cloudapp.net:/home/azureuser |
SSH into workstation
ssh azureuser@mme-chef-ws.cloudapp.net |
Execute following commands to get SSL keys and test connection to Chef Server
# move to home directory of azureuser
cd # install unzip utility sudo apt-get install unzip # unzip the starter kit unzip chef-starter.zip # move to chef-repo directory cd chef-repo # retrieve SSL keys from server knife ssl fetch # test connection to server, we should see contoso-validator knife client list |
Next Blog
Next, I will try out adding a Chef Node to the organization and running cookbooks.
Setup Chef Workstation on Microsoft Azure
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.
Prerequisites
- 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
Click OK
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 azureuser@vmname.cloudapp.net’
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 Blog
Next, I will try out configuring Chef Server and node on Azure.