Class: CookbookFetcherConfigureChef
- Inherits:
-
Object
- Object
- CookbookFetcherConfigureChef
- Defined in:
- lib/vagrant_cookbook_fetcher.rb
Overview
Injects auto-checkout-derived chef-solo config
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ CookbookFetcherConfigureChef
constructor
A new instance of CookbookFetcherConfigureChef.
Constructor Details
#initialize(app, env) ⇒ CookbookFetcherConfigureChef
Returns a new instance of CookbookFetcherConfigureChef.
156 157 158 |
# File 'lib/vagrant_cookbook_fetcher.rb', line 156 def initialize(app, env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/vagrant_cookbook_fetcher.rb', line 160 def call(env) # Do this even if fetch is disabled require 'pp' # there has got to be a better way provisioners_list = env[:vm].config.to_hash["keys"][:vm].provisioners chef_solo = provisioners_list.find { |p| p.shortcut === :chef_solo } if !chef_solo.nil? then solo_cfg = chef_solo.config if solo_cfg.roles_path.nil? then solo_cfg.roles_path = "combined/roles" else env[:ui].warn "Auto-checkout is keeping your custom chef-solo role path" end if solo_cfg.data_bags_path.nil? then solo_cfg.data_bags_path = "combined/data_bags" else env[:ui].warn "Auto-checkout is keeping your custom chef-solo data_bags path" end # Cookbooks has a default if solo_cfg.cookbooks_path === ["cookbooks", [:vm, "cookbooks"]] then # Read from filesystem if !File.exists?(".cookbook-order") then env[:ui].error "Auto-checkout could not a .cookbook-order file. You need to run provision with autocheckout enabled at least once (or else specify your own cookbook path)" end cbs = [] IO.readlines(".cookbook-order").each { |line| cbs.push line.chomp } solo_cfg.cookbooks_path = cbs else env[:ui].warn "Auto-checkout is keeping your custom chef-solo cookbook path" end end # Continue daisy chain @app.call(env) end |