Adding Attributes to Test Kitchen
Asked Answered
V

1

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".

Vandavandal answered 22/4, 2014 at 15:53 Comment(3)
Supply the attributes also as yaml, not as json.Prologize
Thanks, that worked. Do you want to post the answer for credit?Vandavandal
Thanks for that, I'm glad that it helped. While searching for any documentation I am wondering about the example in the github wiki.Prologize
P
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' } }
Prologize answered 22/4, 2014 at 22:10 Comment(3)
so the {} braces aren't needed? I've been using them successfully. example: attributes: { 'java': { 'install_flavor': 'oracle' } }Vandavandal
I'm using the complete yaml style here, 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.Prologize
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" }Betulaceous

© 2022 - 2024 — McMap. All rights reserved.