11

I'm trying to override attributes in the java cookbook with test-kitchen.

When I try run kitchen converge default-centos-64, a bad YAML error shows up.

---
driver:
  name: vagrant
  customize:
    memory: 1024
    cpuexecutioncap: 50

provisioner:
  name: chef_solo

platforms:
  - name: centos-6.4

suites:
  - name: default
    run_list: 
      - recipe[java::default]
      - recipe[maven::default]
    attributes: {
                  java.install_flavor: "oracle",
                  java.jdk_version: "7"
                }

I pasted the above into http://yamllint.com/. When I hit "Go," it removes all lines beginning at "attributes", and then shows a Green "Valid YAML".

Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384

1 Answers1

20

Attributes are supplied as normal yaml content:

suites:
  - name: default
    run_list: 
      - recipe[java::default]
      - recipe[maven::default]
    attributes:
       java:
         install_flavor: "oracle",
         jdk_version: "7"

The Getting Started shows a syntax similar to yours:

suites:
  - name: default
    run_list: 
      - recipe[java::default]
      - recipe[maven::default]
    attributes: { 'java': { 'install_flavor': 'oracle' } }
StephenKing
  • 36,187
  • 11
  • 83
  • 112
  • so the `{}` braces aren't needed? I've been using them successfully. example: `attributes: { 'java': { 'install_flavor': 'oracle' } }` – Kevin Meredith Apr 22 '14 at 22:10
  • I'm using the complete yaml style [here](https://github.com/TYPO3-cookbooks/gerrit/blob/77f05d33aefb93de670796e81c7b3322264c22a4/.kitchen.yml#L30-33), but it seems that it doesn't matter, if it is completely yaml or the whole attributes a valid json hash (I would say that yours isn't a valid json style). I'm updating my answer. – StephenKing Apr 23 '14 at 07:06
  • 1
    It's easy to confuse the new ruby hash notation with json hash notation. This is a ruby hash with a symbol called key mapped to a string "value": `{ key: "value" }`. And this is a json hash corresponding `{ "key": "value" }`. It was easier to spot ruby hashes prior to ruby 2.0 they were all like this `{ :key => "value" }` – Benjamin Hammer Nørgaard Jul 16 '14 at 11:05