Overriding attributes in the recipe

前端 未结 3 846
我在风中等你
我在风中等你 2020-12-24 05:46

Let\'s say I have a default attribute in a cookbook:

default.nginx_upstreams = {
    \'service1\' => [\'service1.server.com\'],
    \'service2\' => [\'         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-24 06:12

    So after digging around, I found the answer:

    node.set
    Use node.default (or maybe node.override) instead of node.set because node.set is an alias for node.normal. Normal data is persisted on the node object. Therefore, using node.set will persist data in the node object. If the code that uses node.set is later removed, if that data has already been set on the node, it will remain.

    Normal and override attributes are cleared at the start of the chef-client run, and are then rebuilt as part of the run based on the code in the cookbooks and recipes at that time.

    node.set (and node.normal) should only be used to do something like generate a password for a database on the first chef-client run, after which it’s remembered (instead of persisted). Even this case should be avoided, as using a data bag is the recommended way to store this type of data.

提交回复
热议问题