Search code examples
vagrantchef-infratest-kitchen

How to change box name in Chef kitchen.yml?


I have created my kitchen.yml in the following way:

---
driver:
  name: vagrant
  customize:
    memory: 2048

driver_config:
  require_chef_omnibus: true
  use_vagrant_berkshelf_plugin: true

provisioner:
  name: chef_zero
  chef_omnibus_url: http://box-url/install.sh

platforms:
  - name: prod.abc.com
    driver:
      box_url: http://abc.box
    run_list:
      - role[new_role]

suites:
  - name: default

In the above kitchen.yml, I get the hostname of the machine as default-prodabccom. However, I want the hostname to be prod.abc.com

What changes should i made in my kitchen.yml to get the correct name?


Solution

  • Hostname of the Guest System

    In order to define the hostname of the operating system running inside the VM (cf. /etc/hostname), use the vm_hostname option of the kitchen-vagrant driver:

    platforms:
      - name: prod.abc.com
        driver_config:
          vm_hostname: prod.abc.com
    

    Name of the Test-Kitchen Suite/Platform

    To rename the suite-platform combination shown in Converging <default-prodabccom>, you can only play with name of suite and platform, i.e., to get production-abccom. This name is computed here in test-kitchen and, e.g., all dots are stripped, which cannot simply be changed.

    Nevertheless, if I understand it right that you want to change this name: it makes little sense to me. Don't change that.

    Name of the VM in VirtualBox

    The name of the VM (e.g. kitchen-default-prodabcom_..default_1234..) is derived here in kitchen-vagrant and cannot easily be changed.