Class: VagrantPlugins::R10k::Action::Deploy
- Defined in:
- lib/vagrant-r10k/action/deploy.rb
Overview
run r10k deploy
Instance Method Summary collapse
-
#call(env) ⇒ Object
determine if we should run, and get config.
-
#deploy(env, config) ⇒ Object
run the actual r10k deploy.
Methods inherited from Base
Methods included from Helpers
#env_dir, #get_puppetfile, #module_path, #provision_enabled?, #puppet_provisioner, #puppetfile_path, #r10k_config, #r10k_enabled?
Constructor Details
This class inherits a constructor from VagrantPlugins::R10k::Action::Base
Instance Method Details
#call(env) ⇒ Object
determine if we should run, and get config
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vagrant-r10k/action/deploy.rb', line 10 def call(env) @logger.debug "vagrant::r10k::deploy called" unless r10k_enabled?(env) env[:ui].info "vagrant-r10k not configured; skipping" return @app.call(env) end unless provision_enabled?(env) env[:ui].info "provisioning disabled; skipping vagrant-r10k" return @app.call(env) end # get our config config = r10k_config(env) if config.nil? @logger.info "vagrant::r10k::deploy got nil configuration" raise ErrorWrapper.new(RuntimeError.new("vagrant-r10k configuration error; cannot continue")) end @logger.debug("vagrant::r10k::deploy: env_dir_path=#{config[:env_dir_path]}") @logger.debug("vagrant::r10k::deploy: puppetfile_path=#{config[:puppetfile_path]}") @logger.debug("vagrant::r10k::deploy: module_path=#{config[:module_path]}") @logger.debug("vagrant::r10k::deploy: puppet_dir=#{config[:puppet_dir]}") deploy(env, config) @app.call(env) end |
#deploy(env, config) ⇒ Object
run the actual r10k deploy
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/vagrant-r10k/action/deploy.rb', line 40 def deploy(env, config) @logger.debug("vagrant::r10k::deploy.deploy called") require 'r10k/task_runner' require 'r10k/task/puppetfile' env[:ui].info "vagrant-r10k: Beginning r10k deploy of puppet modules into #{config[:module_path]} using #{config[:puppetfile_path]}" if ENV["VAGRANT_LOG"] == "debug" R10K::Logging.level = 'debug' else R10K::Logging.level = 'info' end unless File.file?(config[:puppetfile_path]) raise ErrorWrapper.new(RuntimeError.new("Puppetfile at #{config[:puppetfile_path]} does not exist.")) end # do the actual module buildout runner = R10K::TaskRunner.new([]) begin puppetfile = get_puppetfile(config) @logger.debug("vagrant-r10k: creating Puppetfile::Sync task") task = R10K::Task::Puppetfile::Sync.new(puppetfile) @logger.debug("vagrant-r10k: appending task to runner queue") runner.append_task task @logger.debug("vagrant-r10k: running sync task") runner.run @logger.debug("vagrant-r10k: sync task complete") rescue Exception => ex @env[:ui].error "Invalid syntax in Puppetfile at #{config[:puppetfile_path]}" raise ErrorWrapper.new(ex.original) end unless runner.succeeded? runner.get_errors().each do |error| if error[1]..include?("fatal: unable to access") and error[1]..include?("Could not resolve host") # if we can't resolve the host, the error should include how to skip provisioning @logger.debug("vagrant-r10k: caught 'Could not resolve host' error") raise ErrorWrapper.new(RuntimeError.new(error[1]. + "\n\nIf you don't have connectivity to the host, running 'vagrant up --no-provision' will skip r10k deploy and all provisioning.")) else raise ErrorWrapper.new(RuntimeError.new(error[1])) end end end @env[:ui].info "vagrant-r10k: Deploy finished" @app.call(env) end |