diff --git a/content/chef_repo.md b/content/chef_repo.md index 9c7d1ccbc6f..305a891fd4e 100644 --- a/content/chef_repo.md +++ b/content/chef_repo.md @@ -11,7 +11,7 @@ aliases = ["/chef_repo.html"] parent = "chef_infra/cookbook_reference" weight = 15 +++ - + {{< readfile file="content/reusable/md/chef_repo_description.md" >}} ## Generate the chef-repo @@ -28,94 +28,88 @@ chef generate repo REPO_NAME {{< /note >}} -## Directory Structure +## Directory structure -The chef-repo contains several directories, each with a README file that describes what it is for and how to use that directory when managing systems. +The chef-repo contains several directories, each with a README file that describes what it's for and how to use that directory when managing systems. The default structure of a new chef-repo is: -```output +```plain . chef-repo - - cookbooks - - README.md - - example - - attribtes - - default.rb - - recipes - - default.rb - - metadata.rb - - README.md - - data_bags - - example - - example_item.json - - README.md - - policyfiles - - README.md - - .chef-repo.txt - - chefignore - - License - - README.md +├── LICENSE +├── README.md +├── chefignore +├── cookbooks +│ ├── README.md +│ └── example +│ ├── README.md +│ ├── attributes +│ │ ├── README.md +│ │ └── default.rb +│ ├── metadata.rb +│ └── recipes +│ ├── README.md +│ └── default.rb +├── data_bags +│ ├── README.md +│ └── example +│ ├── README.md +│ └── example_item.json +└── policyfiles + └── README.md ``` -### cookbooks/ - -This directory contains the cookbooks that are used to configure systems in the infrastructure which are are downloaded from the [Chef Supermarket](https://supermarket.chef.io/) or created locally. The Chef Infra Client uses cookbooks to configuring the systems in the organization. Each cookbook can be configured to contain cookbook-specific copyright, email, and license data. +### cookbooks -### data_bags/ +The `cookbooks` directory contains cookbooks that configure systems in the infrastructure which are are downloaded from the [Chef Supermarket](https://supermarket.chef.io/) or created locally. The Chef Infra Client uses cookbooks to configuring the systems in the organization. Each cookbook can be configured to contain cookbook-specific copyright, email, and license data. -The `data_bags/` directory is used to store all the data bags that exist for an organization. Each sub-directory corresponds to a single data bag on the Chef Infra Server and contains a JSON file corresponding to each data bag item. +### data_bags -### policyfiles/ +The `data_bags` directory is used to store all the data bags that exist for an organization. Each sub-directory corresponds to a single data bag on the Chef Infra Server and contains a JSON file corresponding to each data bag item. -The `policyfiles/` directory is used to store Policyfiles in the `.rb` format that define the set of cookbooks and attributes to apply to specific systems managed by the Chef Infra Server. +### policyfiles -## chefignore Files +The `policyfiles` directory is used to store Policyfiles in the `.rb` format that define the set of cookbooks and attributes to apply to specific systems managed by the Chef Infra Server. -The chefignore file is used to tell knife which cookbook files in the chef-repo should be ignored when uploading data to the Chef Infra Server. The type of data that should be ignored includes swap files, version control data, build output data, and so fort. The chefignore file uses the `File.fnmatch` Ruby syntax to define the ignore patterns using `*`, `**`, and `?` wildcards. +### chefignore -- A pattern is relative to the cookbook root -- A pattern may contain relative directory names -- A pattern may match all files in a directory +A `chefignore` file tells knife which cookbook files in the chef-repo it should ignore when uploading data to the Chef Infra Server. +Include swap files, version control data, and build output data in a `chefignore` file. -The chefignore file can be located in any subdirectory of a chef-repo: `/`, `/cookbooks`, `/cookbooks/COOKBOOK_NAME/`, etc. It should contain sections similar to the following: - -```none -## section -*ignore_pattern +The `chefignore` file has the following rules: -## section -ignore_pattern* +- Patterns use `*`, `**`, and `?` wildcards to match files and directories as defined by the `File.fnmatch` Ruby method. +- A pattern is relative to the directory it's included in. +- A pattern may contain relative directory names. +- A pattern may match all files in a directory. +- You can add a `chefignore` file to any subdirectory of a chef-repo. For example, `/`, `/cookbooks`, `/cookbooks/COOKBOOK_NAME/`, etc. +- Lines that start with `#` are comments. -## section -**ignore_pattern +Group types of ignored files in sections similar to the following: -## section -ignore_pattern** - -## section -?ignore_pattern +```plain +## OS generated files +*ignore_pattern -## section -ignore_pattern? +## Editors +another_ignore_pattern* ``` -### Examples - -The following example shows how to add entries to the `chefignore` file. +See Ruby's [`File.fnmatch` documentation](https://ruby-doc.org/core-2.5.1/File.html#method-c-fnmatch) for information on creating matching file patterns. -#### Ignore editor swap files +#### Examples -Many text editors leave files behind. To prevent these files from being uploaded to the Chef Infra Server, add an entry to the `chefignore` file. +Many text editors leave files behind. To prevent knife from uploading these files to the Chef Infra Server, add an entry to the `chefignore` file. -For Emacs: +For Emacs backup files: -```none +```plain *~ ``` -and for vim: +and for Vim swap files: -```none +```plain *.sw[a-z] ``` diff --git a/content/cookbook_repo.md b/content/cookbook_repo.md index fee6066bdb0..67b0093edc4 100644 --- a/content/cookbook_repo.md +++ b/content/cookbook_repo.md @@ -29,16 +29,19 @@ chef generate repo REPO_NAME The default structure of the cookbooks directory is: -```output -. chef-repo - - cookbooks - - example - - attributes - - default.rb - - recipes - - default.rb - - metadata.rb - - README.rb +```plain +. +└── cookbooks + ├── README.md + └── example + ├── README.md + ├── attributes + │ ├── README.md + │ └── default.rb + ├── metadata.rb + └── recipes + ├── README.md + └── default.rb ``` ## Cookbook Commands @@ -65,21 +68,25 @@ The `custom_web` cookbook directory has the structure: ```text . cookbooks - - custom_web - - recipes - - default.rb - - test - - integration - - default - - default_test.rb - - .gitignore - - CHANGELOG.md - - chefignore - - kitchen.yml - - LICENSE - - metadata.rb - - Policyfile.rb - - README.md +└── custom_web + ├── CHANGELOG.md + ├── LICENSE + ├── Policyfile.rb + ├── README.md + ├── chefignore + ├── compliance + │ ├── README.md + │ ├── inputs + │ ├── profiles + │ └── waivers + ├── kitchen.yml + ├── metadata.rb + ├── recipes + │ └── default.rb + └── test + └── integration + └── default + └── default_test.rb ``` Any unneeded directory components can be left unused or deleted, if diff --git a/content/cookbooks.md b/content/cookbooks.md index 62a3250ac79..8d363d294eb 100644 --- a/content/cookbooks.md +++ b/content/cookbooks.md @@ -27,100 +27,26 @@ Chef Infra Client runs a recipe only when instructed. When Chef Infra Client run A cookbook is comprised of recipes and other optional components as files or directories. - - - ----- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ComponentFile/Directory NameDescription
Recipesrecipes/{{< readfile file="content/reusable/md/cookbooks_recipe.md" >}}
Attributesattributes/{{< readfile file="content/reusable/md/cookbooks_attribute.md" >}}
Filesfiles/A file distribution is a specific type of resource that tells a cookbook how to distribute files, including by node, by platform, or by file version.
Librarieslibraries/A library allows the use of arbitrary Ruby code in a cookbook, either as a way to extend the Chef Infra Client language or to implement a new class.
Custom Resourcesresources/A custom resource is an abstract approach for defining a set of actions and (for each action) a set of properties and validation parameters.
Templatestemplates/A template is a file written in markup language that uses Ruby statements to solve complex configuration scenarios.
Ohai Pluginsohai/Custom Ohai plugins can be written to load additional information about your nodes to be used in recipes. This requires Chef Infra Server 12.18.14 or later.
Metadatametadata.rbThis file contains information about the cookbook such as the cookbook name, description, and version.
- - +| Component | File/Directory Name | Description | +|----------------------------------------|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [Recipes](/recipes/) | recipes/ | {{< readfile file="content/reusable/md/cookbooks_recipe.md" >}} | +| [Attributes](/attributes/) | attributes/ | {{< readfile file="content/reusable/md/cookbooks_attribute.md" >}} | +| [Files](/files/) | files/ | A file distribution is a specific type of resource that tells a cookbook how to distribute files, including by node, by platform, or by file version. | +| [Libraries](/libraries/) | libraries/ | A library allows the use of arbitrary Ruby code in a cookbook, either as a way to extend the Chef Infra Client language or to implement a new class. | +| [Custom Resources](/custom_resources/) | resources/ | A custom resource is an abstract approach for defining a set of actions and (for each action) a set of properties and validation parameters. | +| [Templates](/templates/) | templates/ | A template is a file written in markup language that uses Ruby statements to solve complex configuration scenarios. | +| [Ohai Plugins](/ohai_custom/) | ohai/ | Custom Ohai plugins can be written to load additional information about your nodes to be used in recipes. This requires Chef Infra Server 12.18.14 or later. | +| [Metadata](/config_rb_metadata/) | metadata.rb | This file contains information about the cookbook such as the cookbook name, description, and version. | + ## Community Cookbooks Chef maintains a large collection of cookbooks. In addition, there are thousands of cookbooks created and maintained by the community: - - - ---- - - - - - - - - - - - - - - - - - - - - -
ComponentsDescription
Cookbooks Maintained by ChefChef maintains a collection of cookbooks that are widely used by the community.
Cookbooks Maintained by Sous ChefsSous Chefs is a community organization that collaborates to maintain many of the most used Chef cookbooks.
Cookbooks Maintained by the CommunityThe community has authored thousands of cookbooks, ranging from niche cookbooks that are used by only a few organizations to popular cookbooks used by almost everyone.
- - +| Components | Description | +|:------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------:| +| [Cookbooks Maintained by Chef](https://github.com/chef-cookbooks) | Chef maintains a collection of cookbooks that are widely used by the community. | +| [Cookbooks Maintained by Sous Chefs](https://github.com/sous-chefs) | Sous Chefs is a community organization that collaborates to maintain many of the most used Chef cookbooks. | +| [Cookbooks Maintained by the Community](https://supermarket.chef.io/cookbooks) | The community has authored thousands of cookbooks, ranging from niche cookbooks that are used by only a few organizations to popular cookbooks used by almost everyone. | ## Generate a Cookbook @@ -130,19 +56,23 @@ A cookbook generated with`chef generate cookbook custom_web` creates a cookbook ```text . cookbooks - - custom_web - - recipes - - default.rb - - test - - integration - - default - - default_test.rb - - .gitignore - - CHANGELOG.md - - chefignore - - kitchen.yml - - LICENSE - - metadata.rb - - Policyfile.rb - - README.md +└── custom_web + ├── CHANGELOG.md + ├── LICENSE + ├── Policyfile.rb + ├── README.md + ├── chefignore + ├── compliance + │ ├── README.md + │ ├── inputs + │ ├── profiles + │ └── waivers + ├── kitchen.yml + ├── metadata.rb + ├── recipes + │ └── default.rb + └── test + └── integration + └── default + └── default_test.rb ``` diff --git a/content/templates.md b/content/templates.md index 59afba1386b..25f40b22239 100644 --- a/content/templates.md +++ b/content/templates.md @@ -33,23 +33,28 @@ The `custom_web` cookbook directory with a template has the structure: ```text . cookbooks - - custom_web - - recipes - - default.rb - - templates - - http.erb - - test - - integration - - default - - default_test.rb - - .gitignore - - CHANGELOG.md - - chefignore - - kitchen.yml - - LICENSE - - metadata.rb - - Policyfile.rb - - README.md +├── README.md +└── custom_web + ├── CHANGELOG.md + ├── LICENSE + ├── Policyfile.rb + ├── README.md + ├── chefignore + ├── compliance + │   ├── README.md + │   ├── inputs + │   ├── profiles + │   └── waivers + ├── kitchen.yml + ├── metadata.rb + ├── recipes + │   └── default.rb + ├── templates + │   └── httpd.erb + └── test + └── integration + └── default + └── default_test.rb ``` ## Requirements