Answers: <p>'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 <em>theory</em>.</p>
  
  <p>That theory breaks down however, in respect to server outages. Eventually, one day, your Chef server <em>will</em> 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".</p>
  
  <p>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.</p>
  
  <p>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</p>
  
Answers: CC BY-SA 3.0
Answers: 2018-03-09T16:33:55.840Z
Answers: 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.
Answers: Tensibai
Answers: CC BY-SA 3.0
Answers: 2018-03-09T16:11:43.440Z
Answers: 2018-03-09T16:11:43.440Z
Answers: BoomShadow
Body: <p><strong>Background</strong></p>
  
  <ul>
  <li>I am tasked with setting up a Chef server on our Azure Cloud for a new DevOps automation project. </li>
  <li>We are using the Resource Manager model for Azure, in case it's relevant.</li>
  <li>We will likely use free versions of Chef i.e. Chef Automate is not an option.</li>
  </ul>
  
  <p><strong>Objective</strong></p>
  
  <p>I am new to Chef and Azure, but I would like to <em>try</em> 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.</p>
  
  <p>To move toward achieving these objectives I have explored the following options. </p>
  
  <p><strong>Option 1: Chef to provision Chef Server</strong></p>
  
  <p>Use <a href="https://github.com/chef-cookbooks/chef-server" rel="noreferrer">Chef Server cookbooks</a> and Chef solo to provision Chef server.</p>
  
  <p>In such a scenario, my main question is: how do I <em>create</em> the Chef server VM and make Chef Solo discover it?</p>
  
  <p><strong>Option 2: Use Azure CLI + RM Templates</strong></p>
  
  <ol>
  <li>Manually create Azure VM </li>
  <li>Manually install Chef server</li>
  <li>Save it as an image and Azure RM template</li>
  <li>Use Azure CLI to provision from the RM Template and Image.</li>
  </ol>
  
  <p>I am angling toward this option, but I have some anecdotal opinions from teammates, that Azure RM Templates wll not be declarative. Are they? </p>
  
  <p><strong>Option 3: Use Vagrant  + Azure Provider + Chef Solo</strong></p>
  
  <ol>
  <li>(This option is primarily because I am comfortable with Vagrant)</li>
  <li>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?</li>
  <li>However, I think this option does not work for a permanent infrastructure like Chef Server, I think Vagrant is more useful when you have <em>disposable cloud-based virtualized environments.</em> Is my understanding here correct?</li>
  </ol>
  
  <p><em>Note: Obviously these are not the only 3 options. Please help with any strategies I might have missed.</em></p>
  
Comments: CC BY-SA 3.0
Comments: 2018-03-07T13:50:33.587Z
Comments: 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...
Comments: Tensibai
Comments: CC BY-SA 3.0
Comments: 2018-03-08T04:48:42.050Z
Comments: 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?
Comments: Vish
Comments: CC BY-SA 3.0
Comments: 2018-03-08T06:02:13.643Z
Comments: 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...
Comments: Tensibai
Comments: CC BY-SA 3.0
Comments: 2018-03-09T16:02:39.017Z
Comments: 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.
Comments: BoomShadow
Comments: CC BY-SA 3.0
Comments: 2018-03-09T16:35:06.147Z
Comments: @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.
Comments: Tensibai
Comments: CC BY-SA 3.0
Comments: 2018-03-10T02:11:48.340Z
Comments: @BoomShadow -  thanks for articulating what I could not.
Comments: Vish
Comments: CC BY-SA 3.0
Comments: 2018-03-10T02:11:59.707Z
Comments: @Tensibai "_Installing a chef-server would obviously avoid using a chef-server and as such use chef-solo with standalone cookbooks_" sounds like Option 1 that I mentioned. In such a case (as asked in the question) how would I create the Azure VM through Chef _and_ make Chef Solo discover it and provision it, instead of running locally?
Comments: Vish
Tags: <chef><azure><vagrant><infrastructure-as-code>
Title: What is a suitable strategy for provisioning Chef Server through code?
UserDisplayName: Vish
ThreadText: # What is a suitable strategy for provisioning Chef Server through code?
  
  (Asked by: username_0 on 2018-03-07)
  
  **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](https://github.com/chef-cookbooks/chef-server) 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.*
  
  **Tags:** chef, azure, vagrant, infrastructure-as-code
  
  > **Comments:**
  > **username_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...  
  > **username_0**: 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?  
  > **username_1**: 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...  
  > **username_2**: 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.  
  > **username_1**: @username_2 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.  
  > **username_0**: @username_2 -  thanks for articulating what I could not.  
  > **username_0**: @username_1 "_Installing a chef-server would obviously avoid using a chef-server and as such use chef-solo with standalone cookbooks_" sounds like Option 1 that I mentioned. In such a case (as asked in the question) how would I create the Azure VM through Chef _and_ make Chef Solo discover it and provision it, instead of running locally?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-03-09. Score: 2 | Accepted answer
  
  '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
  
  > **Comments:**
  > **username_1**: 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.  
  
  ---
  
  