0

I have the following chef attribute that i'm trying to convert to YAML for test-kitchen:

default['attr1']['attr2'] = {
    "setting1" => {
        "key1" => "value1",
        "key2" => "value2",
        "key3" => false
    },
};

What would this look like in YAML so test-kitchen will override it properly? I want to override the false value to true for specific test-kitchen drivers.

There is a similar SO question: Adding Attributes to Test Kitchen but the attribute i'm trying to convert is more complicated (i.e the value is not a simple string).

2 Answers 2

2

Should be

attr1:
  attr2:
    setting1:
      key1: value1
      key2: value2
      key3: false
1

My best idea, use irb:

irb(main):001:0> h={
irb(main):002:1*     "setting1" => {
irb(main):003:2*         "key1" => "value1",
irb(main):004:2*         "key2" => "value2",
irb(main):005:2*         "key3" => false
irb(main):006:2>     },
irb(main):007:1* }
=> {"setting1"=>{"key1"=>"value1", "key2"=>"value2", "key3"=>false}}

irb(main):010:0> require 'yaml'
=> true

irb(main):011:0> h.to_yaml
=> "---\nsetting1:\n  key1: value1\n  key2: value2\n  key3: false\n"

Disclaimer: I'm not using test-kitchen nor yaml usually, so it may or may not work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.