简体   繁体   English

如何在以JSON格式定义的Chef角色内使用OHAI属性?

[英]How to use OHAI attributes within a chef role that is defined in JSON format?

I want to know what is the correct way to assign node['ipaddress'] OHAI attribute within the chef role. 我想知道在厨师角色内分配node['ipaddress'] OHAI属性的正确方法是什么。 My chef role is defined in the JSON format . 我的厨师角色是以JSON format定义的。

{  
  "name": "temp_role",  
  "description": "This is temp role",  
  "json_class": "Chef::Role",  
  "default_attributes": {  
"client_addr": #{node['ipaddress']}  
  },  
  "override_attributes": {  
  },    
  "chef_type": "role",  
  "run_list": [  
   "recipe[test::prereq]"  
  ],  
  "env_run_lists": {  
  }  
}  

You cannot use ohai data in roles, JSON format or otherwise. 您不能使用角色,JSON格式或其他形式的ohai数据。 Roles are purely static data, converted to JSON during upload even if they are using the .rb DSL. 角色是纯静态数据,即使在使用.rb DSL的情况下,也会在上传过程中转换为JSON。 anything dynamic must live in a cookbook, in this case probably a role-pattern cookbook. 任何动态内容都必须存在于食谱中,在这种情况下,可能是角色模式食谱。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM