Sha256: af184a164a5bfe5b83cc6624570a882ede93fc92b159352e97692ccb9effc3d5

Contents?: true

Size: 1.48 KB

Versions: 5

Compression:

Stored size: 1.48 KB

Contents

module Coral
  module Vagrant
    module SubCommand
      class CoralRun < ::Vagrant.plugin('2', :command)

        #-----------------------------------------------------------------------
        # Execution
        
        def execute
          options = {}
          success = true

          opts = OptionParser.new do |opts|
            opts.banner = 'Usage: coral run --dir={plan_dir} {plan_name} ...'
            opts.separator ''

            options[:repo] = '.'
            opts.on('-r', '--repo REPO_DIR', 'Local directory of repository relative to the Vagrantfile root (.)') do |r|
              options[:repo] = r
            end

            options[:directory] = 'plans'
            opts.on('-d', '--dir DIRECTORY', 'Local directory that contains the plan(s) being executed (plans)') do |d|
              options[:directory] = d
            end
          end

          #---

          plans = parse_options(opts)
          return unless plans

          plans.each do |plan_name|
            @logger.debug("Running plan: #{plan_name}")

            success = Coral.create_plan(plan_name, {
              :home        => Coral.vagrant,
              :submodule   => options[:repo],
              :config_file => File.join([ options[:directory].to_s, "#{plan_name}.json" ]),
              :logger      => @logger,
              :ui          => @env.ui,
            }).run(options)

            break unless success
          end

          exit success ? 0 : 1
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
coral_vagrant-0.2.8 lib/coral_vagrant/commands/coral/run.rb
coral_vagrant-0.2.5 lib/coral_vagrant/commands/coral/run.rb
coral_vagrant-0.2.4 lib/coral_vagrant/commands/coral/run.rb
coral_vagrant-0.2.3 lib/coral_vagrant/commands/coral/run.rb
coral_vagrant-0.2.2 lib/coral_vagrant/commands/coral/run.rb