Method: Chef::Role.from_hash

Defined in:
lib/chef/role.rb

.from_hash(o) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/chef/role.rb', line 170

def self.from_hash(o)
  role = new
  role.name(o["name"])
  role.description(o["description"])
  role.default_attributes(o["default_attributes"])
  role.override_attributes(o["override_attributes"])

  # _default run_list is in 'run_list' for newer clients, and
  # 'recipes' for older clients.
  env_run_list_hash = { "_default" => (o.key?("run_list") ? o["run_list"] : o["recipes"]) }

  # Clients before 0.10 do not include env_run_lists, so only
  # merge if it's there.
  if o["env_run_lists"]
    env_run_list_hash.merge!(o["env_run_lists"])
  end
  role.env_run_lists(env_run_list_hash)

  role
end