Search code examples
amazon-ec2chef-infratest-kitchenchefdk

test-kitchen: how to read platform specific attributes in kitchen.yml


In my .kitchen.yml config I am trying apply attributes depending on platform version. My kitchen config looks like that:

platforms:
  - name: centos-6.3
    driver_plugin: ec2
    driver:
      image_id: ami-xxxxxxxx
    attributes:
      pg_version: "9.3"
  - name: centos-6.5
    driver_plugin: ec2
    driver:
      image_id: ami-yyyyyyyy 
    attributes:
      pg_version: "9.4"

During kitchen converge process I am not able to get pg_version value correctly. For this code in my chef script pp node.debug_value('pg_version') output is the following:

   [["set_unless_enabled?", false],
    ["default", :not_present],
    ["env_default", :not_present],
    ["role_default", :not_present],
    ["force_default", :not_present],
    ["normal", "9.4"],
    ["override", :not_present],
    ["role_override", :not_present],
    ["env_override", :not_present],
    ["force_override", :not_present],
    ["automatic", :not_present]]

I don't clearly understand this result. I assume precedence level of the attribute I specified in platforms yml section is normal, so how can I get it?

User danieljimenez also raised similar question here.


Solution

  • The various precedence levels are merged into a single node object. You'll want to access it using node['pg_version'] in your case. You only need node.default, node.set, node.override when setting the value.