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
@@ -0,0 +1,25 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Anicheev Serghei (<sanicheev@tacitknowledge.com>)
|
3
|
+
# Copyright:: Copyright (c) 2016 Tacit Knowledge.
|
4
|
+
#
|
5
|
+
|
6
|
+
module CookbookCreator
|
7
|
+
class Helpers
|
8
|
+
|
9
|
+
def self.load_config_file(default_options, modified_options)
|
10
|
+
config_file = default_options.merge!(modified_options)[:config_file]
|
11
|
+
File.exists?(config_file) ? config_file : raise_er
|
12
|
+
end
|
13
|
+
|
14
|
+
def raise_er
|
15
|
+
raise 'Selected config file does not exists or does not have read permissions'
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.merge_configs(default_config, config, sym_hash)
|
19
|
+
combined_config = default_config.merge!(sym_hash)
|
20
|
+
combined_config_options = combined_config.merge(config)
|
21
|
+
config.replace(combined_config_options)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Anicheev Serghei (<sanicheev@tacitknowledge.com>)
|
3
|
+
# Copyright:: Copyright (c) 2016 Tacit Knowledge.
|
4
|
+
#
|
5
|
+
|
6
|
+
require 'mixlib/cli'
|
7
|
+
require 'mixlib/config'
|
8
|
+
require 'cookbook_creator/config_loader'
|
9
|
+
require 'cookbook_creator/cli'
|
10
|
+
require 'cookbook_creator/helpers'
|
11
|
+
require 'cookbook_creator/generator'
|
12
|
+
require 'cookbook_creator/runner'
|
13
|
+
require 'cookbook_creator/config'
|
14
|
+
|
15
|
+
module CookbookCreator
|
16
|
+
class Main
|
17
|
+
|
18
|
+
attr_reader :params
|
19
|
+
|
20
|
+
def initialize(argv=[])
|
21
|
+
@cookbook_name = argv[0]
|
22
|
+
@params = argv
|
23
|
+
end
|
24
|
+
|
25
|
+
def run
|
26
|
+
config_location = ConfigLoader.new(nil, nil).config_location
|
27
|
+
CookbookCreator::MCLI.use_separate_default_options true
|
28
|
+
cli = CookbookCreator::MCLI.new
|
29
|
+
cli.run(@params)
|
30
|
+
generator_config = Helpers::load_config_file(cli.default_config, cli.config)
|
31
|
+
Config.from_file(generator_config)
|
32
|
+
sym_hash = Config.configuration.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
33
|
+
Helpers.merge_configs(cli.default_config, cli.config, sym_hash)
|
34
|
+
run_list = ["recipe[code_generator::cookbook]"]
|
35
|
+
cookbook_root = Generator::Context.cookbook_root
|
36
|
+
runner = Runner.new(cli.config[:generator_cookbook], run_list)
|
37
|
+
Generator.setup_context(cli.config)
|
38
|
+
runner.converge
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (<dan@getchef.com>)
|
3
|
+
# Copyright:: Copyright (c) 2014 Chef Software, Inc
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
|
19
|
+
# Null logger implementation that just ignores everything. This is used by
|
20
|
+
# classes that are intended to be reused outside of Chef, but need to offer
|
21
|
+
# logging functionality when used by other Chef code.
|
22
|
+
#
|
23
|
+
# It does not define the full interface provided by Logger, just enough to be
|
24
|
+
# a reasonable duck type. In particular, methods setting the log level, log
|
25
|
+
# device, etc., are not implemented because any code calling those methods
|
26
|
+
# probably expected a real logger and not this "fake" one.
|
27
|
+
class NullLogger
|
28
|
+
|
29
|
+
def fatal(message, &block)
|
30
|
+
end
|
31
|
+
|
32
|
+
def error(message, &block)
|
33
|
+
end
|
34
|
+
|
35
|
+
def warn(message, &block)
|
36
|
+
end
|
37
|
+
|
38
|
+
def info(message, &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
def debug(message, &block)
|
42
|
+
end
|
43
|
+
|
44
|
+
def add(severity, message=nil, progname=nil)
|
45
|
+
end
|
46
|
+
|
47
|
+
def <<(message)
|
48
|
+
end
|
49
|
+
|
50
|
+
def fatal?
|
51
|
+
false
|
52
|
+
end
|
53
|
+
|
54
|
+
def error?
|
55
|
+
false
|
56
|
+
end
|
57
|
+
|
58
|
+
def warn?
|
59
|
+
false
|
60
|
+
end
|
61
|
+
|
62
|
+
def info?
|
63
|
+
false
|
64
|
+
end
|
65
|
+
|
66
|
+
def debug?
|
67
|
+
false
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class PathHelper
|
2
|
+
def self.home(*args)
|
3
|
+
@@home_dir ||= self.all_homes { |p| break p }
|
4
|
+
if @@home_dir
|
5
|
+
path = File.join(@@home_dir, *args)
|
6
|
+
block_given? ? (yield path) : path
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.all_homes(*args)
|
11
|
+
paths = []
|
12
|
+
paths << Dir.home if ENV['HOME']
|
13
|
+
|
14
|
+
paths = paths.map { |home_path| home_path.gsub(path_separator, ::File::SEPARATOR) if home_path }
|
15
|
+
|
16
|
+
# Filter out duplicate paths and paths that don't exist.
|
17
|
+
valid_paths = paths.select { |home_path| home_path && Dir.exists?(home_path) }
|
18
|
+
valid_paths = valid_paths.uniq
|
19
|
+
|
20
|
+
# Join all optional path elements at the end.
|
21
|
+
# If a block is provided, invoke it - otherwise just return what we've got.
|
22
|
+
joined_paths = valid_paths.map { |home_path| File.join(home_path, *args) }
|
23
|
+
if block_given?
|
24
|
+
joined_paths.each { |p| yield p }
|
25
|
+
else
|
26
|
+
joined_paths
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.path_separator
|
31
|
+
File::SEPARATOR
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'chef'
|
2
|
+
require 'ohai'
|
3
|
+
require 'chef/config'
|
4
|
+
|
5
|
+
module CookbookCreator
|
6
|
+
class Runner
|
7
|
+
|
8
|
+
def initialize(cookbook_path, run_list)
|
9
|
+
@cookbook_path = File.expand_path(cookbook_path)
|
10
|
+
@run_list = run_list
|
11
|
+
@formatter = nil
|
12
|
+
@ohai = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def converge
|
16
|
+
configure
|
17
|
+
Chef::Runner.new(run_context).converge
|
18
|
+
rescue Chef::Exceptions::CookbookNotFound => e
|
19
|
+
message = "Could not find cookbook(s) to satisfy run list #{run_list.inspect} in #{cookbook_path}"
|
20
|
+
raise CookbookNotFound.new(message, e)
|
21
|
+
rescue => e
|
22
|
+
raise ChefConvergeError.new("Chef failed to converge: #{e}", e)
|
23
|
+
end
|
24
|
+
|
25
|
+
def run_context
|
26
|
+
@run_context ||= policy.setup_run_context
|
27
|
+
end
|
28
|
+
|
29
|
+
def policy
|
30
|
+
return @policy_builder if @policy_builder
|
31
|
+
@policy_builder = Chef::PolicyBuilder::Dynamic.new("generator-cookbook", ohai.data, {}, nil, formatter)
|
32
|
+
@policy_builder.load_node
|
33
|
+
@policy_builder.build_node
|
34
|
+
@policy_builder.node.run_list(@run_list)
|
35
|
+
@policy_builder.expand_run_list
|
36
|
+
@policy_builder
|
37
|
+
end
|
38
|
+
|
39
|
+
def configure
|
40
|
+
Chef::Config.solo = true
|
41
|
+
Chef::Config.cookbook_path = @cookbook_path
|
42
|
+
Chef::Config.color = true
|
43
|
+
Chef::Config.diff_disabled = true
|
44
|
+
# atomic file operations on Windows require Administrator privileges to be able to read the SACL from a file
|
45
|
+
# Using file_staging_uses_destdir(true) will get us inherited permissions indirectly on tempfile creation
|
46
|
+
Chef::Config.file_atomic_update = false if Chef::Platform.windows?
|
47
|
+
Chef::Config.file_staging_uses_destdir = true # Default in Chef 12+
|
48
|
+
end
|
49
|
+
|
50
|
+
def ohai
|
51
|
+
return @ohai if @ohai
|
52
|
+
|
53
|
+
@ohai = Ohai::System.new
|
54
|
+
@ohai.all_plugins(["platform", "platform_version"])
|
55
|
+
@ohai
|
56
|
+
end
|
57
|
+
|
58
|
+
def formatter
|
59
|
+
@formatter ||=
|
60
|
+
Chef::EventDispatch::Dispatcher.new.tap do |d|
|
61
|
+
d.register(Chef::Formatters.new(:doc, stdout, stderr))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def stdout
|
66
|
+
$stdout
|
67
|
+
end
|
68
|
+
|
69
|
+
def stderr
|
70
|
+
$stderr
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
@@ -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
|
data/lib/cookbook_creator/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md
ADDED
@@ -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,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.
|