1.

What are the Policyfiles? Why are they used?

Answer»

Policyfiles are used to combine the advantages of roles and environment with Berkshelf.In usual Chef Workflow, the versions and the LOCATIONS of COOKBOOKS being used by a Chef Client are updated in “metadata.rb” file and “Berksfile”. Often this is a tedious task and a SMALL error in these FILES make Chef Client apply the wrong cookbook and converged node would not acquire the required state. These problems could be solved by using a single document called Policyfiles to get the specific cookbook revisions and recipes that Chef Infra Client would apply. Policyfiles are applied on a GROUP of nodes, cookbooks or settings. The syntax for a Policyfile.rb file is as follows:

name "name" run_list "ITEM", "ITEM", ... default_source :SOURCE_TYPE, *args cookbook "NAME" [, "VERSION_CONSTRAINT"] [, SOURCE_OPTIONS]

where 

  • “name” is the name of the policy
  • “run_list “ is the list of recipes applied by Chef Client on all nodes associated with the policy
  • “default_source” specifies the location of the cookbook
  •  “cookbook” defines the name of the cookbook and version constraints. An alternate source path for the cookbook could also be specified here.


Discussion

No Comment Found