Search code examples
chef-infrachef-solo

role's run_list is been overrided by env_run_lists


I can't seem to understand why i get a different run result what i run chef, in different environments. I have for the following setup:

a node.json file

{"run_list:" ["role[webfront]"]}

a webfront.json role:

{
    "name": "webfront",
    "chef_type": "role",
    "json_class": "Chef::Role",
    "description": "The base role for systems that serve HTTP traffic",

    "default_attributes": {},

    "override_attributes": {},

    "run_list": [
            "recipe[apt]",
            "recipe[java]",
            "role[apache-server]",
            "role[node-server]"
    ],

    "env_run_lists" : {
            "sandbox" : [
                    "role[redis-server]"
            ],
            "dev": [
                    "role[redis-server]"
            ]
    }

}

If i run:

sudo chef-solo -c solo.rb -j node.json -E sandbox

I get a different result then if i run it without no env at all:

sudo chef-solo -c solo.rb -j node.json

When i include the "sandbox" environment, only the env_run_lists recipes are included in the chef run

Why is that ?

Thanks!


Solution

  • Because that is how the feature works. If you are presuming the the environment-specific run list gets appended instead of replacing the default that would substantially limit the feature since you wouldn't be able to remove things from the default or change order.