5

Background

  • I am tasked with setting up a Chef server on our Azure Cloud for a new DevOps automation project.
  • We are using the Resource Manager model for Azure, in case it's relevant.
  • We will likely use free versions of Chef i.e. Chef Automate is not an option.

Objective

I am new to Chef and Azure, but I would like to try to do it the "right" way from the start. Specifically: Given the Chef server will eventually become an indispensable part of the DevOps infrastructure I want to make it provisionable through code.

To move toward achieving these objectives I have explored the following options.

Option 1: Chef to provision Chef Server

Use Chef Server cookbooks and Chef solo to provision Chef server.

In such a scenario, my main question is: how do I create the Chef server VM and make Chef Solo discover it?

Option 2: Use Azure CLI + RM Templates

  1. Manually create Azure VM
  2. Manually install Chef server
  3. Save it as an image and Azure RM template
  4. Use Azure CLI to provision from the RM Template and Image.

I am angling toward this option, but I have some anecdotal opinions from teammates, that Azure RM Templates wll not be declarative. Are they?

Option 3: Use Vagrant + Azure Provider + Chef Solo

  1. (This option is primarily because I am comfortable with Vagrant)
  2. The main advantage of this option is that I think it will eliminate the question I had in Option 1. Is my assumption here correct?
  3. However, I think this option does not work for a permanent infrastructure like Chef Server, I think Vagrant is more useful when you have disposable cloud-based virtualized environments. Is my understanding here correct?

Note: Obviously these are not the only 3 options. Please help with any strategies I might have missed.

  • 1
    That's so opinion based and dependent on your wishes I've no idea what you're after, installing a chef server is quite straightforward (kind of apt-get install chef-server ) unless you have specific requirements in term of certificates and hostname where you'll need to setup a minimal chef-server.rb and run chef-server-ctl reconfigure... – Tensibai Mar 7 '18 at 13:50
  • My purpose in asking the question is to find out how creating a Chef Server using Infrastructure-as-Code is generally done. Like you rightly pointed out, there are specific requirements beyond the apt-get that need to be fulfilled - which is why I asked the question here in the first place. I chose not to detail all these reqs (partly because I have a lack of visibility into all of those at this stage). I do believe there is a "right" way of doing things here, need an answer from the audience. Having said that, is there an edit I can make to improve the question? – Vish Mar 8 '18 at 4:48
  • There's no silver bullet or right way, everyone has its own right way. Installing chef-server.rb in IaC is not really different than installing nginx or apache, the right way for you would be to use the same methodology... – Tensibai Mar 8 '18 at 6:02
  • 1
    Actually, its not quite the same as installing Nginx or Apache. Those can be installed with Chef. But if the issue is that Chef doesn't exist yet, then the question is: how do you properly install your CM tool before you have a CM tool. Seems like a perfectly valid question to me. – BoomShadow Mar 9 '18 at 16:02
  • @BoomShadow This is the same, the problem of having the CM tool on the machine is a different problem. Installing a chef-server would obviously avoid using a chef-server and as such use chef-solo with standalone cookbooks. But the core principles are the same. – Tensibai Mar 9 '18 at 16:35
2

'Suitable' can honestly be whatever works for you. I personally feel its perfectly reasonable to do a manual install of Chef server. It is the CM tool to help provision the rest of your fleet. You will not be setting up Chef server over and over again. You do it once, and then never again, in theory.

That theory breaks down however, in respect to server outages. Eventually, one day, your Chef server will go down. If you are running Chef in HA mode, or you have a very good backup system that allows you to restore the entire server, then you are fine. I don't know what it is for Azure, but with Amazon, you can take nightly snapshots of the entire server and simply restore from the AMI if the server ever goes "hard down".

Let's pretend that you don't run Chef in HA, or you aren't very confident in your backup system, or you just want to tinker... my recommendation would be to leverage Terraform w/provisioner scripts, or Packer with Terraform.

You can get the basics of Chef server setup with some simple commands that only need to be run once. This is perfect for Terraform and it's provisioner scripts. Obviously, it runs the provisioner scripts only once (during server creation) and that's all you need for Chef. If something happens to your Chef server, Terraform can rebuild it from scratch. Although, you'll have to re-key your local client and tie all your instances to the new Chef server. This is a huge headache and I would not recommend ever doing that if you can avoid it. :P

  • 2
    Knife backup works well to export all nodes/client/environment/users and restore them also, some even use knife download to get things in json format and push them in git for historical purposes. – Tensibai Mar 9 '18 at 16:33

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.