Skip to content

Commit 765db48

Browse files
authored
Make cookbook directories clearer (#4217)
* Make directories clearer Signed-off-by: Ian Maddaus <[email protected]> * Update hugo_lint Signed-off-by: Ian Maddaus <[email protected]> * fix templates.md Signed-off-by: Ian Maddaus <[email protected]> * More minor corrections Signed-off-by: Ian Maddaus <[email protected]> * Additional fixes Signed-off-by: Ian Maddaus <[email protected]> * Additional fixes Signed-off-by: Ian Maddaus <[email protected]> * Proper indentation Signed-off-by: Ian Maddaus <[email protected]> --------- Signed-off-by: Ian Maddaus <[email protected]>
1 parent a458f36 commit 765db48

File tree

8 files changed

+220
-286
lines changed

8 files changed

+220
-286
lines changed

.expeditor/buildkite/hugo_lint.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22

33
set -euo pipefail
44

5-
LINT_STATUS="$(grep -r -I --color=auto -o --with-filename -n -P '[^\x00-\x7F]' ./content | grep -v '[✓]' &> /dev/null ; echo $?)"
5+
LINT_STATUS="$(grep -r -I --color=auto -o --with-filename -n -P '[^\x00-\x7F]' ./content | grep -v '[✓|├|─|│|└]' &> /dev/null ; echo $?)"
66

77
if [ "$LINT_STATUS" == 1 ]; then
88
echo "Success!"
99
exit 0
1010
else
1111
echo "Failure!"
12-
grep -r -I --color=auto -o --with-filename -n -P '[^\x00-\x7F]' ./content | grep -v '[✓]'
12+
grep -r -I --color=auto -o --with-filename -n -P '[^\x00-\x7F]' ./content | grep -v '[✓|├|─|│|└]'
1313
if [ "$LINT_STATUS" == 0 ]; then
1414
exit 1
1515
else
1616
exit "$LINT_STATUS"
1717
fi
1818
fi
19-

content/chef_repo.md

Lines changed: 54 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ aliases = ["/chef_repo.html"]
1111
parent = "chef_infra/cookbook_reference"
1212
weight = 15
1313
+++
14-
<!-- markdownlint-disable-file MD033 -->
14+
1515
{{< readfile file="content/reusable/md/chef_repo_description.md" >}}
1616

1717
## Generate the chef-repo
@@ -28,94 +28,88 @@ chef generate repo REPO_NAME
2828

2929
{{< /note >}}
3030

31-
## Directory Structure
31+
## Directory structure
3232

33-
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.
33+
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.
3434

3535
The default structure of a new chef-repo is:
3636

37-
```output
37+
```plain
3838
. chef-repo
39-
- cookbooks
40-
- README.md
41-
- example
42-
- attribtes
43-
- default.rb
44-
- recipes
45-
- default.rb
46-
- metadata.rb
47-
- README.md
48-
- data_bags
49-
- example
50-
- example_item.json
51-
- README.md
52-
- policyfiles
53-
- README.md
54-
- .chef-repo.txt
55-
- chefignore
56-
- License
57-
- README.md
39+
├── LICENSE
40+
├── README.md
41+
├── chefignore
42+
├── cookbooks
43+
│ ├── README.md
44+
│ └── example
45+
│ ├── README.md
46+
│ ├── attributes
47+
│ │ ├── README.md
48+
│ │ └── default.rb
49+
│ ├── metadata.rb
50+
│ └── recipes
51+
│ ├── README.md
52+
│ └── default.rb
53+
├── data_bags
54+
│ ├── README.md
55+
│ └── example
56+
│ ├── README.md
57+
│ └── example_item.json
58+
└── policyfiles
59+
└── README.md
5860
```
5961

60-
### cookbooks/
61-
62-
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.
62+
### cookbooks
6363

64-
### data_bags/
64+
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.
6565

66-
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.
66+
### data_bags
6767

68-
### policyfiles/
68+
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.
6969

70-
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.
70+
### policyfiles
7171

72-
## chefignore Files
72+
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.
7373

74-
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.
74+
### chefignore
7575

76-
- A pattern is relative to the cookbook root
77-
- A pattern may contain relative directory names
78-
- A pattern may match all files in a directory
76+
A `chefignore` file tells knife which cookbook files in the chef-repo it should ignore when uploading data to the Chef Infra Server.
77+
Include swap files, version control data, and build output data in a `chefignore` file.
7978

80-
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:
81-
82-
```none
83-
## section
84-
*ignore_pattern
79+
The `chefignore` file has the following rules:
8580

86-
## section
87-
ignore_pattern*
81+
- Patterns use `*`, `**`, and `?` wildcards to match files and directories as defined by the `File.fnmatch` Ruby method.
82+
- A pattern is relative to the directory it's included in.
83+
- A pattern may contain relative directory names.
84+
- A pattern may match all files in a directory.
85+
- You can add a `chefignore` file to any subdirectory of a chef-repo. For example, `/`, `/cookbooks`, `/cookbooks/COOKBOOK_NAME/`, etc.
86+
- Lines that start with `#` are comments.
8887

89-
## section
90-
**ignore_pattern
88+
Group types of ignored files in sections similar to the following:
9189

92-
## section
93-
ignore_pattern**
94-
95-
## section
96-
?ignore_pattern
90+
```plain
91+
## OS generated files
92+
*ignore_pattern
9793
98-
## section
99-
ignore_pattern?
94+
## Editors
95+
another_ignore_pattern*
10096
```
10197

102-
### Examples
103-
104-
The following example shows how to add entries to the `chefignore` file.
98+
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.
10599

106-
#### Ignore editor swap files
100+
#### Examples
107101

108-
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.
102+
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.
109103

110-
For Emacs:
104+
For Emacs backup files:
111105

112-
```none
106+
```plain
113107
*~
114108
```
115109

116-
and for vim:
110+
and for Vim swap files:
117111

118-
```none
112+
```plain
119113
*.sw[a-z]
120114
```
121115

content/chef_solo.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,15 @@ cookbooks be added to an archive. For example:
2828
tar zcvf chef-solo.tar.gz ./cookbooks
2929
```
3030

31-
If multiple cookbook directories are being used, chef-solo expects the
31+
If you use multiple cookbook directories, chef-solo expects the
3232
tar.gz archive to have a directory structure similar to the following:
3333

3434
```text
35-
cookbooks/
36-
|---- cbname1/
37-
|--attributes/ ... etc
38-
...
39-
|---- cbname2/
40-
|--attributes/
35+
. cookbooks
36+
├── cookbook-name-1
37+
│ └── attributes
38+
└── cookbook-name-2
39+
└── attributes
4140
```
4241

4342
The `cookbook_path` variable in the solo.rb file must include both
@@ -80,7 +79,7 @@ run-list. For example:
8079
}
8180
```
8281

83-
## Data Bags
82+
## Data bags
8483

8584
A data bag is defined using JSON. chef-solo will look for data bags in
8685
`/var/chef/data_bags`, but this location can be modified by changing the

content/cookbook_repo.md

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,19 @@ chef generate repo REPO_NAME
2929

3030
The default structure of the cookbooks directory is:
3131

32-
```output
32+
```plain
3333
. chef-repo
34-
- cookbooks
35-
- example
36-
- attributes
37-
- default.rb
38-
- recipes
39-
- default.rb
40-
- metadata.rb
41-
- README.rb
34+
└── cookbooks
35+
├── README.md
36+
└── example
37+
├── README.md
38+
├── attributes
39+
│ ├── README.md
40+
│ └── default.rb
41+
├── metadata.rb
42+
└── recipes
43+
├── README.md
44+
└── default.rb
4245
```
4346

4447
## Cookbook Commands
@@ -65,21 +68,25 @@ The `custom_web` cookbook directory has the structure:
6568

6669
```text
6770
. cookbooks
68-
- custom_web
69-
- recipes
70-
- default.rb
71-
- test
72-
- integration
73-
- default
74-
- default_test.rb
75-
- .gitignore
76-
- CHANGELOG.md
77-
- chefignore
78-
- kitchen.yml
79-
- LICENSE
80-
- metadata.rb
81-
- Policyfile.rb
82-
- README.md
71+
└── custom_web
72+
├── CHANGELOG.md
73+
├── LICENSE
74+
├── Policyfile.rb
75+
├── README.md
76+
├── chefignore
77+
├── compliance
78+
│ ├── README.md
79+
│ ├── inputs
80+
│ ├── profiles
81+
│ └── waivers
82+
├── kitchen.yml
83+
├── metadata.rb
84+
├── recipes
85+
│ └── default.rb
86+
└── test
87+
└── integration
88+
└── default
89+
└── default_test.rb
8390
```
8491

8592
Any unneeded directory components can be left unused or deleted, if

0 commit comments

Comments
 (0)