idlc-sdk-pfm 1.0.0.pre.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/.yardopts +3 -0
  6. data/Gemfile +6 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +37 -0
  9. data/Rakefile +6 -0
  10. data/bin/pfm +8 -0
  11. data/docs/GettingStarted.md +299 -0
  12. data/idlc-sdk-pfm.gemspec +44 -0
  13. data/lib/idlc-sdk-pfm/builtin_commands.rb +11 -0
  14. data/lib/idlc-sdk-pfm/cli.rb +150 -0
  15. data/lib/idlc-sdk-pfm/command/apply.rb +71 -0
  16. data/lib/idlc-sdk-pfm/command/base.rb +195 -0
  17. data/lib/idlc-sdk-pfm/command/build.rb +120 -0
  18. data/lib/idlc-sdk-pfm/command/configure.rb +41 -0
  19. data/lib/idlc-sdk-pfm/command/destroy.rb +61 -0
  20. data/lib/idlc-sdk-pfm/command/exec.rb +24 -0
  21. data/lib/idlc-sdk-pfm/command/format.rb +64 -0
  22. data/lib/idlc-sdk-pfm/command/generate.rb +83 -0
  23. data/lib/idlc-sdk-pfm/command/generator_commands/base.rb +50 -0
  24. data/lib/idlc-sdk-pfm/command/generator_commands/server_build.rb +58 -0
  25. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/Berksfile +3 -0
  26. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/build_cookbook/.kitchen.yml +21 -0
  27. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/build_cookbook/README.md +146 -0
  28. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/build_cookbook/test-fixture-recipe.rb +8 -0
  29. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/chefignore +107 -0
  30. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md +9 -0
  31. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/cookbook_readmes/README.md +54 -0
  32. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/delivery-config.json +12 -0
  33. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/delivery-project.toml +36 -0
  34. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/gitignore +21 -0
  35. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/README.md +24 -0
  36. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/cookbooks/example/README.md +27 -0
  37. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +7 -0
  38. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/cookbooks/example/metadata.rb +6 -0
  39. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +8 -0
  40. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/data_bags/README.md +56 -0
  41. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/data_bags/example/example_item.json +4 -0
  42. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/dot-chef-repo.txt +6 -0
  43. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/environments/README.md +9 -0
  44. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/environments/example.json +13 -0
  45. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/policies/README.md +24 -0
  46. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/roles/README.md +9 -0
  47. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/repo/roles/example.json +13 -0
  48. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/spec_helper.rb +2 -0
  49. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/files/default/spec_helper_policyfile.rb +2 -0
  50. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/metadata.rb +7 -0
  51. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/app.rb +89 -0
  52. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/attribute.rb +12 -0
  53. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/build_cookbook.rb +182 -0
  54. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/cookbook.rb +144 -0
  55. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/cookbook_file.rb +24 -0
  56. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/lwrp.rb +23 -0
  57. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/policyfile.rb +8 -0
  58. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/recipe.rb +51 -0
  59. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/repo.rb +67 -0
  60. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/recipes/template.rb +32 -0
  61. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.all_rights.erb +3 -0
  62. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.apachev2.erb +201 -0
  63. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.gplv2.erb +339 -0
  64. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.gplv3.erb +674 -0
  65. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/LICENSE.mit.erb +21 -0
  66. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/Policyfile.rb.erb +25 -0
  67. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/README.md.erb +4 -0
  68. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/attribute.rb.erb +0 -0
  69. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/build_cookbook/Berksfile.erb +7 -0
  70. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/build_cookbook/metadata.rb.erb +10 -0
  71. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/build_cookbook/recipe.rb.erb +8 -0
  72. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/cookbook_file.erb +0 -0
  73. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/inspec_default_test.rb.erb +18 -0
  74. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/kitchen.yml.erb +26 -0
  75. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +33 -0
  76. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/metadata.rb.erb +20 -0
  77. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/provider.rb.erb +0 -0
  78. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/recipe.rb.erb +5 -0
  79. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/recipe_spec.rb.erb +22 -0
  80. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/repo/gitignore.erb +128 -0
  81. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/resource.rb.erb +0 -0
  82. data/lib/idlc-sdk-pfm/command/generator_commands/skeletons/code_generator/templates/default/template.erb +0 -0
  83. data/lib/idlc-sdk-pfm/command/generator_commands.rb +34 -0
  84. data/lib/idlc-sdk-pfm/command/plan.rb +80 -0
  85. data/lib/idlc-sdk-pfm/command/templates/app/files/config/client.rb.template +9 -0
  86. data/lib/idlc-sdk-pfm/command/templates/app/files/config/init.ps1.userdata +16 -0
  87. data/lib/idlc-sdk-pfm/command/templates/base/files/config/client.rb.template +6 -0
  88. data/lib/idlc-sdk-pfm/command/templates/base/files/config/init.ps1.userdata +219 -0
  89. data/lib/idlc-sdk-pfm/command/validate.rb +85 -0
  90. data/lib/idlc-sdk-pfm/command/validator_commands/base.rb +65 -0
  91. data/lib/idlc-sdk-pfm/command/validator_commands/infrastructure.rb +46 -0
  92. data/lib/idlc-sdk-pfm/command/validator_commands/server_build.rb +135 -0
  93. data/lib/idlc-sdk-pfm/command/validator_commands.rb +32 -0
  94. data/lib/idlc-sdk-pfm/commands_map.rb +61 -0
  95. data/lib/idlc-sdk-pfm/generator.rb +52 -0
  96. data/lib/idlc-sdk-pfm/helpers.rb +49 -0
  97. data/lib/idlc-sdk-pfm/settings.rb +205 -0
  98. data/lib/idlc-sdk-pfm/validator.rb +52 -0
  99. data/lib/idlc-sdk-pfm/version.rb +3 -0
  100. data/lib/idlc-sdk-pfm.rb +24 -0
  101. metadata +342 -0
@@ -0,0 +1,21 @@
1
+ ---
2
+ driver:
3
+ name: vagrant
4
+ synced_folders:
5
+ - [<%= File.join(ENV['PWD'], '..', '..')%>, '/tmp/repo-data']
6
+
7
+ provisioner:
8
+ name: chef_zero
9
+ encrypted_data_bag_secret_key_path: 'secrets/fakey-mcfakerton'
10
+ data_bags_path: './data_bags'
11
+ product_name: chefdk
12
+
13
+ platforms:
14
+ - name: ubuntu-16.04
15
+ - name: centos-7.3
16
+
17
+ suites:
18
+ - name: default
19
+ run_list:
20
+ - recipe[test]
21
+ attributes:
@@ -0,0 +1,146 @@
1
+ # build_cookbook
2
+
3
+ A build cookbook for running the parent project through Chef Delivery
4
+
5
+ This build cookbook should be customized to suit the needs of the parent project. Using this cookbook can be done outside of Chef Delivery, too. If the parent project is a Chef cookbook, we've detected that and "wrapped" [delivery-truck](https://github.com/chef-cookbooks/delivery-truck). That means it is a dependency, and each of its pipeline phase recipes is included in the appropriate phase recipes in this cookbook. If the parent project is not a cookbook, it's left as an exercise to the reader to customize the recipes as needed for each phase in the pipeline.
6
+
7
+ ## .delivery/config.json
8
+
9
+ In the parent directory to this build_cookbook, the `config.json` can be modified as necessary. For example, phases can be skipped, publishing information can be added, and so on. Refer to customer support or the Chef Delivery documentation for assistance on what options are available for this configuration.
10
+
11
+ ## Test Kitchen - Local Verify Testing
12
+
13
+ This cookbook also has a `.kitchen.yml` which can be used to create local build nodes with Test Kitchen to perform the verification phases, `unit`, `syntax`, and `lint`. When running `kitchen converge`, the instances will be set up like Chef Delivery "build nodes" with the [delivery_build cookbook](https://github.com/chef-cookbooks/delivery_build). The reason for this is to make sure that the same exact kind of nodes are used by this build cookbook are run on the local workstation as would run Delivery. It will run `delivery job verify PHASE` for the parent project.
14
+
15
+ Modify the `.kitchen.yml` if necessary to change the platforms or other configuration to run the verify phases. After making changes in the parent project, `cd` into this directory (`.delivery/build_cookbook`), and run:
16
+
17
+ ```
18
+ kitchen test
19
+ ```
20
+
21
+ ## Recipes
22
+
23
+ Each of the recipes in this build_cookbook are run in the named phase during the Chef Delivery pipeline. The `unit`, `syntax`, and `lint` recipes are additionally run when using Test Kitchen for local testing as noted in the above section.
24
+
25
+ ## Making Changes - Cookbook Example
26
+
27
+ When making changes in the parent project (that which lives in `../..` from this directory), or in the recipes in this build cookbook, there is a bespoke workflow for Chef Delivery. As an example, we'll discuss a Chef Cookbook as the parent.
28
+
29
+ First, create a new branch for the changes.
30
+
31
+ ```
32
+ git checkout -b testing-build-cookbook
33
+ ```
34
+
35
+ Next, increment the version in the metadata.rb. This should be in the _parent_, not in this, the build_cookbook. If this is not done, the verify phase will fail.
36
+
37
+ ```
38
+ % git diff
39
+ <SNIP>
40
+ -version '0.1.0'
41
+ +version '0.1.1'
42
+ ```
43
+
44
+ The change we'll use for an example is to install the `zsh` package. Write a failing ChefSpec in the cookbook project's `spec/unit/recipes/default_spec.rb`.
45
+
46
+ ```ruby
47
+ require 'spec_helper'
48
+
49
+ describe 'godzilla::default' do
50
+ context 'When all attributes are default, on Ubuntu 16.04' do
51
+ let(:chef_run) do
52
+ runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04')
53
+ runner.converge(described_recipe)
54
+ end
55
+
56
+ it 'installs zsh' do
57
+ expect(chef_run).to install_package('zsh')
58
+ end
59
+ end
60
+ end
61
+ ```
62
+
63
+ Commit the local changes as work in progress. The `delivery job` expects to use a clean git repository.
64
+
65
+ ```
66
+ git add ../..
67
+ git commit -m 'WIP: Testing changes'
68
+ ```
69
+
70
+ From _this_ directory (`.delivery/build_cookbook`, relative to the parent cookbook project), run
71
+
72
+ ```
73
+ cd .delivery/build_cookbook
74
+ kitchen converge
75
+ ```
76
+
77
+ This will take some time at first, because the VMs need to be created, Chef installed, the Delivery CLI installed, etc. Later runs will be faster until they are destroyed. It will also fail on the first VM, as expected, because we wrote the test first. Now edit the parent cookbook project's default recipe to install `zsh`.
78
+
79
+ ```
80
+ cd ../../
81
+ $EDITOR/recipes/default.rb
82
+ ```
83
+
84
+ It should look like this:
85
+
86
+ ```
87
+ package 'zsh'
88
+ ```
89
+
90
+ Create another commit.
91
+
92
+ ```
93
+ git add .
94
+ git commit -m 'WIP: Install zsh in default recipe'
95
+ ```
96
+
97
+ Now rerun kitchen from the build_cookbook.
98
+
99
+ ```
100
+ cd .delivery/build_cookbook
101
+ kitchen converge
102
+ ```
103
+
104
+ This will take awhile because it will now pass on the first VM, and then create the second VM. We should have warned you this was a good time for a coffee break.
105
+
106
+ ```
107
+ Recipe: test::default
108
+
109
+ - execute HOME=/home/vagrant delivery job verify unit --server localhost --ent test --org kitchen
110
+ * execute[HOME=/home/vagrant delivery job verify lint --server localhost --ent test --org kitchen] action run
111
+ - execute HOME=/home/vagrant delivery job verify lint --server localhost --ent test --org kitchen
112
+
113
+ - execute HOME=/home/vagrant delivery job verify syntax --server localhost --ent test --org kitchen
114
+
115
+ Running handlers:
116
+ Running handlers complete
117
+ Chef Client finished, 3/32 resources updated in 54.665445968 seconds
118
+ Finished converging <default-centos-71> (1m26.83s).
119
+ ```
120
+
121
+ Victory is ours! Our verify phase passed on the build nodes.
122
+
123
+ We are ready to run this through our Delivery pipeline. Simply run `delivery review` on the local system from the parent project, and it will open a browser window up to the change we just added.
124
+
125
+ ```
126
+ cd ../..
127
+ delivery review
128
+ ```
129
+
130
+ ## FAQ
131
+
132
+ ### Why don't I just run rspec and foodcritic/rubocop on my local system?
133
+
134
+ An objection to the Test Kitchen approach is that it is much faster to run the unit, lint, and syntax commands for the project on the local system. That is totally true, and also totally valid. Do that for the really fast feedback loop. However, the dance we do with Test Kitchen brings a much higher degree of confidence in the changes we're making, that everything will run on the build nodes in Chef Delivery. We strongly encourage this approach before actually pushing the changes to Delivery.
135
+
136
+ ### Why do I have to make a commit every time?
137
+
138
+ When running `delivery job`, it expects to merge the commit for the changeset against the clean master branch. If we don't save our progress by making a commit, our local changes aren't run through `delivery job` in the Test Kitchen build instances. We can always perform an interactive rebase, and modify the original changeset message in Delivery with `delivery review --edit`. The latter won't modify the git commits, only the changeset in Delivery.
139
+
140
+ ### What do I do next?
141
+
142
+ Make changes in the cookbook project as required for organizational goals and needs. Modify the `build_cookbook` as necessary for the pipeline phases that the cookbook should go through.
143
+
144
+ ### What if I get stuck?
145
+
146
+ Contact Chef Support, or your Chef Customer Success team and they will help you get unstuck.
@@ -0,0 +1,8 @@
1
+ %w(unit lint syntax).each do |phase|
2
+ # TODO: This works on Linux/Unix. Not Windows.
3
+ execute "HOME=/home/vagrant delivery job verify #{phase} --server localhost --ent test --org kitchen" do
4
+ cwd '/tmp/repo-data'
5
+ user 'vagrant'
6
+ environment('GIT_DISCOVERY_ACROSS_FILESYSTEM' => '1')
7
+ end
8
+ end
@@ -0,0 +1,107 @@
1
+ # Put files/directories that should be ignored in this file when uploading
2
+ # to a chef-server or supermarket.
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
+ spec/*
60
+ Rakefile
61
+ .travis.yml
62
+ .foodcritic
63
+ .codeclimate.yml
64
+
65
+ # SCM #
66
+ #######
67
+ .git
68
+ */.git
69
+ .gitignore
70
+ .gitmodules
71
+ .gitconfig
72
+ .gitattributes
73
+ .svn
74
+ */.bzr/*
75
+ */.hg/*
76
+ */.svn/*
77
+
78
+ # Berkshelf #
79
+ #############
80
+ Berksfile
81
+ Berksfile.lock
82
+ cookbooks/*
83
+ tmp
84
+
85
+ # Policyfile #
86
+ ##############
87
+ Policyfile.rb
88
+ Policyfile.lock.json
89
+
90
+ # Cookbooks #
91
+ #############
92
+ CONTRIBUTING*
93
+ CHANGELOG*
94
+ TESTING*
95
+ MAINTAINERS.toml
96
+
97
+ # Strainer #
98
+ ############
99
+ Colanderfile
100
+ Strainerfile
101
+ .colander
102
+ .strainer
103
+
104
+ # Vagrant #
105
+ ###########
106
+ .vagrant
107
+ Vagrantfile
@@ -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,12 @@
1
+ {
2
+ "version": "2",
3
+ "build_cookbook": {
4
+ "name": "build_cookbook",
5
+ "path": ".delivery/build_cookbook"
6
+ },
7
+ "skip_phases": [],
8
+ "job_dispatch": {
9
+ "version": "v2"
10
+ },
11
+ "dependencies": []
12
+ }
@@ -0,0 +1,36 @@
1
+ # Delivery Prototype for Local Phases Execution
2
+ #
3
+ # The purpose of this file is to prototype a new way to execute
4
+ # phases locally on your workstation. The delivery-cli will read
5
+ # this file and execute the command(s) that are configured for
6
+ # each phase. You can customize them by just modifying the phase
7
+ # key on this file.
8
+ #
9
+ # By default these phases are configured for Cookbook Workflow only
10
+ #
11
+ # As this is still a prototype we are not modifying the current
12
+ # config.json file and it will continue working as usual.
13
+
14
+ [local_phases]
15
+ unit = "chef exec rspec spec/"
16
+ lint = "chef exec cookstyle"
17
+ # Foodcritic includes rules only appropriate for community cookbooks
18
+ # uploaded to Supermarket. We turn off any rules tagged "supermarket"
19
+ # by default. If you plan to share this cookbook you should remove
20
+ # '-t ~supermarket' below to enable supermarket rules.
21
+ syntax = "chef exec foodcritic . --exclude spec -f any -t ~supermarket"
22
+ provision = "chef exec kitchen create"
23
+ deploy = "chef exec kitchen converge"
24
+ smoke = "chef exec kitchen verify"
25
+ # The functional phase is optional, you can define it by uncommenting
26
+ # the line below and running the command: `delivery local functional`
27
+ # functional = ""
28
+ cleanup = "chef exec kitchen destroy"
29
+
30
+ # Remote project.toml file
31
+ #
32
+ # Specify a remote URI location for the `project.toml` file.
33
+ # This is useful for teams that wish to centrally manage the behavior
34
+ # of the `delivery local` command across many different projects.
35
+ #
36
+ # remote_file = "https://url/project.toml"
@@ -0,0 +1,21 @@
1
+ .vagrant
2
+ *~
3
+ *#
4
+ .#*
5
+ \#*#
6
+ .*.sw[a-z]
7
+ *.un~
8
+
9
+ # Bundler
10
+ Gemfile.lock
11
+ bin/*
12
+ .bundle/*
13
+
14
+ # test kitchen
15
+ .kitchen/
16
+ .kitchen.local.yml
17
+
18
+ # Chef
19
+ Berksfile.lock
20
+ .zero-knife.rb
21
+ Policyfile.lock.json
@@ -0,0 +1,24 @@
1
+ # Overview
2
+
3
+ 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.
4
+
5
+ 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.
6
+
7
+ # Repository Directories
8
+
9
+ 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.
10
+
11
+ - `cookbooks/` - Cookbooks you download or create.
12
+ - `data_bags/` - Store data bags and items in .json in the repository.
13
+ - `roles/` - Store roles in .rb or .json in the repository.
14
+ - `environments/` - Store environments in .rb or .json in the repository.
15
+
16
+ # Configuration
17
+
18
+ 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.
19
+
20
+ <https://docs.chef.io/knife.html>
21
+
22
+ # Next Steps
23
+
24
+ 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,6 @@
1
+ name 'example'
2
+ description 'An example cookbook'
3
+ maintainer 'Example maintainer'
4
+ maintainer_email 'maintainer@example.com'
5
+ license 'Apache v2'
6
+ 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/recipes.html
@@ -0,0 +1,56 @@
1
+ # Data Bags
2
+
3
+ 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.
4
+
5
+ For example, in this directory you'll find an example data bag directory called `example`, which contains an item definition called `example_item.json`
6
+
7
+ Before uploading this item to the server, we must first create the data bag on the Chef Server.
8
+
9
+ knife data bag create example
10
+
11
+ Then we can upload the items in the data bag's directory to the Chef Server.
12
+
13
+ knife data bag from file example example_item.json
14
+
15
+ For more information on data bags, see the Chef wiki page:
16
+
17
+ https://docs.chef.io/data_bags.html
18
+
19
+ # Encrypted Data Bags
20
+
21
+ 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.
22
+
23
+ openssl rand -base64 512 > secret_key
24
+
25
+ You may use this secret_key to add items to a data bag during a create.
26
+
27
+ knife data bag create --secret-file secret_key passwords mysql
28
+
29
+ You may also use it when adding ITEMs from files,
30
+
31
+ knife data bag create passwords
32
+ knife data bag from file passwords data_bags/passwords/mysql.json --secret-file secret_key
33
+
34
+ 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,
35
+
36
+ {
37
+ "id": "mysql",
38
+ "password": "abc123"
39
+ }
40
+
41
+ Without the secret_key, the contents are encrypted.
42
+
43
+ knife data bag show passwords mysql
44
+ id: mysql
45
+ password: 2I0XUUve1TXEojEyeGsjhw==
46
+
47
+ Use the secret_key to view the contents.
48
+
49
+ knife data bag show passwords mysql --secret-file secret_key
50
+ id: mysql
51
+ password: abc123
52
+
53
+
54
+ For more information on encrypted data bags, see the Chef wiki page:
55
+
56
+ https://docs.chef.io/data_bags.html
@@ -0,0 +1,6 @@
1
+ .chef-repo.txt
2
+ ==============
3
+
4
+ This file gives ChefDK's generators a hint that you are using a Chef Repo and
5
+ this is the root directory of your Chef Repo. ChefDK's generators use this to
6
+ generate code that is designed to work with the Chef Repo workflow.
@@ -0,0 +1,9 @@
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
@@ -0,0 +1,13 @@
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
+ }
@@ -0,0 +1,24 @@
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-frontend.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
+ ```
@@ -0,0 +1,9 @@
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/roles.html
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "example",
3
+ "description": "This is an example role defined as JSON",
4
+ "chef_type": "role",
5
+ "json_class": "Chef::Role",
6
+ "default_attributes": {
7
+ },
8
+ "override_attributes": {
9
+ },
10
+ "run_list": [
11
+ "recipe[example]"
12
+ ]
13
+ }
@@ -0,0 +1,2 @@
1
+ require 'chefspec'
2
+ require 'chefspec/berkshelf'
@@ -0,0 +1,2 @@
1
+ require 'chefspec'
2
+ require 'chefspec/policyfile'
@@ -0,0 +1,7 @@
1
+ name 'code_generator'
2
+ maintainer 'Chef Software, Inc.'
3
+ maintainer_email 'dev@chef.io'
4
+ license 'Apache 2 License'
5
+ description 'Generates Chef code for Chef DK'
6
+ long_description 'Generates Chef code for Chef DK'
7
+ version '0.1.0'