cookbook_creator 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cookbook_creator.gemspec +2 -2
- data/lib/cookbook_creator/skeletons/code_generator/files/default/gitignore +2 -0
- data/lib/cookbook_creator/skeletons/code_generator/metadata.rb +4 -4
- data/lib/cookbook_creator/skeletons/code_generator/recipes/cookbook.rb +12 -3
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/Berksfile.erb +3 -0
- metadata +2 -79
- data/lib/cookbook_creator/.config_loader.rb.swp +0 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/Berksfile +0 -3
- data/lib/cookbook_creator/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md +0 -9
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/README.md +0 -28
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/cookbooks/example/README.md +0 -27
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +0 -7
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/cookbooks/example/metadata.rb +0 -3
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +0 -8
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/data_bags/README.md +0 -58
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/data_bags/example/example_item.json +0 -4
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/dot-chef-repo.txt +0 -6
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/environments/README.md +0 -9
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/environments/example.json +0 -13
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/policies/README.md +0 -24
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/roles/README.md +0 -9
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/roles/example.json +0 -13
- data/lib/cookbook_creator/skeletons/code_generator/files/default/spec_helper_policyfile.rb +0 -2
- data/lib/cookbook_creator/skeletons/code_generator/recipes/app.rb +0 -97
- data/lib/cookbook_creator/skeletons/code_generator/recipes/attribute.rb +0 -12
- data/lib/cookbook_creator/skeletons/code_generator/recipes/cookbook_file.rb +0 -24
- data/lib/cookbook_creator/skeletons/code_generator/recipes/lwrp.rb +0 -23
- data/lib/cookbook_creator/skeletons/code_generator/recipes/policyfile.rb +0 -8
- data/lib/cookbook_creator/skeletons/code_generator/recipes/recipe.rb +0 -27
- data/lib/cookbook_creator/skeletons/code_generator/recipes/repo.rb +0 -67
- data/lib/cookbook_creator/skeletons/code_generator/recipes/template.rb +0 -32
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/cookbook_file.erb +0 -1
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/repo/gitignore.erb +0 -11
- data/lib/skeletons/code_generator/files/default/Berksfile +0 -3
- data/lib/skeletons/code_generator/files/default/chefignore +0 -100
- data/lib/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md +0 -9
- data/lib/skeletons/code_generator/files/default/cookbook_readmes/README.md +0 -54
- data/lib/skeletons/code_generator/files/default/gitignore +0 -16
- data/lib/skeletons/code_generator/files/default/repo/README.md +0 -28
- data/lib/skeletons/code_generator/files/default/repo/cookbooks/example/README.md +0 -27
- data/lib/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +0 -7
- data/lib/skeletons/code_generator/files/default/repo/cookbooks/example/metadata.rb +0 -3
- data/lib/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +0 -8
- data/lib/skeletons/code_generator/files/default/repo/data_bags/README.md +0 -58
- data/lib/skeletons/code_generator/files/default/repo/data_bags/example/example_item.json +0 -4
- data/lib/skeletons/code_generator/files/default/repo/dot-chef-repo.txt +0 -6
- data/lib/skeletons/code_generator/files/default/repo/environments/README.md +0 -9
- data/lib/skeletons/code_generator/files/default/repo/environments/example.json +0 -13
- data/lib/skeletons/code_generator/files/default/repo/policies/README.md +0 -24
- data/lib/skeletons/code_generator/files/default/repo/roles/README.md +0 -9
- data/lib/skeletons/code_generator/files/default/repo/roles/example.json +0 -13
- data/lib/skeletons/code_generator/files/default/serverspec_spec_helper.rb +0 -8
- data/lib/skeletons/code_generator/files/default/spec_helper.rb +0 -2
- data/lib/skeletons/code_generator/files/default/spec_helper_policyfile.rb +0 -2
- data/lib/skeletons/code_generator/metadata.rb +0 -8
- data/lib/skeletons/code_generator/recipes/app.rb +0 -97
- data/lib/skeletons/code_generator/recipes/attribute.rb +0 -12
- data/lib/skeletons/code_generator/recipes/cookbook.rb +0 -94
- data/lib/skeletons/code_generator/recipes/cookbook_file.rb +0 -24
- data/lib/skeletons/code_generator/recipes/lwrp.rb +0 -23
- data/lib/skeletons/code_generator/recipes/policyfile.rb +0 -8
- data/lib/skeletons/code_generator/recipes/recipe.rb +0 -27
- data/lib/skeletons/code_generator/recipes/repo.rb +0 -67
- data/lib/skeletons/code_generator/recipes/template.rb +0 -32
- data/lib/skeletons/code_generator/templates/default/LICENSE.all_rights.erb +0 -3
- data/lib/skeletons/code_generator/templates/default/LICENSE.apache2.erb +0 -201
- data/lib/skeletons/code_generator/templates/default/LICENSE.gplv2.erb +0 -339
- data/lib/skeletons/code_generator/templates/default/LICENSE.gplv3.erb +0 -674
- data/lib/skeletons/code_generator/templates/default/LICENSE.mit.erb +0 -21
- data/lib/skeletons/code_generator/templates/default/Policyfile.rb.erb +0 -25
- data/lib/skeletons/code_generator/templates/default/README.md.erb +0 -4
- data/lib/skeletons/code_generator/templates/default/attribute.rb.erb +0 -0
- data/lib/skeletons/code_generator/templates/default/cookbook_file.erb +0 -0
- data/lib/skeletons/code_generator/templates/default/kitchen.yml.erb +0 -21
- data/lib/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +0 -32
- data/lib/skeletons/code_generator/templates/default/metadata.rb.erb +0 -7
- data/lib/skeletons/code_generator/templates/default/provider.rb.erb +0 -0
- data/lib/skeletons/code_generator/templates/default/recipe.rb.erb +0 -5
- data/lib/skeletons/code_generator/templates/default/recipe_spec.rb.erb +0 -20
- data/lib/skeletons/code_generator/templates/default/repo/gitignore.erb +0 -11
- data/lib/skeletons/code_generator/templates/default/resource.rb.erb +0 -0
- data/lib/skeletons/code_generator/templates/default/serverspec_default_spec.rb.erb +0 -9
- data/lib/skeletons/code_generator/templates/default/template.erb +0 -0
@@ -1,27 +0,0 @@
|
|
1
|
-
|
2
|
-
context = ChefDK::Generator.context
|
3
|
-
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
|
4
|
-
recipe_path = File.join(cookbook_dir, "recipes", "#{context.new_file_basename}.rb")
|
5
|
-
spec_helper_path = File.join(cookbook_dir, "spec", "spec_helper.rb")
|
6
|
-
spec_path = File.join(cookbook_dir, "spec", "unit", "recipes", "#{context.new_file_basename}_spec.rb")
|
7
|
-
|
8
|
-
# Chefspec
|
9
|
-
directory "#{cookbook_dir}/spec/unit/recipes" do
|
10
|
-
recursive true
|
11
|
-
end
|
12
|
-
|
13
|
-
cookbook_file spec_helper_path do
|
14
|
-
action :create_if_missing
|
15
|
-
end
|
16
|
-
|
17
|
-
template spec_path do
|
18
|
-
source "recipe_spec.rb.erb"
|
19
|
-
helpers(ChefDK::Generator::TemplateHelper)
|
20
|
-
action :create_if_missing
|
21
|
-
end
|
22
|
-
|
23
|
-
# Recipe
|
24
|
-
template recipe_path do
|
25
|
-
source "recipe.rb.erb"
|
26
|
-
helpers(ChefDK::Generator::TemplateHelper)
|
27
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
context = ChefDK::Generator.context
|
2
|
-
repo_dir = File.join(context.repo_root, context.repo_name)
|
3
|
-
|
4
|
-
# repo root dir
|
5
|
-
directory repo_dir
|
6
|
-
|
7
|
-
# Top level files
|
8
|
-
template "#{repo_dir}/LICENSE" do
|
9
|
-
source "LICENSE.#{context.license}.erb"
|
10
|
-
helpers(ChefDK::Generator::TemplateHelper)
|
11
|
-
action :create_if_missing
|
12
|
-
end
|
13
|
-
|
14
|
-
cookbook_file "#{repo_dir}/.chef-repo.txt" do
|
15
|
-
source "repo/dot-chef-repo.txt"
|
16
|
-
action :create_if_missing
|
17
|
-
end
|
18
|
-
|
19
|
-
cookbook_file "#{repo_dir}/README.md" do
|
20
|
-
source "repo/README.md"
|
21
|
-
action :create_if_missing
|
22
|
-
end
|
23
|
-
|
24
|
-
cookbook_file "#{repo_dir}/chefignore" do
|
25
|
-
source "chefignore"
|
26
|
-
action :create_if_missing
|
27
|
-
end
|
28
|
-
|
29
|
-
directories_to_create = %w{ cookbooks data_bags }
|
30
|
-
|
31
|
-
if context.use_roles
|
32
|
-
directories_to_create += %w{ roles environments }
|
33
|
-
else
|
34
|
-
directories_to_create += %w{ policies }
|
35
|
-
end
|
36
|
-
|
37
|
-
directories_to_create.each do |tlo|
|
38
|
-
remote_directory "#{repo_dir}/#{tlo}" do
|
39
|
-
source "repo/#{tlo}"
|
40
|
-
action :create_if_missing
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
cookbook_file "#{repo_dir}/cookbooks/README.md" do
|
45
|
-
if context.policy_only
|
46
|
-
source "cookbook_readmes/README-policy.md"
|
47
|
-
else
|
48
|
-
source "cookbook_readmes/README.md"
|
49
|
-
end
|
50
|
-
action :create_if_missing
|
51
|
-
end
|
52
|
-
|
53
|
-
# git
|
54
|
-
if context.have_git
|
55
|
-
if !context.skip_git_init
|
56
|
-
execute("initialize-git") do
|
57
|
-
command("git init .")
|
58
|
-
cwd repo_dir
|
59
|
-
not_if { File.exist?("#{repo_dir}/.gitignore") }
|
60
|
-
end
|
61
|
-
end
|
62
|
-
template "#{repo_dir}/.gitignore" do
|
63
|
-
source "repo/gitignore.erb"
|
64
|
-
helpers(ChefDK::Generator::TemplateHelper)
|
65
|
-
action :create_if_missing
|
66
|
-
end
|
67
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
|
2
|
-
context = ChefDK::Generator.context
|
3
|
-
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
|
4
|
-
template_dir = File.join(cookbook_dir, "templates", "default")
|
5
|
-
template_filename = context.new_file_basename
|
6
|
-
|
7
|
-
unless File.extname(template_filename) == ".erb"
|
8
|
-
# new_file_basename is a frozen string, so we have to create an entirely
|
9
|
-
# new string here instead of using concat.
|
10
|
-
template_filename = "#{template_filename}.erb"
|
11
|
-
end
|
12
|
-
|
13
|
-
template_path = File.join(cookbook_dir, "templates", "default", template_filename)
|
14
|
-
|
15
|
-
directory template_dir do
|
16
|
-
recursive true
|
17
|
-
end
|
18
|
-
|
19
|
-
if source_file = context.content_source
|
20
|
-
|
21
|
-
file template_path do
|
22
|
-
content(IO.read(source_file))
|
23
|
-
end
|
24
|
-
|
25
|
-
else
|
26
|
-
|
27
|
-
template template_path do
|
28
|
-
source "template.erb"
|
29
|
-
helpers(ChefDK::Generator::TemplateHelper)
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= license_description('#') %>
|
@@ -1,100 +0,0 @@
|
|
1
|
-
# Put files/directories that should be ignored in this file when uploading
|
2
|
-
# or sharing to the community site.
|
3
|
-
# Lines that start with '# ' are comments.
|
4
|
-
|
5
|
-
# OS generated files #
|
6
|
-
######################
|
7
|
-
.DS_Store
|
8
|
-
Icon?
|
9
|
-
nohup.out
|
10
|
-
ehthumbs.db
|
11
|
-
Thumbs.db
|
12
|
-
|
13
|
-
# SASS #
|
14
|
-
########
|
15
|
-
.sass-cache
|
16
|
-
|
17
|
-
# EDITORS #
|
18
|
-
###########
|
19
|
-
\#*
|
20
|
-
.#*
|
21
|
-
*~
|
22
|
-
*.sw[a-z]
|
23
|
-
*.bak
|
24
|
-
REVISION
|
25
|
-
TAGS*
|
26
|
-
tmtags
|
27
|
-
*_flymake.*
|
28
|
-
*_flymake
|
29
|
-
*.tmproj
|
30
|
-
.project
|
31
|
-
.settings
|
32
|
-
mkmf.log
|
33
|
-
|
34
|
-
## COMPILED ##
|
35
|
-
##############
|
36
|
-
a.out
|
37
|
-
*.o
|
38
|
-
*.pyc
|
39
|
-
*.so
|
40
|
-
*.com
|
41
|
-
*.class
|
42
|
-
*.dll
|
43
|
-
*.exe
|
44
|
-
*/rdoc/
|
45
|
-
|
46
|
-
# Testing #
|
47
|
-
###########
|
48
|
-
.watchr
|
49
|
-
.rspec
|
50
|
-
spec/*
|
51
|
-
spec/fixtures/*
|
52
|
-
test/*
|
53
|
-
features/*
|
54
|
-
examples/*
|
55
|
-
Guardfile
|
56
|
-
Procfile
|
57
|
-
.kitchen*
|
58
|
-
.rubocop.yml
|
59
|
-
|
60
|
-
# SCM #
|
61
|
-
#######
|
62
|
-
.git
|
63
|
-
*/.git
|
64
|
-
.gitignore
|
65
|
-
.gitmodules
|
66
|
-
.gitconfig
|
67
|
-
.gitattributes
|
68
|
-
.svn
|
69
|
-
*/.bzr/*
|
70
|
-
*/.hg/*
|
71
|
-
*/.svn/*
|
72
|
-
|
73
|
-
# Berkshelf #
|
74
|
-
#############
|
75
|
-
Berksfile
|
76
|
-
Berksfile.lock
|
77
|
-
cookbooks/*
|
78
|
-
tmp
|
79
|
-
|
80
|
-
# Cookbooks #
|
81
|
-
#############
|
82
|
-
CONTRIBUTING*
|
83
|
-
CHANGELOG*
|
84
|
-
TESTING*
|
85
|
-
|
86
|
-
# Strainer #
|
87
|
-
############
|
88
|
-
Colanderfile
|
89
|
-
Strainerfile
|
90
|
-
.colander
|
91
|
-
.strainer
|
92
|
-
|
93
|
-
# Vagrant #
|
94
|
-
###########
|
95
|
-
.vagrant
|
96
|
-
Vagrantfile
|
97
|
-
|
98
|
-
# Travis #
|
99
|
-
##########
|
100
|
-
.travis.yml
|
@@ -1,9 +0,0 @@
|
|
1
|
-
This directory typically contains Chef cookbooks. This repository was
|
2
|
-
generated with the '--policy-only' option, which means you have chosen
|
3
|
-
to use a workflow where each cookbook is treated as an independent
|
4
|
-
software project. As a result, any cookbooks present in this directory
|
5
|
-
are independent git projects, and the contents of this directory have
|
6
|
-
been added to .gitignore.
|
7
|
-
|
8
|
-
Love,
|
9
|
-
Chef
|
@@ -1,54 +0,0 @@
|
|
1
|
-
This directory contains the cookbooks used to configure systems in your infrastructure with Chef - an example basic cookbook called `example` has been automatically created for you.
|
2
|
-
|
3
|
-
Knife needs to be configured to know where the cookbooks are located with the `cookbook_path` setting. If this is not set, then several cookbook operations will fail to work properly.
|
4
|
-
|
5
|
-
cookbook_path ["./cookbooks"]
|
6
|
-
|
7
|
-
This setting tells knife to look for the cookbooks directory in the present working directory. This means the knife cookbook subcommands need to be run in the `chef-repo` directory itself. To make sure that the cookbooks can be found elsewhere inside the repository, use an absolute path. This is a Ruby file, so something like the following can be used:
|
8
|
-
|
9
|
-
current_dir = File.dirname(__FILE__)
|
10
|
-
cookbook_path ["#{current_dir}/../cookbooks"]
|
11
|
-
|
12
|
-
Which will set `current_dir` to the location of the knife.rb file itself (e.g. `~/chef-repo/.chef/knife.rb`).
|
13
|
-
|
14
|
-
Configure knife to use your preferred copyright holder, email contact and license. Add the following lines to `.chef/knife.rb`.
|
15
|
-
|
16
|
-
cookbook_copyright "Example, Com."
|
17
|
-
cookbook_email "cookbooks@example.com"
|
18
|
-
cookbook_license "apachev2"
|
19
|
-
|
20
|
-
Supported values for `cookbook_license` are "apachev2", "mit","gplv2","gplv3", or "none". These settings are used to prefill comments in the default recipe, and the corresponding values in the metadata.rb. You are free to change the the comments in those files.
|
21
|
-
|
22
|
-
Create new cookbooks in this directory with Knife.
|
23
|
-
|
24
|
-
knife cookbook create COOKBOOK
|
25
|
-
|
26
|
-
This will create all the cookbook directory components. You don't need to use them all, and can delete the ones you don't need. It also creates a README file, metadata.rb and default recipe.
|
27
|
-
|
28
|
-
You can also download cookbooks directly from the Opscode Cookbook Site. There are two subcommands to help with this depending on what your preference is.
|
29
|
-
|
30
|
-
The first and recommended method is to use a vendor branch if you're using Git. This is automatically handled with Knife.
|
31
|
-
|
32
|
-
knife cookbook site install COOKBOOK
|
33
|
-
|
34
|
-
This will:
|
35
|
-
|
36
|
-
* Download the cookbook tarball from the Chef Supermarket.
|
37
|
-
* Ensure its on the git master branch.
|
38
|
-
* Checks for an existing vendor branch, and creates if it doesn't.
|
39
|
-
* Checks out the vendor branch (chef-vendor-COOKBOOK).
|
40
|
-
* Removes the existing (old) version.
|
41
|
-
* Untars the cookbook tarball it downloaded in the first step.
|
42
|
-
* Adds the cookbook files to the git index and commits.
|
43
|
-
* Creates a tag for the version downloaded.
|
44
|
-
* Checks out the master branch again.
|
45
|
-
* Merges the cookbook into master.
|
46
|
-
* Repeats the above for all the cookbooks dependencies, downloading them from the community site
|
47
|
-
|
48
|
-
The last step will ensure that any local changes or modifications you have made to the cookbook are preserved, so you can keep your changes through upstream updates.
|
49
|
-
|
50
|
-
If you're not using Git, use the site download subcommand to download the tarball.
|
51
|
-
|
52
|
-
knife cookbook site download COOKBOOK
|
53
|
-
|
54
|
-
This creates the COOKBOOK.tar.gz from in the current directory (e.g., `~/chef-repo`). We recommend following a workflow similar to the above for your version control tool.
|
@@ -1,28 +0,0 @@
|
|
1
|
-
Overview
|
2
|
-
========
|
3
|
-
|
4
|
-
Every Chef installation needs a Chef Repository. This is the place where cookbooks, roles, config files and other artifacts for managing systems with Chef will live. We strongly recommend storing this repository in a version control system such as Git and treat it like source code.
|
5
|
-
|
6
|
-
While we prefer Git, and make this repository available via GitHub, you are welcome to download a tar or zip archive and use your favorite version control system to manage the code.
|
7
|
-
|
8
|
-
Repository Directories
|
9
|
-
======================
|
10
|
-
|
11
|
-
This repository contains several directories, and each directory contains a README file that describes what it is for in greater detail, and how to use it for managing your systems with Chef.
|
12
|
-
|
13
|
-
* `cookbooks/` - Cookbooks you download or create.
|
14
|
-
* `data_bags/` - Store data bags and items in .json in the repository.
|
15
|
-
* `roles/` - Store roles in .rb or .json in the repository.
|
16
|
-
* `environments/` - Store environments in .rb or .json in the repository.
|
17
|
-
|
18
|
-
Configuration
|
19
|
-
=============
|
20
|
-
|
21
|
-
The config file, `.chef/knife.rb` is a repository specific configuration file for knife. If you're using the Chef Platform, you can download one for your organization from the management console. If you're using the Open Source Chef Server, you can generate a new one with `knife configure`. For more information about configuring Knife, see the Knife documentation.
|
22
|
-
|
23
|
-
https://docs.chef.io/knife.html
|
24
|
-
|
25
|
-
Next Steps
|
26
|
-
==========
|
27
|
-
|
28
|
-
Read the README file in each of the subdirectories for more information about what goes in those directories.
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# Example
|
2
|
-
|
3
|
-
An example cookbook
|
4
|
-
|
5
|
-
## Requirements
|
6
|
-
|
7
|
-
### Platform:
|
8
|
-
|
9
|
-
*No platforms defined*
|
10
|
-
|
11
|
-
### Cookbooks:
|
12
|
-
|
13
|
-
*No dependencies defined*
|
14
|
-
|
15
|
-
## Attributes
|
16
|
-
|
17
|
-
* `node['example']['name']` - Defaults to `Sam Doe`.
|
18
|
-
|
19
|
-
## Recipes
|
20
|
-
|
21
|
-
* example::default
|
22
|
-
|
23
|
-
## License and Maintainer
|
24
|
-
|
25
|
-
Maintainer:: (<>)
|
26
|
-
|
27
|
-
License:: All rights reserved
|
data/lib/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
# This is a Chef attributes file. It can be used to specify default and override
|
2
|
-
# attributes to be applied to nodes that run this cookbook.
|
3
|
-
|
4
|
-
# Set a default name
|
5
|
-
default["example"]["name"] = "Sam Doe"
|
6
|
-
|
7
|
-
# For further information, see the Chef documentation (https://docs.chef.io/essentials_cookbook_attribute_files.html).
|
@@ -1,8 +0,0 @@
|
|
1
|
-
# This is a Chef recipe file. It can be used to specify resources which will
|
2
|
-
# apply configuration to a server.
|
3
|
-
|
4
|
-
log "Welcome to Chef, #{node["example"]["name"]}!" do
|
5
|
-
level :info
|
6
|
-
end
|
7
|
-
|
8
|
-
# For more information, see the documentation: https://docs.chef.io/essentials_cookbook_recipes.html
|
@@ -1,58 +0,0 @@
|
|
1
|
-
Data Bags
|
2
|
-
---------
|
3
|
-
|
4
|
-
This directory contains directories of the various data bags you create for your infrastructure. Each subdirectory corresponds to a data bag on the Chef Server, and contains JSON files of the items that go in the bag.
|
5
|
-
|
6
|
-
For example, in this directory you'll find an example data bag directory called `example`, which contains an item definition called `example_item.json`
|
7
|
-
|
8
|
-
Before uploading this item to the server, we must first create the data bag on the Chef Server.
|
9
|
-
|
10
|
-
knife data bag create example
|
11
|
-
|
12
|
-
Then we can upload the items in the data bag's directory to the Chef Server.
|
13
|
-
|
14
|
-
knife data bag from file example example_item.json
|
15
|
-
|
16
|
-
For more information on data bags, see the Chef wiki page:
|
17
|
-
|
18
|
-
https://docs.chef.io/essentials_data_bags.html
|
19
|
-
|
20
|
-
Encrypted Data Bags
|
21
|
-
-------------------
|
22
|
-
|
23
|
-
Added in Chef 0.10, encrypted data bags allow you to encrypt the contents of your data bags. The content of attributes will no longer be searchable. To use encrypted data bags, first you must have or create a secret key.
|
24
|
-
|
25
|
-
openssl rand -base64 512 > secret_key
|
26
|
-
|
27
|
-
You may use this secret_key to add items to a data bag during a create.
|
28
|
-
|
29
|
-
knife data bag create --secret-file secret_key passwords mysql
|
30
|
-
|
31
|
-
You may also use it when adding ITEMs from files,
|
32
|
-
|
33
|
-
knife data bag create passwords
|
34
|
-
knife data bag from file passwords data_bags/passwords/mysql.json --secret-file secret_key
|
35
|
-
|
36
|
-
The JSON for the ITEM must contain a key named "id" with a value equal to "ITEM" and the contents will be encrypted when uploaded. For example,
|
37
|
-
|
38
|
-
{
|
39
|
-
"id": "mysql",
|
40
|
-
"password": "abc123"
|
41
|
-
}
|
42
|
-
|
43
|
-
Without the secret_key, the contents are encrypted.
|
44
|
-
|
45
|
-
knife data bag show passwords mysql
|
46
|
-
id: mysql
|
47
|
-
password: 2I0XUUve1TXEojEyeGsjhw==
|
48
|
-
|
49
|
-
Use the secret_key to view the contents.
|
50
|
-
|
51
|
-
knife data bag show passwords mysql --secret-file secret_key
|
52
|
-
id: mysql
|
53
|
-
password: abc123
|
54
|
-
|
55
|
-
|
56
|
-
For more information on encrypted data bags, see the Chef wiki page:
|
57
|
-
|
58
|
-
https://docs.chef.io/essentials_data_bags.html
|
@@ -1,9 +0,0 @@
|
|
1
|
-
Create environments here, in either the Role Ruby DSL (.rb) or JSON (.json) files. To install environments on the server, use knife.
|
2
|
-
|
3
|
-
For example, in this directory you'll find an example environment file called `example.json` which can be uploaded to the Chef Server:
|
4
|
-
|
5
|
-
knife environment from file environments/example.json
|
6
|
-
|
7
|
-
For more information on environments, see the Chef wiki page:
|
8
|
-
|
9
|
-
https://docs.chef.io/environments.html
|
@@ -1,13 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "example",
|
3
|
-
"description": "This is an example environment defined as JSON",
|
4
|
-
"chef_type": "environment",
|
5
|
-
"json_class": "Chef::Environment",
|
6
|
-
"default_attributes": {
|
7
|
-
},
|
8
|
-
"override_attributes": {
|
9
|
-
},
|
10
|
-
"cookbook_versions": {
|
11
|
-
"example": "= 1.0.0"
|
12
|
-
}
|
13
|
-
}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
Create policyfiles here. When using a chef-repo, give your policyfiles
|
2
|
-
the same filename as the name set in the policyfile itself, and use the
|
3
|
-
`.rb` file extension.
|
4
|
-
|
5
|
-
Compile the policy with a command like this:
|
6
|
-
|
7
|
-
```
|
8
|
-
chef install policies/my-app-frontend.rb
|
9
|
-
```
|
10
|
-
|
11
|
-
This will create a lockfile `policies/my-app-frontend.lock.json`.
|
12
|
-
|
13
|
-
To update locked dependencies, run `chef update` like this:
|
14
|
-
|
15
|
-
```
|
16
|
-
chef update policies/my-app-fronend.rb
|
17
|
-
```
|
18
|
-
|
19
|
-
You can upload the policy (with associated cookbooks) to the server
|
20
|
-
using a command like:
|
21
|
-
|
22
|
-
```
|
23
|
-
chef push staging policies/my-app-frontend.rb
|
24
|
-
```
|
@@ -1,9 +0,0 @@
|
|
1
|
-
Create roles here, in either the Role Ruby DSL (.rb) or JSON (.json) files. To install roles on the server, use knife.
|
2
|
-
|
3
|
-
For example, in this directory you'll find an example role file called `example.json` which can be uploaded to the Chef Server:
|
4
|
-
|
5
|
-
knife role from file roles/example.json
|
6
|
-
|
7
|
-
For more information on roles, see the Chef wiki page:
|
8
|
-
|
9
|
-
https://docs.chef.io/essentials_roles.html
|