Sha256: 077af7de3b2ed47ddba9d593cde25a4e685ea5983b7012c6a221abe517195ee1

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require "optparse"
require "vagrant"

module VagrantPlugins
  module Orchestrate
    module Command
      class Push < Vagrant.plugin("2", :command)
        include Vagrant::Util

        def execute
          options = {}

          opts = OptionParser.new do |o|
            o.banner = "Usage: vagrant orchestrate push"
            o.separator ""

            o.on("--reboot", "Reboot a managed server after the provisioning step") do
              options[:reboot] = true
            end
          end

          # Parse the options
          argv = parse_options(opts)

          with_target_vms(argv) do |machine|
            unless machine.provider_name.to_sym == :managed
              @env.ui.info("Skipping machine #{machine.name}")
              next
            end
            push(options)
          end
        end

        def push(options)
          ENV["VAGRANT_ORCHESTRATE_COMMAND"] = "PUSH"
          begin
            machine.action(:up, options)
            machine.action(:provision, options)
            machine.action(:reload, options) if options[:reboot]
            machine.action(:destroy, options)
          ensure
            ENV.delete "VAGRANT_ORCHESTRATE_COMMAND"
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-orchestrate-0.1.0 lib/vagrant-orchestrate/command/push.rb