I have 2 roles:
base.json
{
"chef_type": "role",
"default_attributes": {},
"description": "Base Machine",
"env_run_lists": {},
"json_class": "Chef::Role",
"name": "base",
"override_attributes": {},
"run_list": [
"recipe[apt]",
"recipe[clean-up]"
]
}
web.json which includes base role
{
"chef_type": "role",
"default_attributes": {},
"description": "Web Machine",
"env_run_lists": {},
"json_class": "Chef::Role",
"name": "web",
"override_attributes": {},
"run_list": [
"role[base]",
"recipe[nginx]",
"recipe[clean-up]"
]
}
when I run, the run_list will be expanded as: recipe[apt], recipe[clean-up], recipe[nginx]. Note that it skipped the last recipe[clean-up] of the web role. Why is it? Is there anyway that I can force to rerun recipe[clean-up]?
No, Chef is a configuration management system, not a script runner.
Each recipe is supposed to be run once and get the system in a particular state.
This is done in many phases:
More details here
The main idea is to decribe a system state, and be able to run N times not changing the system if it's in the desired state.
You can remove this recipe from your base role or you can do a "closing" role wich you ensure appear at the end of each node runlist.