cookbook_creator 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/bin/cookbook_create +11 -0
  3. data/cookbook_creator.gemspec +33 -0
  4. data/lib/cookbook_creator/cli.rb +100 -0
  5. data/lib/cookbook_creator/config.rb +24 -0
  6. data/lib/cookbook_creator/config_loader.rb +157 -0
  7. data/lib/cookbook_creator/generator.rb +202 -0
  8. data/lib/cookbook_creator/helpers.rb +25 -0
  9. data/lib/cookbook_creator/main.rb +42 -0
  10. data/lib/cookbook_creator/null_logger.rb +70 -0
  11. data/lib/cookbook_creator/pathhelper.rb +33 -0
  12. data/lib/cookbook_creator/runner.rb +74 -0
  13. data/lib/cookbook_creator/skeletons/code_generator/files/default/Berksfile +3 -0
  14. data/lib/cookbook_creator/skeletons/code_generator/files/default/chefignore +100 -0
  15. data/lib/cookbook_creator/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md +9 -0
  16. data/lib/cookbook_creator/skeletons/code_generator/files/default/cookbook_readmes/README.md +54 -0
  17. data/lib/cookbook_creator/skeletons/code_generator/files/default/gitignore +16 -0
  18. data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/README.md +28 -0
  19. data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/cookbooks/example/README.md +27 -0
  20. data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +7 -0
  21. data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/cookbooks/example/metadata.rb +3 -0
  22. data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +8 -0
  23. data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/data_bags/README.md +58 -0
  24. data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/data_bags/example/example_item.json +4 -0
  25. data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/dot-chef-repo.txt +6 -0
  26. data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/environments/README.md +9 -0
  27. data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/environments/example.json +13 -0
  28. data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/policies/README.md +24 -0
  29. data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/roles/README.md +9 -0
  30. data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/roles/example.json +13 -0
  31. data/lib/cookbook_creator/skeletons/code_generator/files/default/serverspec_spec_helper.rb +8 -0
  32. data/lib/cookbook_creator/skeletons/code_generator/files/default/spec_helper.rb +2 -0
  33. data/lib/cookbook_creator/skeletons/code_generator/files/default/spec_helper_policyfile.rb +2 -0
  34. data/lib/cookbook_creator/skeletons/code_generator/metadata.rb +8 -0
  35. data/lib/cookbook_creator/skeletons/code_generator/recipes/app.rb +97 -0
  36. data/lib/cookbook_creator/skeletons/code_generator/recipes/attribute.rb +12 -0
  37. data/lib/cookbook_creator/skeletons/code_generator/recipes/cookbook.rb +112 -0
  38. data/lib/cookbook_creator/skeletons/code_generator/recipes/cookbook_file.rb +24 -0
  39. data/lib/cookbook_creator/skeletons/code_generator/recipes/lwrp.rb +23 -0
  40. data/lib/cookbook_creator/skeletons/code_generator/recipes/policyfile.rb +8 -0
  41. data/lib/cookbook_creator/skeletons/code_generator/recipes/recipe.rb +27 -0
  42. data/lib/cookbook_creator/skeletons/code_generator/recipes/repo.rb +67 -0
  43. data/lib/cookbook_creator/skeletons/code_generator/recipes/template.rb +32 -0
  44. data/lib/cookbook_creator/skeletons/code_generator/templates/default/Berksfile.erb +3 -0
  45. data/lib/cookbook_creator/skeletons/code_generator/templates/default/LICENSE.all_rights.erb +3 -0
  46. data/lib/cookbook_creator/skeletons/code_generator/templates/default/LICENSE.apache2.erb +201 -0
  47. data/lib/cookbook_creator/skeletons/code_generator/templates/default/LICENSE.gplv2.erb +339 -0
  48. data/lib/cookbook_creator/skeletons/code_generator/templates/default/LICENSE.gplv3.erb +674 -0
  49. data/lib/cookbook_creator/skeletons/code_generator/templates/default/LICENSE.mit.erb +21 -0
  50. data/lib/cookbook_creator/skeletons/code_generator/templates/default/README.md.erb +4 -0
  51. data/lib/cookbook_creator/skeletons/code_generator/templates/default/attribute.rb.erb +1 -0
  52. data/lib/cookbook_creator/skeletons/code_generator/templates/default/cookbook_file.erb +1 -0
  53. data/lib/cookbook_creator/skeletons/code_generator/templates/default/kitchen.yml.erb +25 -0
  54. data/lib/cookbook_creator/skeletons/code_generator/templates/default/library.rb.erb +7 -0
  55. data/lib/cookbook_creator/skeletons/code_generator/templates/default/metadata.rb.erb +7 -0
  56. data/lib/cookbook_creator/skeletons/code_generator/templates/default/provider.rb.erb +10 -0
  57. data/lib/cookbook_creator/skeletons/code_generator/templates/default/recipe.rb.erb +5 -0
  58. data/lib/cookbook_creator/skeletons/code_generator/templates/default/recipe_spec.rb.erb +20 -0
  59. data/lib/cookbook_creator/skeletons/code_generator/templates/default/repo/gitignore.erb +11 -0
  60. data/lib/cookbook_creator/skeletons/code_generator/templates/default/resource.rb.erb +7 -0
  61. data/lib/cookbook_creator/skeletons/code_generator/templates/default/serverspec_default_spec.rb.erb +9 -0
  62. data/lib/cookbook_creator/skeletons/code_generator/templates/default/template.erb +0 -0
  63. data/lib/skeletons/code_generator/files/default/Berksfile +3 -0
  64. data/lib/skeletons/code_generator/files/default/chefignore +100 -0
  65. data/lib/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md +9 -0
  66. data/lib/skeletons/code_generator/files/default/cookbook_readmes/README.md +54 -0
  67. data/lib/skeletons/code_generator/files/default/gitignore +16 -0
  68. data/lib/skeletons/code_generator/files/default/repo/README.md +28 -0
  69. data/lib/skeletons/code_generator/files/default/repo/cookbooks/example/README.md +27 -0
  70. data/lib/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +7 -0
  71. data/lib/skeletons/code_generator/files/default/repo/cookbooks/example/metadata.rb +3 -0
  72. data/lib/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +8 -0
  73. data/lib/skeletons/code_generator/files/default/repo/data_bags/README.md +58 -0
  74. data/lib/skeletons/code_generator/files/default/repo/data_bags/example/example_item.json +4 -0
  75. data/lib/skeletons/code_generator/files/default/repo/dot-chef-repo.txt +6 -0
  76. data/lib/skeletons/code_generator/files/default/repo/environments/README.md +9 -0
  77. data/lib/skeletons/code_generator/files/default/repo/environments/example.json +13 -0
  78. data/lib/skeletons/code_generator/files/default/repo/policies/README.md +24 -0
  79. data/lib/skeletons/code_generator/files/default/repo/roles/README.md +9 -0
  80. data/lib/skeletons/code_generator/files/default/repo/roles/example.json +13 -0
  81. data/lib/skeletons/code_generator/files/default/serverspec_spec_helper.rb +8 -0
  82. data/lib/skeletons/code_generator/files/default/spec_helper.rb +2 -0
  83. data/lib/skeletons/code_generator/files/default/spec_helper_policyfile.rb +2 -0
  84. data/lib/skeletons/code_generator/metadata.rb +8 -0
  85. data/lib/skeletons/code_generator/recipes/app.rb +97 -0
  86. data/lib/skeletons/code_generator/recipes/attribute.rb +12 -0
  87. data/lib/skeletons/code_generator/recipes/cookbook.rb +94 -0
  88. data/lib/skeletons/code_generator/recipes/cookbook_file.rb +24 -0
  89. data/lib/skeletons/code_generator/recipes/lwrp.rb +23 -0
  90. data/lib/skeletons/code_generator/recipes/policyfile.rb +8 -0
  91. data/lib/skeletons/code_generator/recipes/recipe.rb +27 -0
  92. data/lib/skeletons/code_generator/recipes/repo.rb +67 -0
  93. data/lib/skeletons/code_generator/recipes/template.rb +32 -0
  94. data/lib/skeletons/code_generator/templates/default/LICENSE.all_rights.erb +3 -0
  95. data/lib/skeletons/code_generator/templates/default/LICENSE.apache2.erb +201 -0
  96. data/lib/skeletons/code_generator/templates/default/LICENSE.gplv2.erb +339 -0
  97. data/lib/skeletons/code_generator/templates/default/LICENSE.gplv3.erb +674 -0
  98. data/lib/skeletons/code_generator/templates/default/LICENSE.mit.erb +21 -0
  99. data/lib/skeletons/code_generator/templates/default/Policyfile.rb.erb +25 -0
  100. data/lib/skeletons/code_generator/templates/default/README.md.erb +4 -0
  101. data/lib/skeletons/code_generator/templates/default/attribute.rb.erb +0 -0
  102. data/lib/skeletons/code_generator/templates/default/cookbook_file.erb +0 -0
  103. data/lib/skeletons/code_generator/templates/default/kitchen.yml.erb +21 -0
  104. data/lib/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +32 -0
  105. data/lib/skeletons/code_generator/templates/default/metadata.rb.erb +7 -0
  106. data/lib/skeletons/code_generator/templates/default/provider.rb.erb +0 -0
  107. data/lib/skeletons/code_generator/templates/default/recipe.rb.erb +5 -0
  108. data/lib/skeletons/code_generator/templates/default/recipe_spec.rb.erb +20 -0
  109. data/lib/skeletons/code_generator/templates/default/repo/gitignore.erb +11 -0
  110. data/lib/skeletons/code_generator/templates/default/resource.rb.erb +0 -0
  111. data/lib/skeletons/code_generator/templates/default/serverspec_default_spec.rb.erb +9 -0
  112. data/lib/skeletons/code_generator/templates/default/template.erb +0 -0
  113. data/test.txt +0 -0
  114. metadata +119 -6
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) <%= year %> <%= copyright_holder %>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,4 @@
1
+ # <%= cookbook_name %>
2
+
3
+ TODO: Enter the cookbook description here.
4
+
@@ -0,0 +1 @@
1
+ <%= license_description('#') %>
@@ -0,0 +1 @@
1
+ <%= license_description('#') %>
@@ -0,0 +1,25 @@
1
+ ---
2
+ <% if driver.eql?('docker') %>
3
+ driver:
4
+ name: docker
5
+ use_sudo: false
6
+ <% else %>
7
+ driver:
8
+ name: vagrant
9
+ <% end %>
10
+
11
+ provisioner:
12
+ name: <%= provisioner %>
13
+
14
+ platforms:
15
+ - name: <%= platform %>
16
+ driver_config:
17
+ image: <%= image %>
18
+
19
+ suites:
20
+ - name: default
21
+ run_list:
22
+ - recipe[<%= cookbook_name %>::default]
23
+ attributes: {
24
+ }
25
+
@@ -0,0 +1,7 @@
1
+ <%= license_description('#') %>
2
+
3
+ class Chef
4
+ class Recipe
5
+
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ name '<%= cookbook_name %>'
2
+ maintainer '<%= copyright_holder %>'
3
+ maintainer_email '<%= email %>'
4
+ license '<%= license %>'
5
+ description 'Installs/Configures <%= cookbook_name %>'
6
+ long_description 'Installs/Configures <%= cookbook_name %>'
7
+ version '0.1.0'
@@ -0,0 +1,10 @@
1
+ <%= license_description('#') %>
2
+
3
+ def whyrun_supported?
4
+ true
5
+ end
6
+
7
+ use_inline_resources
8
+
9
+ action <default_action> do
10
+ end
@@ -0,0 +1,5 @@
1
+ #
2
+ # Cookbook Name:: <%= cookbook_name %>
3
+ # Recipe:: <%= recipe_name %>
4
+ #
5
+ <%= license_description('#') %>
@@ -0,0 +1,20 @@
1
+ #
2
+ # Cookbook Name:: <%= cookbook_name %>
3
+ # Spec:: default
4
+ #
5
+ <%= license_description('#') %>
6
+
7
+ require 'spec_helper'
8
+
9
+ describe '<%= cookbook_name %>::<%= recipe_name %>' do
10
+ context 'When all attributes are default, on an unspecified platform' do
11
+ let(:chef_run) do
12
+ runner = ChefSpec::ServerRunner.new
13
+ runner.converge(described_recipe)
14
+ end
15
+
16
+ it 'converges successfully' do
17
+ expect { chef_run }.to_not raise_error
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ .rake_test_cache
2
+
3
+ ###
4
+ # Ignore Chef key files and secrets
5
+ ###
6
+ .chef/*.pem
7
+ .chef/encrypted_data_bag_secret
8
+ <%- if policy_only -%>
9
+ cookbooks/**
10
+ !cookbooks/README.md
11
+ <%- end -%>
@@ -0,0 +1,7 @@
1
+ <%= license_description('#') %>
2
+
3
+ actions <actions>
4
+
5
+ default_action <default_action>
6
+
7
+ attribute <main_attribute>, :kind_of => <attr_class>, :name_attribute => true
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe '<%= cookbook_name %>::default' do
4
+ # Serverspec examples can be found at
5
+ # http://serverspec.org/resource_types.html
6
+ it 'does something' do
7
+ skip 'Replace this with meaningful tests'
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ source 'https://supermarket.chef.io'
2
+
3
+ metadata
@@ -0,0 +1,100 @@
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
@@ -0,0 +1,9 @@
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
@@ -0,0 +1,54 @@
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.
@@ -0,0 +1,16 @@
1
+ .vagrant
2
+ Berksfile.lock
3
+ *~
4
+ *#
5
+ .#*
6
+ \#*#
7
+ .*.sw[a-z]
8
+ *.un~
9
+
10
+ # Bundler
11
+ Gemfile.lock
12
+ bin/*
13
+ .bundle/*
14
+
15
+ .kitchen/
16
+ .kitchen.local.yml
@@ -0,0 +1,28 @@
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.
@@ -0,0 +1,27 @@
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
@@ -0,0 +1,7 @@
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).
@@ -0,0 +1,3 @@
1
+ name 'example'
2
+ description 'An example cookbook'
3
+ version '1.0.0'
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,58 @@
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