Is chef_type mandatory for a node?

188 Views Asked by At

In a project that uses Chef Server, we are using the following concepts:

  • node
  • role
  • environment

The environment and role json files looks fine (they have chef_type and json_class):

  • ENV.json

    {
        "name": "ENV",
        "chef_type": "environment",
        "json_class": "Chef::Environment",
        ...
        "cookbook_versions": {
            ...
        }
    }
    
  • my_role.json

    {
        "name": "my_role",
        "chef_type": "role",
        "json_class": "Chef::Role",
        ...
        "run_list": [
            "role[my_role]",
            "recipe[my_recipe]"
        ]
    }
    

but the node looks like this (no chef_type, no json_class):

  • my.machine.json

    {
        "chef_environment": "ENV",
        "name": "my.machine",
        "normal": {
           "key": "val"
        },    
        "run_list": [
             "role[my_role]"
        ]
    }
    

Is it a real Chef node?

And does is satisfy the following precedence?
I supposed that if I had "normal" "key":"value" in node, role and environment, the following precedence (overwriting) order was applied: node > role > environment, but according to that documentation the precedence is role > environment > recipe and the recipe is in the same table cell as node.

1

There are 1 best solutions below

2
On BEST ANSWER

We've been slowly fixing the JSON loading code to not rely on the json_class auto-inflation bits. To the best of my knowledge chef_type was never actually used, but it may still be checked for by some of the testing code.

As for the precedence question: roles and envs can contain attributes at both the default and override levels. Override > normal > default. In general we recommend against the use of the normal level. It's not deprecated but we're moving in that direction (very slowly because we have many years of compat to think about).