【问题标题】:test-kitchen: how to read platform specific attributes in kitchen.yml测试厨房:如何在 kitchen.yml 中读取平台特定属性
【发布时间】:2015-06-10 05:50:20
【问题描述】:

在我的.kitchen.yml 配置中,我尝试根据平台版本应用属性。我的厨房配置如下:

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"

kitchen converge 过程中,我无法正确获取pg_version 值。对于我的厨师脚本pp node.debug_value('pg_version') 中的这段代码,输出如下:

   [["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]]

我不清楚这个结果。我假设我在platforms yml 部分中指定的属性的优先级是normal,那么我怎样才能得到它呢?

用户danieljimenez也提出了类似的问题here

【问题讨论】:

  • 您能告诉我们您是如何访问该属性的吗?我希望它在node['pg_version']
  • @Martin 刚刚更新
  • @Martin 这是否意味着所有平台属性默认为normal 优先级,我们需要像node.normal['pg_version'] 一样使用smth?

标签: amazon-ec2 chef-infra test-kitchen chefdk


【解决方案1】:

各种优先级合并为一个node 对象。在您的情况下,您需要使用 node['pg_version'] 访问它。设置值时只需要node.defaultnode.setnode.override即可。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-07
    • 1970-01-01
    • 1970-01-01
    • 2020-05-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多