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.
- checksums.yaml +4 -4
- data/bin/cookbook_create +11 -0
- data/cookbook_creator.gemspec +33 -0
- data/lib/cookbook_creator/cli.rb +100 -0
- data/lib/cookbook_creator/config.rb +24 -0
- data/lib/cookbook_creator/config_loader.rb +157 -0
- data/lib/cookbook_creator/generator.rb +202 -0
- data/lib/cookbook_creator/helpers.rb +25 -0
- data/lib/cookbook_creator/main.rb +42 -0
- data/lib/cookbook_creator/null_logger.rb +70 -0
- data/lib/cookbook_creator/pathhelper.rb +33 -0
- data/lib/cookbook_creator/runner.rb +74 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/Berksfile +3 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/chefignore +100 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md +9 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/cookbook_readmes/README.md +54 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/gitignore +16 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/README.md +28 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/cookbooks/example/README.md +27 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +7 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/cookbooks/example/metadata.rb +3 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +8 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/data_bags/README.md +58 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/data_bags/example/example_item.json +4 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/dot-chef-repo.txt +6 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/environments/README.md +9 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/environments/example.json +13 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/policies/README.md +24 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/roles/README.md +9 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/roles/example.json +13 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/serverspec_spec_helper.rb +8 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/spec_helper.rb +2 -0
- data/lib/cookbook_creator/skeletons/code_generator/files/default/spec_helper_policyfile.rb +2 -0
- data/lib/cookbook_creator/skeletons/code_generator/metadata.rb +8 -0
- data/lib/cookbook_creator/skeletons/code_generator/recipes/app.rb +97 -0
- data/lib/cookbook_creator/skeletons/code_generator/recipes/attribute.rb +12 -0
- data/lib/cookbook_creator/skeletons/code_generator/recipes/cookbook.rb +112 -0
- data/lib/cookbook_creator/skeletons/code_generator/recipes/cookbook_file.rb +24 -0
- data/lib/cookbook_creator/skeletons/code_generator/recipes/lwrp.rb +23 -0
- data/lib/cookbook_creator/skeletons/code_generator/recipes/policyfile.rb +8 -0
- data/lib/cookbook_creator/skeletons/code_generator/recipes/recipe.rb +27 -0
- data/lib/cookbook_creator/skeletons/code_generator/recipes/repo.rb +67 -0
- data/lib/cookbook_creator/skeletons/code_generator/recipes/template.rb +32 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/Berksfile.erb +3 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/LICENSE.all_rights.erb +3 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/LICENSE.apache2.erb +201 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/LICENSE.gplv2.erb +339 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/LICENSE.gplv3.erb +674 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/LICENSE.mit.erb +21 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/README.md.erb +4 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/attribute.rb.erb +1 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/cookbook_file.erb +1 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/kitchen.yml.erb +25 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/library.rb.erb +7 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/metadata.rb.erb +7 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/provider.rb.erb +10 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/recipe.rb.erb +5 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/recipe_spec.rb.erb +20 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/repo/gitignore.erb +11 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/resource.rb.erb +7 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/serverspec_default_spec.rb.erb +9 -0
- data/lib/cookbook_creator/skeletons/code_generator/templates/default/template.erb +0 -0
- data/lib/skeletons/code_generator/files/default/Berksfile +3 -0
- data/lib/skeletons/code_generator/files/default/chefignore +100 -0
- data/lib/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md +9 -0
- data/lib/skeletons/code_generator/files/default/cookbook_readmes/README.md +54 -0
- data/lib/skeletons/code_generator/files/default/gitignore +16 -0
- data/lib/skeletons/code_generator/files/default/repo/README.md +28 -0
- data/lib/skeletons/code_generator/files/default/repo/cookbooks/example/README.md +27 -0
- data/lib/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +7 -0
- data/lib/skeletons/code_generator/files/default/repo/cookbooks/example/metadata.rb +3 -0
- data/lib/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +8 -0
- data/lib/skeletons/code_generator/files/default/repo/data_bags/README.md +58 -0
- data/lib/skeletons/code_generator/files/default/repo/data_bags/example/example_item.json +4 -0
- data/lib/skeletons/code_generator/files/default/repo/dot-chef-repo.txt +6 -0
- data/lib/skeletons/code_generator/files/default/repo/environments/README.md +9 -0
- data/lib/skeletons/code_generator/files/default/repo/environments/example.json +13 -0
- data/lib/skeletons/code_generator/files/default/repo/policies/README.md +24 -0
- data/lib/skeletons/code_generator/files/default/repo/roles/README.md +9 -0
- data/lib/skeletons/code_generator/files/default/repo/roles/example.json +13 -0
- data/lib/skeletons/code_generator/files/default/serverspec_spec_helper.rb +8 -0
- data/lib/skeletons/code_generator/files/default/spec_helper.rb +2 -0
- data/lib/skeletons/code_generator/files/default/spec_helper_policyfile.rb +2 -0
- data/lib/skeletons/code_generator/metadata.rb +8 -0
- data/lib/skeletons/code_generator/recipes/app.rb +97 -0
- data/lib/skeletons/code_generator/recipes/attribute.rb +12 -0
- data/lib/skeletons/code_generator/recipes/cookbook.rb +94 -0
- data/lib/skeletons/code_generator/recipes/cookbook_file.rb +24 -0
- data/lib/skeletons/code_generator/recipes/lwrp.rb +23 -0
- data/lib/skeletons/code_generator/recipes/policyfile.rb +8 -0
- data/lib/skeletons/code_generator/recipes/recipe.rb +27 -0
- data/lib/skeletons/code_generator/recipes/repo.rb +67 -0
- data/lib/skeletons/code_generator/recipes/template.rb +32 -0
- data/lib/skeletons/code_generator/templates/default/LICENSE.all_rights.erb +3 -0
- data/lib/skeletons/code_generator/templates/default/LICENSE.apache2.erb +201 -0
- data/lib/skeletons/code_generator/templates/default/LICENSE.gplv2.erb +339 -0
- data/lib/skeletons/code_generator/templates/default/LICENSE.gplv3.erb +674 -0
- data/lib/skeletons/code_generator/templates/default/LICENSE.mit.erb +21 -0
- data/lib/skeletons/code_generator/templates/default/Policyfile.rb.erb +25 -0
- data/lib/skeletons/code_generator/templates/default/README.md.erb +4 -0
- 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 +21 -0
- data/lib/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +32 -0
- data/lib/skeletons/code_generator/templates/default/metadata.rb.erb +7 -0
- data/lib/skeletons/code_generator/templates/default/provider.rb.erb +0 -0
- data/lib/skeletons/code_generator/templates/default/recipe.rb.erb +5 -0
- data/lib/skeletons/code_generator/templates/default/recipe_spec.rb.erb +20 -0
- data/lib/skeletons/code_generator/templates/default/repo/gitignore.erb +11 -0
- data/lib/skeletons/code_generator/templates/default/resource.rb.erb +0 -0
- data/lib/skeletons/code_generator/templates/default/serverspec_default_spec.rb.erb +9 -0
- data/lib/skeletons/code_generator/templates/default/template.erb +0 -0
- data/test.txt +0 -0
- metadata +119 -6
data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/cookbooks/example/README.md
ADDED
@@ -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,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
|
@@ -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
|
data/lib/cookbook_creator/skeletons/code_generator/files/default/repo/environments/example.json
ADDED
@@ -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-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
|
+
```
|
@@ -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/essentials_roles.html
|
@@ -0,0 +1,97 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
context = ChefDK::Generator.context
|
4
|
+
app_dir = File.join(context.app_root, context.app_name)
|
5
|
+
cookbooks_dir = context.cookbook_root
|
6
|
+
cookbook_dir = File.join(cookbooks_dir, context.cookbook_name)
|
7
|
+
|
8
|
+
# app root dir
|
9
|
+
directory app_dir
|
10
|
+
|
11
|
+
# Top level files
|
12
|
+
|
13
|
+
# TK
|
14
|
+
template "#{app_dir}/.kitchen.yml" do
|
15
|
+
source 'kitchen.yml.erb'
|
16
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
17
|
+
end
|
18
|
+
|
19
|
+
directory "#{app_dir}/test/integration/default/serverspec" do
|
20
|
+
recursive true
|
21
|
+
end
|
22
|
+
|
23
|
+
directory "#{app_dir}/test/integration/helpers/serverspec" do
|
24
|
+
recursive true
|
25
|
+
end
|
26
|
+
|
27
|
+
cookbook_file "#{app_dir}/test/integration/helpers/serverspec/spec_helper.rb" do
|
28
|
+
source 'serverspec_spec_helper.rb'
|
29
|
+
action :create_if_missing
|
30
|
+
end
|
31
|
+
|
32
|
+
template "#{app_dir}/test/integration/default/serverspec/default_spec.rb" do
|
33
|
+
source 'serverspec_default_spec.rb.erb'
|
34
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
35
|
+
action :create_if_missing
|
36
|
+
end
|
37
|
+
|
38
|
+
# README
|
39
|
+
template "#{app_dir}/README.md" do
|
40
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Generated Cookbook:
|
44
|
+
|
45
|
+
# cookbook collection dir
|
46
|
+
directory cookbooks_dir
|
47
|
+
|
48
|
+
# cookbook collection dir
|
49
|
+
directory cookbook_dir
|
50
|
+
|
51
|
+
# metadata.rb
|
52
|
+
template "#{cookbook_dir}/metadata.rb" do
|
53
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
54
|
+
end
|
55
|
+
|
56
|
+
# chefignore
|
57
|
+
cookbook_file "#{cookbook_dir}/chefignore"
|
58
|
+
|
59
|
+
# Berks
|
60
|
+
cookbook_file "#{cookbook_dir}/Berksfile"
|
61
|
+
|
62
|
+
# Recipes
|
63
|
+
|
64
|
+
directory "#{cookbook_dir}/recipes"
|
65
|
+
|
66
|
+
template "#{cookbook_dir}/recipes/default.rb" do
|
67
|
+
source "recipe.rb.erb"
|
68
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Chefspec
|
72
|
+
directory "#{cookbook_dir}/spec/unit/recipes" do
|
73
|
+
recursive true
|
74
|
+
end
|
75
|
+
|
76
|
+
cookbook_file "#{cookbook_dir}/spec/spec_helper.rb" do
|
77
|
+
action :create_if_missing
|
78
|
+
end
|
79
|
+
|
80
|
+
template "#{cookbook_dir}/spec/unit/recipes/default_spec.rb" do
|
81
|
+
source "recipe_spec.rb.erb"
|
82
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
83
|
+
action :create_if_missing
|
84
|
+
end
|
85
|
+
|
86
|
+
# git
|
87
|
+
if context.have_git
|
88
|
+
if !context.skip_git_init
|
89
|
+
execute("initialize-git") do
|
90
|
+
command("git init .")
|
91
|
+
cwd app_dir
|
92
|
+
end
|
93
|
+
end
|
94
|
+
cookbook_file "#{app_dir}/.gitignore" do
|
95
|
+
source "gitignore"
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
context = ChefDK::Generator.context
|
3
|
+
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
|
4
|
+
attribute_dir = File.join(cookbook_dir, "attributes")
|
5
|
+
attribute_path = File.join(cookbook_dir, "attributes", "#{context.new_file_basename}.rb")
|
6
|
+
|
7
|
+
directory attribute_dir
|
8
|
+
|
9
|
+
template attribute_path do
|
10
|
+
source "attribute.rb.erb"
|
11
|
+
helpers(ChefDK::Generator::TemplateHelper)
|
12
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
context = CookbookCreator::Generator.context
|
2
|
+
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
|
3
|
+
|
4
|
+
# cookbook root dir
|
5
|
+
directory cookbook_dir
|
6
|
+
|
7
|
+
# metadata.rb
|
8
|
+
template "#{cookbook_dir}/metadata.rb" do
|
9
|
+
helpers(CookbookCreator::Generator::TemplateHelper)
|
10
|
+
action :create_if_missing
|
11
|
+
end
|
12
|
+
|
13
|
+
# README
|
14
|
+
template "#{cookbook_dir}/README.md" do
|
15
|
+
helpers(CookbookCreator::Generator::TemplateHelper)
|
16
|
+
action :create_if_missing
|
17
|
+
end
|
18
|
+
|
19
|
+
# chefignore
|
20
|
+
cookbook_file "#{cookbook_dir}/chefignore"
|
21
|
+
|
22
|
+
# Berks
|
23
|
+
template "#{cookbook_dir}/Berksfile" do
|
24
|
+
helpers(CookbookCreator::Generator::TemplateHelper)
|
25
|
+
source 'Berksfile.erb'
|
26
|
+
action :create_if_missing
|
27
|
+
end
|
28
|
+
|
29
|
+
# CookbookCreator & Serverspec
|
30
|
+
template "#{cookbook_dir}/.kitchen.yml" do
|
31
|
+
source 'kitchen.yml.erb'
|
32
|
+
helpers(CookbookCreator::Generator::TemplateHelper)
|
33
|
+
action :create_if_missing
|
34
|
+
end
|
35
|
+
|
36
|
+
directory "#{cookbook_dir}/test/integration/default/serverspec" do
|
37
|
+
recursive true
|
38
|
+
end
|
39
|
+
|
40
|
+
directory "#{cookbook_dir}/test/integration/helpers/serverspec" do
|
41
|
+
recursive true
|
42
|
+
end
|
43
|
+
|
44
|
+
cookbook_file "#{cookbook_dir}/test/integration/helpers/serverspec/spec_helper.rb" do
|
45
|
+
source 'serverspec_spec_helper.rb'
|
46
|
+
action :create_if_missing
|
47
|
+
end
|
48
|
+
|
49
|
+
template "#{cookbook_dir}/test/integration/default/serverspec/default_spec.rb" do
|
50
|
+
source 'serverspec_default_spec.rb.erb'
|
51
|
+
helpers(CookbookCreator::Generator::TemplateHelper)
|
52
|
+
action :create_if_missing
|
53
|
+
end
|
54
|
+
|
55
|
+
# Chefspec
|
56
|
+
directory "#{cookbook_dir}/spec/unit/recipes" do
|
57
|
+
recursive true
|
58
|
+
end
|
59
|
+
|
60
|
+
cookbook_file "#{cookbook_dir}/spec/spec_helper.rb" do
|
61
|
+
source "spec_helper.rb"
|
62
|
+
action :create_if_missing
|
63
|
+
end
|
64
|
+
|
65
|
+
template "#{cookbook_dir}/spec/unit/recipes/default_spec.rb" do
|
66
|
+
source "recipe_spec.rb.erb"
|
67
|
+
helpers(CookbookCreator::Generator::TemplateHelper)
|
68
|
+
action :create_if_missing
|
69
|
+
end
|
70
|
+
|
71
|
+
# Recipes
|
72
|
+
directory "#{cookbook_dir}/recipes"
|
73
|
+
|
74
|
+
template "#{cookbook_dir}/recipes/default.rb" do
|
75
|
+
source "recipe.rb.erb"
|
76
|
+
helpers(CookbookCreator::Generator::TemplateHelper)
|
77
|
+
action :create_if_missing
|
78
|
+
end
|
79
|
+
|
80
|
+
# Libraries
|
81
|
+
if context.lib
|
82
|
+
directory "#{cookbook_dir}/libraries"
|
83
|
+
|
84
|
+
template "#{cookbook_dir}/libraries/default.rb" do
|
85
|
+
source "library.rb.erb"
|
86
|
+
helpers(CookbookCreator::Generator::TemplateHelper)
|
87
|
+
action :create_if_missing
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
#LWRP
|
92
|
+
if context.lwrp
|
93
|
+
directory "#{cookbook_dir}/resources"
|
94
|
+
directory "#{cookbook_dir}/providers"
|
95
|
+
|
96
|
+
template "#{cookbook_dir}/resources/default.rb" do
|
97
|
+
source "resource.rb.erb"
|
98
|
+
helpers(CookbookCreator::Generator::TemplateHelper)
|
99
|
+
action :create_if_missing
|
100
|
+
end
|
101
|
+
|
102
|
+
template "#{cookbook_dir}/providers/default.rb" do
|
103
|
+
source "provider.rb.erb"
|
104
|
+
helpers(CookbookCreator::Generator::TemplateHelper)
|
105
|
+
action :create_if_missing
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# git
|
110
|
+
cookbook_file "#{cookbook_dir}/.gitignore" do
|
111
|
+
source "gitignore"
|
112
|
+
end
|