No commit activity in last 3 years
No release in over 3 years
Plugin for test-kitchen that extends the chef_solo provisioner with chef_extended_attributes to use pre-existing dna.json files, and optionally, to merge those with attributes in .kitchen.yml
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

kitchen-chef-extended-attributes

Circle CI Code Climate Gem Version

Use Case

If you use chef-solo for your main workflow, then you will have dna.json files defining the attributes and run_list etc for each of your roles. This test-kitchen extension allows you to use test-kitchen as your main entry point for a chef repo level test-kitchen setup - loading the pre-existing dna.json for your nodes so that your .kitchen.yml doesn't drift from the actual setup. Additionally adding extra run list items or attributes within the .kitchen.yml file will override the json file for example adding test handler cookbooks or vagrant user sudo permissions.

Example

Given a chef repository layout similar to

chef_repo
|-- .kitchen.yml
|-- Berksfile
|-- Berksfile.lock
|-- roles
|   |-- app.rb
|   `-- db.rb
`-- nodes
    |-- app.json
    `-- db.json

Use the provisioner chef_extended_attributes in your .kitchen.yml and ensure nodes_path is set appropriately

# .kitchen.yml
---
driver:
  name: vagrant

provisioner:
  name: chef_extended_attributes
  merge_attributes: true # the default
  role_path: 'roles'
  nodes_path: 'nodes'

platforms:
  - name: ubuntu-14.04
    attributes:
      authorization:
        sudo:
          users: ['vagrant']

# Suites will have node data loaded from nodes_path (nodes/<SUITENAME>.json)
suites:
  - name: app
    run_list:
      - "recipe[minitest-handler]" # this is merged with the run_list definition in nodes
    attributes:
      mysql:
        password: test-password

This will result in kitchen converge app-ubuntu-1404 running in chef-solo mode with a dna.json generated that uses the json file with the same name as the suite (e.g. nodes/app.json) your defined nodes/*.json files (where the suite name - e.g. app, and merges the overriden attributes given in the test kitchen definition.