Class: Chef::Knife::SoloInit
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::SoloInit
- Includes:
- FileUtils
- Defined in:
- lib/chef/knife/solo_init.rb
Direct Known Subclasses
Instance Method Summary collapse
- #config_value(key, default = nil) ⇒ Object
- #cookbook_manager ⇒ Object
- #create_config ⇒ Object
- #create_cupboards(dirs) ⇒ Object
- #create_kitchen ⇒ Object
- #gitignore(*entries) ⇒ Object
- #run ⇒ Object
- #validate! ⇒ Object
Instance Method Details
#config_value(key, default = nil) ⇒ Object
50 51 52 |
# File 'lib/chef/knife/solo_init.rb', line 50 def config_value(key, default = nil) KnifeSolo::Tools.config_value(config, key, default) end |
#cookbook_manager ⇒ Object
79 80 81 |
# File 'lib/chef/knife/solo_init.rb', line 79 def cookbook_manager KnifeSolo::CookbookManagerSelector.new(config, ui).select(@base) end |
#create_config ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/chef/knife/solo_init.rb', line 70 def create_config ui.msg "Creating knife.rb in kitchen..." mkdir_p File.join(@base, '.chef') knife_rb = File.join(@base, '.chef', 'knife.rb') unless File.exist?(knife_rb) cp KnifeSolo.resource('knife.rb'), knife_rb end end |
#create_cupboards(dirs) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/chef/knife/solo_init.rb', line 54 def create_cupboards(dirs) ui.msg "Creating cupboards..." dirs.each do |dir| cupboard_dir = File.join(@base, dir) unless File.exist?(cupboard_dir) mkdir cupboard_dir touch File.join(cupboard_dir, '.gitkeep') end end end |
#create_kitchen ⇒ Object
65 66 67 68 |
# File 'lib/chef/knife/solo_init.rb', line 65 def create_kitchen ui.msg "Creating kitchen..." mkdir @base unless @base == '.' end |
#gitignore(*entries) ⇒ Object
83 84 85 86 87 |
# File 'lib/chef/knife/solo_init.rb', line 83 def gitignore(*entries) if config_value(:git, true) KnifeSolo::Gitignore.new(@base).add(*entries) end end |
#run ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/chef/knife/solo_init.rb', line 30 def run @base = @name_args.first validate! create_kitchen create_config create_cupboards %w[nodes roles data_bags environments site-cookbooks cookbooks] gitignore %w[/cookbooks/] if (cm = cookbook_manager) cm.bootstrap(@base) end end |
#validate! ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/chef/knife/solo_init.rb', line 42 def validate! unless @base show_usage ui.fatal "You must specify a directory. Use '.' to initialize the current one." exit 1 end end |