From db60e5f426ff9d45ecfe75a03b17918bd0cfeefd Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 11 Jan 2011 19:50:20 -0800 Subject: [PATCH] Fix indentation on puppet.rb --- lib/vagrant/provisioners/puppet.rb | 129 ++++++++++++++--------------- 1 file changed, 64 insertions(+), 65 deletions(-) diff --git a/lib/vagrant/provisioners/puppet.rb b/lib/vagrant/provisioners/puppet.rb index a3fa9e2d1..9f4739abe 100644 --- a/lib/vagrant/provisioners/puppet.rb +++ b/lib/vagrant/provisioners/puppet.rb @@ -1,85 +1,84 @@ module Vagrant module Provisioners - - class PuppetError < Vagrant::Errors::VagrantError - error_namespace("vagrant.provisioners.puppet") - end - - class PuppetConfig < Vagrant::Config::Base - configures :puppet - - attr_accessor :manifest_file - attr_accessor :manifests_path - attr_accessor :pp_path - attr_accessor :options - - def initialize - @manifest_file = "" - @manifests_path = "manifests" - @pp_path = "/tmp/vagrant-puppet" - @options = [] - end - end - - class Puppet < Base - def prepare - check_manifest_dir - share_manifests + class PuppetError < Vagrant::Errors::VagrantError + error_namespace("vagrant.provisioners.puppet") end - def provision! - verify_binary("puppet") - create_pp_path - set_manifest - run_puppet_client - end + class PuppetConfig < Vagrant::Config::Base + configures :puppet - def check_manifest_dir - Dir.mkdir(env.config.puppet.manifests_path) unless File.directory?(env.config.puppet.manifests_path) - end + attr_accessor :manifest_file + attr_accessor :manifests_path + attr_accessor :pp_path + attr_accessor :options - def share_manifests - env.config.vm.share_folder("manifests", env.config.puppet.pp_path, env.config.puppet.manifests_path) - end - - def verify_binary(binary) - vm.ssh.execute do |ssh| - ssh.exec!("which #{binary}", :error_class => PuppetError, :_key => :puppet_not_detected, :binary => binary) + def initialize + @manifest_file = "" + @manifests_path = "manifests" + @pp_path = "/tmp/vagrant-puppet" + @options = [] end end - def create_pp_path - vm.ssh.execute do |ssh| - ssh.exec!("sudo mkdir -p #{env.config.puppet.pp_path}") - ssh.exec!("sudo chown #{env.config.ssh.username} #{env.config.puppet.pp_path}") + class Puppet < Base + def prepare + check_manifest_dir + share_manifests end - end - def set_manifest - @manifest = !env.config.puppet.manifest_file.empty? ? env.config.puppet.manifest_file : "#{env.config.vm.box}.pp" - - if File.exists?("#{env.config.puppet.manifests_path}/#{@manifest}") - env.ui.info I18n.t("vagrant.provisioners.puppet.manifest_to_run", :manifest => @manifest) - return @manifest - else - raise PuppetError, :_key => :manifest_missing, :manifest => @manifest + def provision! + verify_binary("puppet") + create_pp_path + set_manifest + run_puppet_client end - end - def run_puppet_client - options = env.config.puppet.options - options = options.join(" ") if options.is_a?(Array) - command = "cd #{env.config.puppet.pp_path} && sudo -E puppet #{options} #{@manifest}" + def check_manifest_dir + Dir.mkdir(env.config.puppet.manifests_path) unless File.directory?(env.config.puppet.manifests_path) + end - env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet") + def share_manifests + env.config.vm.share_folder("manifests", env.config.puppet.pp_path, env.config.puppet.manifests_path) + end - vm.ssh.execute do |ssh| - ssh.exec!(command) do |channel, type, data| - ssh.check_exit_status(data, command) if type == :exit_status - env.ui.info("#{data}: #{type}") if type != :exit_status + def verify_binary(binary) + vm.ssh.execute do |ssh| + ssh.exec!("which #{binary}", :error_class => PuppetError, :_key => :puppet_not_detected, :binary => binary) + end + end + + def create_pp_path + vm.ssh.execute do |ssh| + ssh.exec!("sudo mkdir -p #{env.config.puppet.pp_path}") + ssh.exec!("sudo chown #{env.config.ssh.username} #{env.config.puppet.pp_path}") + end + end + + def set_manifest + @manifest = !env.config.puppet.manifest_file.empty? ? env.config.puppet.manifest_file : "#{env.config.vm.box}.pp" + + if File.exists?("#{env.config.puppet.manifests_path}/#{@manifest}") + env.ui.info I18n.t("vagrant.provisioners.puppet.manifest_to_run", :manifest => @manifest) + return @manifest + else + raise PuppetError, :_key => :manifest_missing, :manifest => @manifest + end + end + + def run_puppet_client + options = env.config.puppet.options + options = options.join(" ") if options.is_a?(Array) + command = "cd #{env.config.puppet.pp_path} && sudo -E puppet #{options} #{@manifest}" + + env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet") + + vm.ssh.execute do |ssh| + ssh.exec!(command) do |channel, type, data| + ssh.check_exit_status(data, command) if type == :exit_status + env.ui.info("#{data}: #{type}") if type != :exit_status + end end end end end - end end