title: Set up a test kitchen cookbook recipe to generate chef server inside vagrant
body: <p>I'm experimenting with chef and test kitchen.</p>
  <p>The problem I'm facing is as follows.
  I'm using arch linux and I couldn't get chef installed on my machine, so I decided to use a centos7 box for a working vm to do so.</p>
  <p>My goal is to have enterprise chef server created using a cookbook by test kitchen and have both machines (server and the working vm) accessible on the same network one depending on the other. So yeah, it's a nested setup.
  If anyone has a better idea, I'm open to different suggestions.</p>
  <p>For the working vm, I used this box:</p>
  <p><a href="https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box" rel="nofollow noreferrer">https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box</a></p>
  <p>Here's the contents of my Vagrant file:</p>
  <pre class="lang-rb prettyprint-override"><code>Vagrant.configure(2) do |config|
      config.vm.box = &quot;chef-repo&quot;
      
      config.vm.network &quot;public_network&quot;
  end
  </code></pre>
  <p>So really basic stuff ...</p>
  <p>I successfully installed chef and test kitchen on that machine and life was good.</p>
  <p>The problem now is using test kitchen to install chef server from here:</p>
  <p><a href="https://downloads.chef.io/chef-server/" rel="nofollow noreferrer">https://downloads.chef.io/chef-server/</a></p>
  <p>I created a really simple config with test kitchen that resembles the following:</p>
  <p><code>recipes/default.rb</code></p>
  <pre class="lang-rb prettyprint-override"><code>package_url = node['enterprise-chef']['url']
  package_name = ::File.basename(package_url)
  package_local_path = &quot;#{Chef::Config[:file_cache_path]}/#{package_name}&quot;
  
  # omnibus_package is remote (i.e., a URL) let's download it
  remote_file package_local_path do
    source package_url
  end
  
  package package_local_path
  
  # reconfigure the installation
  execute 'private-chef-ctl reconfigure'
  </code></pre>
  <p>...and <code>attributes/default.rb</code></p>
  <pre class="lang-rb prettyprint-override"><code>default['enterprise-chef']['url'] = 'https://web-dl.packagecloud.io/chef/stable/packages/el/7/chef-server-core-12.1.0-1.el7.x86_64.rpm'
  </code></pre>
  <p>After which I run <code>$ kitchen converge</code> and it fails miserably with this:</p>
  <pre><code>[vagrant@localhost enterprise-chef]$ kitchen converge
  -----&gt; Starting Kitchen (v1.4.0)
  -----&gt; Creating &lt;default-centos-65&gt;...
         Bringing machine 'default' up with 'virtualbox' provider...
         ==&gt; default: Importing base box 'opscode-centos-6.5'...
  ==&gt; default: Matching MAC address for NAT networking...
         ==&gt; default: Setting the name of the VM: kitchen-enterprise-chef-default-centos-65_default_1436040993946_29931
         ==&gt; default: Clearing any previously set network interfaces...
         ==&gt; default: Available bridged network interfaces:
         1) eth0
         2) eth1
         ==&gt; default: When choosing an interface, it is usually the one that is
         ==&gt; default: being used to connect to the internet.
         Vagrant is attempting to interface with the UI in a way that requires
         a TTY. Most actions in Vagrant that require a TTY have configuration
         switches to disable this requirement. Please do that or run Vagrant
         with TTY.
  &gt;&gt;&gt;&gt;&gt;&gt; ------Exception-------
  &gt;&gt;&gt;&gt;&gt;&gt; Class: Kitchen::ActionFailed
  &gt;&gt;&gt;&gt;&gt;&gt; Message: Failed to complete #create action: [Expected process to exit with [0], but received '1'
  ---- Begin output of vagrant up --no-provision --provider virtualbox ----
  STDOUT: Bringing machine 'default' up with 'virtualbox' provider...
  ==&gt; default: Importing base box 'opscode-centos-6.5'...
  ==&gt; default: Matching MAC address for NAT networking...
  ==&gt; default: Setting the name of the VM: kitchen-enterprise-chef-default-centos-65_default_1436040993946_29931
  ==&gt; default: Clearing any previously set network interfaces...
  ==&gt; default: Available bridged network interfaces:
  1) eth0
  2) eth1
  ==&gt; default: When choosing an interface, it is usually the one that is
  ==&gt; default: being used to connect to the internet.
  STDERR: Vagrant is attempting to interface with the UI in a way that requires
  a TTY. Most actions in Vagrant that require a TTY have configuration
  switches to disable this requirement. Please do that or run Vagrant
  with TTY.
  ---- End output of vagrant up --no-provision --provider virtualbox ----
  Ran vagrant up --no-provision --provider virtualbox returned 1]
  &gt;&gt;&gt;&gt;&gt;&gt; ----------------------
  &gt;&gt;&gt;&gt;&gt;&gt; Please see .kitchen/logs/kitchen.log for more details
  &gt;&gt;&gt;&gt;&gt;&gt; Also try running `kitchen diagnose --all` for configuration
  
  [vagrant@localhost enterprise-chef]$ 
  </code></pre>
  <p>I'm currently trying to figure out the problem by manually changing the <code>Vagrantfile</code> located in <code>.kitchen/kitchen-vagrant/kitchen-enterprise-chef-default-centos-65</code>:</p>
  <pre class="lang-rb prettyprint-override"><code>Vagrant.configure(&quot;2&quot;) do |c|
    c.berkshelf.enabled = false if Vagrant.has_plugin?(&quot;vagrant-berkshelf&quot;)
    c.vm.box = &quot;opscode-centos-6.5&quot;
    c.vm.box_url = &quot;https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box&quot;
  
    c.vm.network :public_network
  
    c.vm.synced_folder &quot;.&quot;, &quot;/vagrant&quot;, disabled: true
    c.vm.provider :virtualbox do |p|
    end
  end
  </code></pre>
  <p>so far, I'm getting this error:</p>
  <pre><code>[vagrant@localhost kitchen-enterprise-chef-default-centos-65]$ vagrant up
  Bringing machine 'default' up with 'virtualbox' provider...
  ==&gt; default: Clearing any previously set forwarded ports...
  ==&gt; default: Clearing any previously set network interfaces...
  ==&gt; default: Available bridged network interfaces:
  1) eth0
  2) eth1
  ==&gt; default: When choosing an interface, it is usually the one that is
  ==&gt; default: being used to connect to the internet.
      default: Which interface should the network bridge to? 1
  ==&gt; default: Preparing network interfaces based on configuration...
      default: Adapter 1: nat
      default: Adapter 2: bridged
  ==&gt; default: Forwarding ports...
      default: 22 =&gt; 2222 (adapter 1)
  ==&gt; default: Booting VM...
  ==&gt; default: Waiting for machine to boot. This may take a few minutes...
      default: SSH address: 127.0.0.1:2222
      default: SSH username: vagrant
      default: SSH auth method: private key
      default: Warning: Connection timeout. Retrying...
      default: Warning: Connection timeout. Retrying...
      default: Warning: Connection timeout. Retrying...
      default: Warning: Connection timeout. Retrying...
      default: Warning: Connection timeout. Retrying...
  ^C==&gt; default: Waiting for cleanup before exiting...
  Vagrant exited after cleanup due to external interrupt.
  $
  </code></pre>
  <p>The <code>default: Warning: Connection timeout. Retrying...</code> goes indefinitely and I'm forced to stop it.
  But the machine seems to be running, only inaccessible to the first vagrant instance.</p>
  <pre><code>[vagrant@localhost kitchen-enterprise-chef-default-centos-65]$ vagrant status
  Current machine states:
  
  default                   running (virtualbox)
  
  The VM is running. To stop this VM, you can run `vagrant halt` to
  shut it down forcefully, or you can run `vagrant suspend` to simply
  suspend the virtual machine. In either case, to restart it again,
  simply run `vagrant up`.
  [vagrant@localhost kitchen-enterprise-chef-default-centos-65]$ 
  </code></pre>
  <p>My guess is that something is terrible wrong with the network configuration.</p>
  <p>Any ideas or some feedback around my setup are very much welcome.</p>
  <p>Thank you.</p>