Sha256: e157cd887269c1384c16d9583e7405bf1a1101c98d3c75a1f5b31cd6f1cfd963

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 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(machine, options)
          end
        end

        def push(machine, 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

6 entries across 6 versions & 1 rubygems

Version Path
vagrant-orchestrate-0.3.2 lib/vagrant-orchestrate/command/push.rb
vagrant-orchestrate-0.3.1 lib/vagrant-orchestrate/command/push.rb
vagrant-orchestrate-0.3.0 lib/vagrant-orchestrate/command/push.rb
vagrant-orchestrate-0.2.1 lib/vagrant-orchestrate/command/push.rb
vagrant-orchestrate-0.2.0 lib/vagrant-orchestrate/command/push.rb
vagrant-orchestrate-0.1.1 lib/vagrant-orchestrate/command/push.rb