class Vpsb::Tasks::DoApiAccess
Public Instance Methods
call()
click to toggle source
# File lib/vpsb/tasks/do_api_access.rb, line 10 def call prepare ask_loop(proc {|r| process(r)}) do ap preparation_results puts "Save this configuration y[es]/n[o]?" end update_knife_rb end
Private Instance Methods
config()
click to toggle source
# File lib/vpsb/tasks/do_api_access.rb, line 34 def config <<-EOS cookbook_path ["cookbooks", "site-cookbooks"] node_path "nodes" role_path "roles" environment_path "environments" data_bag_path "data_bags" encrypted_data_bag_secret "data_bag_key" # knife[:secret_file] = "data_bag_key" knife[:secret_file] = "~/chef-solo/data_bag_key" knife[:berkshelf_path] = "cookbooks" knife[:digital_ocean_client_id] = '#{core.get(:do_client_id)}' knife[:digital_ocean_api_key] = '#{core.get(:do_api_key)}' EOS end
process(result)
click to toggle source
# File lib/vpsb/tasks/do_api_access.rb, line 23 def process(result) return true if result[0].to_s.downcase == 'y' reprepare false end
update_knife_rb()
click to toggle source
# File lib/vpsb/tasks/do_api_access.rb, line 29 def update_knife_rb File.open(core.get(:knife_rb_path), "w+") { |f| f.write(config) } puts 'Knife.rb file created' end