vagrant-lightsail 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.gitignore +10 -0
 - data/.rspec +2 -0
 - data/.rubocop.yml +26 -0
 - data/.ruby-version +1 -0
 - data/.travis.yml +5 -0
 - data/Gemfile +12 -0
 - data/LICENSE.txt +21 -0
 - data/README.md +117 -0
 - data/Rakefile +20 -0
 - data/box/lightsail.box +0 -0
 - data/box/metadata.json +3 -0
 - data/lib/vagrant-lightsail/action/connect_lightsail.rb +33 -0
 - data/lib/vagrant-lightsail/action/is_created.rb +18 -0
 - data/lib/vagrant-lightsail/action/is_stopped.rb +18 -0
 - data/lib/vagrant-lightsail/action/message_already_created.rb +16 -0
 - data/lib/vagrant-lightsail/action/message_not_created.rb +16 -0
 - data/lib/vagrant-lightsail/action/message_will_not_destroy.rb +16 -0
 - data/lib/vagrant-lightsail/action/read_ssh_info.rb +38 -0
 - data/lib/vagrant-lightsail/action/read_state.rb +46 -0
 - data/lib/vagrant-lightsail/action/run_instance.rb +89 -0
 - data/lib/vagrant-lightsail/action/setup_key.rb +55 -0
 - data/lib/vagrant-lightsail/action/start_instance.rb +40 -0
 - data/lib/vagrant-lightsail/action/stop_instance.rb +28 -0
 - data/lib/vagrant-lightsail/action/terminate_instance.rb +31 -0
 - data/lib/vagrant-lightsail/action/wait_for_state.rb +40 -0
 - data/lib/vagrant-lightsail/action.rb +165 -0
 - data/lib/vagrant-lightsail/config.rb +125 -0
 - data/lib/vagrant-lightsail/errors.rb +17 -0
 - data/lib/vagrant-lightsail/plugin.rb +28 -0
 - data/lib/vagrant-lightsail/provider.rb +41 -0
 - data/lib/vagrant-lightsail/version.rb +5 -0
 - data/lib/vagrant-lightsail.rb +13 -0
 - data/locales/en.yml +50 -0
 - data/spec/spec_helper.rb +2 -0
 - data/spec/vagrant/lightsail_spec.rb +11 -0
 - data/test/Vagrantfile +21 -0
 - data/test/puppet/lightsail/manifests/default.pp +1 -0
 - data/test/scripts/provision.sh +3 -0
 - data/test/test.sh +33 -0
 - data/vagrant-lightsail.gemspec +27 -0
 - metadata +160 -0
 
| 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'log4r'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module VagrantPlugins
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Lightsail
         
     | 
| 
      
 5 
     | 
    
         
            +
                module Action
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # This terminates the running instance.
         
     | 
| 
      
 7 
     | 
    
         
            +
                  class TerminateInstance
         
     | 
| 
      
 8 
     | 
    
         
            +
                    def initialize(app, _)
         
     | 
| 
      
 9 
     | 
    
         
            +
                      @app    = app
         
     | 
| 
      
 10 
     | 
    
         
            +
                      @logger = Log4r::Logger.new('vagrant_lightsail::action::terminate_instance')
         
     | 
| 
      
 11 
     | 
    
         
            +
                    end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                    def call(env)
         
     | 
| 
      
 14 
     | 
    
         
            +
                      server = env[:lightsail_client].get_instance(instance_name: env[:machine].id).instance
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                      # Destroy the server and remove the tracking ID
         
     | 
| 
      
 17 
     | 
    
         
            +
                      env[:ui].info(I18n.t('vagrant_lightsail.terminating'))
         
     | 
| 
      
 18 
     | 
    
         
            +
                      begin
         
     | 
| 
      
 19 
     | 
    
         
            +
                        env[:lightsail_client].delete_instance(instance_name: server.name)
         
     | 
| 
      
 20 
     | 
    
         
            +
                      rescue Aws::Lightsail::Errors => e
         
     | 
| 
      
 21 
     | 
    
         
            +
                        raise Errors::LightailError, message: e
         
     | 
| 
      
 22 
     | 
    
         
            +
                      end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                      env[:machine].id = nil
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                      @app.call(env)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    end
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,40 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'log4r'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'timeout'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module VagrantPlugins
         
     | 
| 
      
 5 
     | 
    
         
            +
              module Lightsail
         
     | 
| 
      
 6 
     | 
    
         
            +
                module Action
         
     | 
| 
      
 7 
     | 
    
         
            +
                  # This action will wait for a machine to reach a specific state
         
     | 
| 
      
 8 
     | 
    
         
            +
                  # or quit by timeout
         
     | 
| 
      
 9 
     | 
    
         
            +
                  class WaitForState
         
     | 
| 
      
 10 
     | 
    
         
            +
                    # env[:result] will be false in case of timeout.
         
     | 
| 
      
 11 
     | 
    
         
            +
                    # @param [Symbol] state Target machine state.
         
     | 
| 
      
 12 
     | 
    
         
            +
                    # @param [Number] timeout Timeout in seconds.
         
     | 
| 
      
 13 
     | 
    
         
            +
                    def initialize(app, _, state, timeout)
         
     | 
| 
      
 14 
     | 
    
         
            +
                      @app     = app
         
     | 
| 
      
 15 
     | 
    
         
            +
                      @logger  = Log4r::Logger.new('vagrant_lightsail::action::wait_for_state')
         
     | 
| 
      
 16 
     | 
    
         
            +
                      @state   = state
         
     | 
| 
      
 17 
     | 
    
         
            +
                      @timeout = timeout
         
     | 
| 
      
 18 
     | 
    
         
            +
                    end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                    def call(env)
         
     | 
| 
      
 21 
     | 
    
         
            +
                      env[:result] = true
         
     | 
| 
      
 22 
     | 
    
         
            +
                      if env[:machine].state.id == @state
         
     | 
| 
      
 23 
     | 
    
         
            +
                        @logger.info I18n.t('vagrant_lightsail.already_status', status: @state)
         
     | 
| 
      
 24 
     | 
    
         
            +
                      else
         
     | 
| 
      
 25 
     | 
    
         
            +
                        @logger.info "Waiting for machine to reach state #{@state}"
         
     | 
| 
      
 26 
     | 
    
         
            +
                        begin
         
     | 
| 
      
 27 
     | 
    
         
            +
                          Timeout.timeout(@timeout) do
         
     | 
| 
      
 28 
     | 
    
         
            +
                            sleep 2 until env[:machine].state.id == @state
         
     | 
| 
      
 29 
     | 
    
         
            +
                          end
         
     | 
| 
      
 30 
     | 
    
         
            +
                        rescue Timeout::Error
         
     | 
| 
      
 31 
     | 
    
         
            +
                          env[:result] = false # couldn't reach state in time
         
     | 
| 
      
 32 
     | 
    
         
            +
                        end
         
     | 
| 
      
 33 
     | 
    
         
            +
                      end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                      @app.call(env)
         
     | 
| 
      
 36 
     | 
    
         
            +
                    end
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,165 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module VagrantPlugins
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Lightsail
         
     | 
| 
      
 3 
     | 
    
         
            +
                module Action
         
     | 
| 
      
 4 
     | 
    
         
            +
                  include Vagrant::Action::Builtin
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                  # This action is called to read the SSH info of the machine. The
         
     | 
| 
      
 7 
     | 
    
         
            +
                  # resulting state is expected to be put into the
         
     | 
| 
      
 8 
     | 
    
         
            +
                  # `:machine_ssh_info` key.
         
     | 
| 
      
 9 
     | 
    
         
            +
                  def self.read_ssh_info
         
     | 
| 
      
 10 
     | 
    
         
            +
                    Vagrant::Action::Builder.new.tap do |b|
         
     | 
| 
      
 11 
     | 
    
         
            +
                      b.use ConfigValidate
         
     | 
| 
      
 12 
     | 
    
         
            +
                      b.use ConnectLightsail
         
     | 
| 
      
 13 
     | 
    
         
            +
                      b.use ReadSSHInfo
         
     | 
| 
      
 14 
     | 
    
         
            +
                    end
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  # This action is called to read the state of the machine. The
         
     | 
| 
      
 18 
     | 
    
         
            +
                  # resulting state is expected to be put into the
         
     | 
| 
      
 19 
     | 
    
         
            +
                  # `:machine_state_id` key.
         
     | 
| 
      
 20 
     | 
    
         
            +
                  def self.read_state
         
     | 
| 
      
 21 
     | 
    
         
            +
                    Vagrant::Action::Builder.new.tap do |b|
         
     | 
| 
      
 22 
     | 
    
         
            +
                      b.use ConfigValidate
         
     | 
| 
      
 23 
     | 
    
         
            +
                      b.use ConnectLightsail
         
     | 
| 
      
 24 
     | 
    
         
            +
                      b.use ReadState
         
     | 
| 
      
 25 
     | 
    
         
            +
                    end
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  # This action is called to bring the box up from nothing.
         
     | 
| 
      
 29 
     | 
    
         
            +
                  def self.up
         
     | 
| 
      
 30 
     | 
    
         
            +
                    Vagrant::Action::Builder.new.tap do |b|
         
     | 
| 
      
 31 
     | 
    
         
            +
                      b.use HandleBox
         
     | 
| 
      
 32 
     | 
    
         
            +
                      b.use ConfigValidate
         
     | 
| 
      
 33 
     | 
    
         
            +
                      b.use BoxCheckOutdated
         
     | 
| 
      
 34 
     | 
    
         
            +
                      b.use ConnectLightsail
         
     | 
| 
      
 35 
     | 
    
         
            +
                      b.use Call, IsCreated do |env1, b1|
         
     | 
| 
      
 36 
     | 
    
         
            +
                        if env1[:result]
         
     | 
| 
      
 37 
     | 
    
         
            +
                          b1.use Call, IsStopped do |env2, b2|
         
     | 
| 
      
 38 
     | 
    
         
            +
                            if env2[:result]
         
     | 
| 
      
 39 
     | 
    
         
            +
                              b2.use prepare_boot
         
     | 
| 
      
 40 
     | 
    
         
            +
                              b2.use StartInstance # restart this instance
         
     | 
| 
      
 41 
     | 
    
         
            +
                            else
         
     | 
| 
      
 42 
     | 
    
         
            +
                              b2.use MessageAlreadyCreated # TODO: write a better message
         
     | 
| 
      
 43 
     | 
    
         
            +
                            end
         
     | 
| 
      
 44 
     | 
    
         
            +
                          end
         
     | 
| 
      
 45 
     | 
    
         
            +
                        else
         
     | 
| 
      
 46 
     | 
    
         
            +
                          b1.use SetupKey
         
     | 
| 
      
 47 
     | 
    
         
            +
                          b1.use prepare_boot
         
     | 
| 
      
 48 
     | 
    
         
            +
                          b1.use RunInstance # launch a new instance
         
     | 
| 
      
 49 
     | 
    
         
            +
                        end
         
     | 
| 
      
 50 
     | 
    
         
            +
                      end
         
     | 
| 
      
 51 
     | 
    
         
            +
                    end
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                  def self.prepare_boot
         
     | 
| 
      
 55 
     | 
    
         
            +
                    Vagrant::Action::Builder.new.tap do |b|
         
     | 
| 
      
 56 
     | 
    
         
            +
                      b.use Provision
         
     | 
| 
      
 57 
     | 
    
         
            +
                      b.use SyncedFolders
         
     | 
| 
      
 58 
     | 
    
         
            +
                    end
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                  # This action is called to terminate the remote machine.
         
     | 
| 
      
 62 
     | 
    
         
            +
                  def self.destroy
         
     | 
| 
      
 63 
     | 
    
         
            +
                    Vagrant::Action::Builder.new.tap do |b|
         
     | 
| 
      
 64 
     | 
    
         
            +
                      b.use Call, DestroyConfirm do |env, b2|
         
     | 
| 
      
 65 
     | 
    
         
            +
                        if env[:result]
         
     | 
| 
      
 66 
     | 
    
         
            +
                          b2.use ConfigValidate
         
     | 
| 
      
 67 
     | 
    
         
            +
                          b2.use Call, IsCreated do |env2, b3|
         
     | 
| 
      
 68 
     | 
    
         
            +
                            unless env2[:result]
         
     | 
| 
      
 69 
     | 
    
         
            +
                              b3.use MessageNotCreated
         
     | 
| 
      
 70 
     | 
    
         
            +
                              next
         
     | 
| 
      
 71 
     | 
    
         
            +
                            end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                            b3.use ConnectLightsail
         
     | 
| 
      
 74 
     | 
    
         
            +
                            b3.use ProvisionerCleanup, :before if defined? ProvisionerCleanup
         
     | 
| 
      
 75 
     | 
    
         
            +
                            b3.use TerminateInstance
         
     | 
| 
      
 76 
     | 
    
         
            +
                          end
         
     | 
| 
      
 77 
     | 
    
         
            +
                        else
         
     | 
| 
      
 78 
     | 
    
         
            +
                          b2.use MessageWillNotDestroy
         
     | 
| 
      
 79 
     | 
    
         
            +
                        end
         
     | 
| 
      
 80 
     | 
    
         
            +
                      end
         
     | 
| 
      
 81 
     | 
    
         
            +
                    end
         
     | 
| 
      
 82 
     | 
    
         
            +
                  end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
                  # This action is called when `vagrant provision` is called.
         
     | 
| 
      
 85 
     | 
    
         
            +
                  def self.provision
         
     | 
| 
      
 86 
     | 
    
         
            +
                    Vagrant::Action::Builder.new.tap do |b|
         
     | 
| 
      
 87 
     | 
    
         
            +
                      b.use ConfigValidate
         
     | 
| 
      
 88 
     | 
    
         
            +
                      b.use Call, IsCreated do |env, b2|
         
     | 
| 
      
 89 
     | 
    
         
            +
                        unless env[:result]
         
     | 
| 
      
 90 
     | 
    
         
            +
                          b2.use MessageNotCreated
         
     | 
| 
      
 91 
     | 
    
         
            +
                          next
         
     | 
| 
      
 92 
     | 
    
         
            +
                        end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                        b2.use Provision
         
     | 
| 
      
 95 
     | 
    
         
            +
                      end
         
     | 
| 
      
 96 
     | 
    
         
            +
                    end
         
     | 
| 
      
 97 
     | 
    
         
            +
                  end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                  def self.reload
         
     | 
| 
      
 100 
     | 
    
         
            +
                    Vagrant::Action::Builder.new.tap do |b|
         
     | 
| 
      
 101 
     | 
    
         
            +
                      b.use ConfigValidate
         
     | 
| 
      
 102 
     | 
    
         
            +
                      b.use ConnectLightsail
         
     | 
| 
      
 103 
     | 
    
         
            +
                      b.use Call, IsCreated do |env, b2|
         
     | 
| 
      
 104 
     | 
    
         
            +
                        unless env[:result]
         
     | 
| 
      
 105 
     | 
    
         
            +
                          b2.use MessageNotCreated
         
     | 
| 
      
 106 
     | 
    
         
            +
                          next
         
     | 
| 
      
 107 
     | 
    
         
            +
                        end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
                        b2.use halt
         
     | 
| 
      
 110 
     | 
    
         
            +
                        b2.use up
         
     | 
| 
      
 111 
     | 
    
         
            +
                      end
         
     | 
| 
      
 112 
     | 
    
         
            +
                    end
         
     | 
| 
      
 113 
     | 
    
         
            +
                  end
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                  # This action is called to halt the remote machine.
         
     | 
| 
      
 116 
     | 
    
         
            +
                  def self.halt
         
     | 
| 
      
 117 
     | 
    
         
            +
                    Vagrant::Action::Builder.new.tap do |b|
         
     | 
| 
      
 118 
     | 
    
         
            +
                      b.use ConfigValidate
         
     | 
| 
      
 119 
     | 
    
         
            +
                      b.use Call, IsCreated do |env, b2|
         
     | 
| 
      
 120 
     | 
    
         
            +
                        unless env[:result]
         
     | 
| 
      
 121 
     | 
    
         
            +
                          b2.use MessageNotCreated
         
     | 
| 
      
 122 
     | 
    
         
            +
                          next
         
     | 
| 
      
 123 
     | 
    
         
            +
                        end
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
                        b2.use ConnectLightsail
         
     | 
| 
      
 126 
     | 
    
         
            +
                        b2.use StopInstance
         
     | 
| 
      
 127 
     | 
    
         
            +
                        b2.use WaitForState, :stopped, 120
         
     | 
| 
      
 128 
     | 
    
         
            +
                      end
         
     | 
| 
      
 129 
     | 
    
         
            +
                    end
         
     | 
| 
      
 130 
     | 
    
         
            +
                  end
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
                  # This action is called to SSH into the machine.
         
     | 
| 
      
 133 
     | 
    
         
            +
                  def self.ssh
         
     | 
| 
      
 134 
     | 
    
         
            +
                    Vagrant::Action::Builder.new.tap do |b|
         
     | 
| 
      
 135 
     | 
    
         
            +
                      b.use ConfigValidate
         
     | 
| 
      
 136 
     | 
    
         
            +
                      b.use Call, IsCreated do |env, b2|
         
     | 
| 
      
 137 
     | 
    
         
            +
                        unless env[:result]
         
     | 
| 
      
 138 
     | 
    
         
            +
                          b2.use MessageNotCreated
         
     | 
| 
      
 139 
     | 
    
         
            +
                          next
         
     | 
| 
      
 140 
     | 
    
         
            +
                        end
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
                        b2.use SSHExec
         
     | 
| 
      
 143 
     | 
    
         
            +
                      end
         
     | 
| 
      
 144 
     | 
    
         
            +
                    end
         
     | 
| 
      
 145 
     | 
    
         
            +
                  end
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
                  # The autload farm
         
     | 
| 
      
 148 
     | 
    
         
            +
                  action_root = Pathname.new(File.expand_path('../action', __FILE__))
         
     | 
| 
      
 149 
     | 
    
         
            +
                  autoload :ConnectLightsail, action_root.join('connect_lightsail')
         
     | 
| 
      
 150 
     | 
    
         
            +
                  autoload :IsCreated, action_root.join('is_created')
         
     | 
| 
      
 151 
     | 
    
         
            +
                  autoload :IsStopped, action_root.join('is_stopped')
         
     | 
| 
      
 152 
     | 
    
         
            +
                  autoload :MessageAlreadyCreated, action_root.join('message_already_created')
         
     | 
| 
      
 153 
     | 
    
         
            +
                  autoload :MessageNotCreated, action_root.join('message_not_created')
         
     | 
| 
      
 154 
     | 
    
         
            +
                  autoload :MessageWillNotDestroy, action_root.join('message_will_not_destroy')
         
     | 
| 
      
 155 
     | 
    
         
            +
                  autoload :ReadSSHInfo, action_root.join('read_ssh_info')
         
     | 
| 
      
 156 
     | 
    
         
            +
                  autoload :ReadState, action_root.join('read_state')
         
     | 
| 
      
 157 
     | 
    
         
            +
                  autoload :RunInstance, action_root.join('run_instance')
         
     | 
| 
      
 158 
     | 
    
         
            +
                  autoload :SetupKey, action_root.join('setup_key')
         
     | 
| 
      
 159 
     | 
    
         
            +
                  autoload :StartInstance, action_root.join('start_instance')
         
     | 
| 
      
 160 
     | 
    
         
            +
                  autoload :StopInstance, action_root.join('stop_instance')
         
     | 
| 
      
 161 
     | 
    
         
            +
                  autoload :TerminateInstance, action_root.join('terminate_instance')
         
     | 
| 
      
 162 
     | 
    
         
            +
                  autoload :WaitForState, action_root.join('wait_for_state')
         
     | 
| 
      
 163 
     | 
    
         
            +
                end
         
     | 
| 
      
 164 
     | 
    
         
            +
              end
         
     | 
| 
      
 165 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,125 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'iniparse'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module VagrantPlugins
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Lightsail
         
     | 
| 
      
 5 
     | 
    
         
            +
                class Config < Vagrant.plugin('2', :config)
         
     | 
| 
      
 6 
     | 
    
         
            +
                  attr_accessor :access_key_id
         
     | 
| 
      
 7 
     | 
    
         
            +
                  attr_accessor :availability_zone
         
     | 
| 
      
 8 
     | 
    
         
            +
                  attr_accessor :aws_dir
         
     | 
| 
      
 9 
     | 
    
         
            +
                  attr_accessor :aws_profile
         
     | 
| 
      
 10 
     | 
    
         
            +
                  attr_accessor :blueprint_id
         
     | 
| 
      
 11 
     | 
    
         
            +
                  attr_accessor :bundle_id
         
     | 
| 
      
 12 
     | 
    
         
            +
                  attr_accessor :endpoint
         
     | 
| 
      
 13 
     | 
    
         
            +
                  attr_accessor :keypair_name
         
     | 
| 
      
 14 
     | 
    
         
            +
                  attr_accessor :region
         
     | 
| 
      
 15 
     | 
    
         
            +
                  attr_accessor :secret_access_key
         
     | 
| 
      
 16 
     | 
    
         
            +
                  attr_accessor :session_token
         
     | 
| 
      
 17 
     | 
    
         
            +
                  attr_accessor :user_data
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                  def initialize
         
     | 
| 
      
 20 
     | 
    
         
            +
                    @access_key_id     = UNSET_VALUE
         
     | 
| 
      
 21 
     | 
    
         
            +
                    @availability_zone = UNSET_VALUE
         
     | 
| 
      
 22 
     | 
    
         
            +
                    @aws_dir           = UNSET_VALUE
         
     | 
| 
      
 23 
     | 
    
         
            +
                    @aws_profile       = UNSET_VALUE
         
     | 
| 
      
 24 
     | 
    
         
            +
                    @blueprint_id      = UNSET_VALUE
         
     | 
| 
      
 25 
     | 
    
         
            +
                    @bundle_id         = UNSET_VALUE
         
     | 
| 
      
 26 
     | 
    
         
            +
                    @endpoint          = UNSET_VALUE
         
     | 
| 
      
 27 
     | 
    
         
            +
                    @keypair_name      = UNSET_VALUE
         
     | 
| 
      
 28 
     | 
    
         
            +
                    @region            = UNSET_VALUE
         
     | 
| 
      
 29 
     | 
    
         
            +
                    @secret_access_key = UNSET_VALUE
         
     | 
| 
      
 30 
     | 
    
         
            +
                    @session_token     = UNSET_VALUE
         
     | 
| 
      
 31 
     | 
    
         
            +
                    @user_data         = UNSET_VALUE
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  def finalize!
         
     | 
| 
      
 35 
     | 
    
         
            +
                    if @access_key_id == UNSET_VALUE || @secret_access_key == UNSET_VALUE
         
     | 
| 
      
 36 
     | 
    
         
            +
                      @aws_profile = 'default'                   if @aws_profile == UNSET_VALUE
         
     | 
| 
      
 37 
     | 
    
         
            +
                      @aws_dir     = ENV['HOME'].to_s + '/.aws/' if @aws_dir == UNSET_VALUE
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                      @aws_region, @access_key_id, @secret_access_key, @session_token = Credentials.new.get_aws_info(@aws_profile, @aws_dir)
         
     | 
| 
      
 40 
     | 
    
         
            +
                      @region = @aws_region if @region == UNSET_VALUE && !@aws_region.nil?
         
     | 
| 
      
 41 
     | 
    
         
            +
                    else
         
     | 
| 
      
 42 
     | 
    
         
            +
                      @aws_profile = nil
         
     | 
| 
      
 43 
     | 
    
         
            +
                      @aws_dir     = nil
         
     | 
| 
      
 44 
     | 
    
         
            +
                    end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                    @blueprint_id      = 'ubuntu_16_04' if @blueprint_id      == UNSET_VALUE
         
     | 
| 
      
 47 
     | 
    
         
            +
                    @bundle_id         = 'nano_1_0'     if @bundle_id         == UNSET_VALUE
         
     | 
| 
      
 48 
     | 
    
         
            +
                    @endpoint          = nil            if @endpoint          == UNSET_VALUE
         
     | 
| 
      
 49 
     | 
    
         
            +
                    @keypair_name      = 'vagrant'      if @keypair_name      == UNSET_VALUE
         
     | 
| 
      
 50 
     | 
    
         
            +
                    @region            = 'us-east-1'    if @region            == UNSET_VALUE
         
     | 
| 
      
 51 
     | 
    
         
            +
                    @availability_zone = "#{@region}a"  if @availability_zone == UNSET_VALUE
         
     | 
| 
      
 52 
     | 
    
         
            +
                    @session_token     = nil            if @session_token     == UNSET_VALUE
         
     | 
| 
      
 53 
     | 
    
         
            +
                    @user_data         = nil            if @user_data         == UNSET_VALUE
         
     | 
| 
      
 54 
     | 
    
         
            +
                  end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                  def validate(_)
         
     | 
| 
      
 57 
     | 
    
         
            +
                    errors = []
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                    if @aws_profile && (@access_key_id.nil? || @secret_access_key.nil? || @region.nil?)
         
     | 
| 
      
 60 
     | 
    
         
            +
                      errors << I18n.t('vagrant_lightsail.config.aws_info_required',
         
     | 
| 
      
 61 
     | 
    
         
            +
                                       profile: @aws_profile, location: @aws_dir)
         
     | 
| 
      
 62 
     | 
    
         
            +
                    end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                    errors << I18n.t('vagrant_lightsail.config.region_required') if @region.nil?
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                    { 'Lightsail Provider' => errors }
         
     | 
| 
      
 67 
     | 
    
         
            +
                  end
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                class Credentials < Vagrant.plugin('2', :config)
         
     | 
| 
      
 71 
     | 
    
         
            +
                  def get_aws_info(profile, location)
         
     | 
| 
      
 72 
     | 
    
         
            +
                    aws_region, aws_id, aws_secret, aws_token = read_aws_environment
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                    if aws_id.to_s.empty? || aws_secret.to_s.empty?
         
     | 
| 
      
 75 
     | 
    
         
            +
                      aws_config = ENV['AWS_CONFIG_FILE'].to_s
         
     | 
| 
      
 76 
     | 
    
         
            +
                      aws_creds  = ENV['AWS_SHARED_CREDENTIALS_FILE'].to_s
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
                      if aws_config.empty? || aws_creds.empty?
         
     | 
| 
      
 79 
     | 
    
         
            +
                        aws_config = location + 'config'
         
     | 
| 
      
 80 
     | 
    
         
            +
                        aws_creds  = location + 'credentials'
         
     | 
| 
      
 81 
     | 
    
         
            +
                      end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                      if File.exist?(aws_config) && File.exist?(aws_creds)
         
     | 
| 
      
 84 
     | 
    
         
            +
                        aws_region, aws_id, aws_secret, aws_token = read_aws_files(profile, aws_config, aws_creds)
         
     | 
| 
      
 85 
     | 
    
         
            +
                      end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                    end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                    aws_region = nil if aws_region == ''
         
     | 
| 
      
 90 
     | 
    
         
            +
                    aws_id     = nil if aws_id     == ''
         
     | 
| 
      
 91 
     | 
    
         
            +
                    aws_secret = nil if aws_secret == ''
         
     | 
| 
      
 92 
     | 
    
         
            +
                    aws_token  = nil if aws_token  == ''
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                    [aws_region, aws_id, aws_secret, aws_token]
         
     | 
| 
      
 95 
     | 
    
         
            +
                  end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                  private
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                  def read_aws_files(profile, aws_config, aws_creds)
         
     | 
| 
      
 100 
     | 
    
         
            +
                    conf_profile = profile == 'default' ? profile : 'profile ' + profile
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
                    data_conf   = File.read(aws_config)
         
     | 
| 
      
 103 
     | 
    
         
            +
                    doc_conf    = IniParse.parse(data_conf)
         
     | 
| 
      
 104 
     | 
    
         
            +
                    aws_region  = doc_conf[conf_profile]['region']
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                    data_cred  = File.read(aws_creds)
         
     | 
| 
      
 107 
     | 
    
         
            +
                    doc_cred   = IniParse.parse(data_cred)
         
     | 
| 
      
 108 
     | 
    
         
            +
                    aws_id     = doc_cred[profile]['aws_access_key_id']
         
     | 
| 
      
 109 
     | 
    
         
            +
                    aws_secret = doc_cred[profile]['aws_secret_access_key']
         
     | 
| 
      
 110 
     | 
    
         
            +
                    aws_token  = doc_cred[profile]['aws_session_token']
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
                    [aws_region, aws_id, aws_secret, aws_token]
         
     | 
| 
      
 113 
     | 
    
         
            +
                  end
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                  def read_aws_environment
         
     | 
| 
      
 116 
     | 
    
         
            +
                    aws_region = ENV['AWS_DEFAULT_REGION']
         
     | 
| 
      
 117 
     | 
    
         
            +
                    aws_id     = ENV['AWS_ACCESS_KEY_ID']
         
     | 
| 
      
 118 
     | 
    
         
            +
                    aws_secret = ENV['AWS_SECRET_ACCESS_KEY']
         
     | 
| 
      
 119 
     | 
    
         
            +
                    aws_token  = ENV['AWS_SESSION_TOKEN']
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
                    [aws_region, aws_id, aws_secret, aws_token]
         
     | 
| 
      
 122 
     | 
    
         
            +
                  end
         
     | 
| 
      
 123 
     | 
    
         
            +
                end
         
     | 
| 
      
 124 
     | 
    
         
            +
              end
         
     | 
| 
      
 125 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'vagrant'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module VagrantPlugins
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Lightsail
         
     | 
| 
      
 5 
     | 
    
         
            +
                class VagrantLightsailError < Vagrant::Errors::VagrantError
         
     | 
| 
      
 6 
     | 
    
         
            +
                  error_namespace('vagrant_lightsail.errors')
         
     | 
| 
      
 7 
     | 
    
         
            +
                end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                class LightsailError < VagrantLightsailError
         
     | 
| 
      
 10 
     | 
    
         
            +
                  error_key(:lightsail_error)
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                class PublicKeyError < VagrantLightsailError
         
     | 
| 
      
 14 
     | 
    
         
            +
                  error_key(:public_key)
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module VagrantPlugins
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Lightsail
         
     | 
| 
      
 3 
     | 
    
         
            +
                class Plugin < Vagrant.plugin('2')
         
     | 
| 
      
 4 
     | 
    
         
            +
                  name 'Lightsail'
         
     | 
| 
      
 5 
     | 
    
         
            +
                  description <<-DESC
         
     | 
| 
      
 6 
     | 
    
         
            +
                    This plugin installs a provider that allows Vagrant to manage
         
     | 
| 
      
 7 
     | 
    
         
            +
                    machines in AWS Lightsail.
         
     | 
| 
      
 8 
     | 
    
         
            +
                  DESC
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  config(:lightsail, :provider) do
         
     | 
| 
      
 11 
     | 
    
         
            +
                    require_relative 'config'
         
     | 
| 
      
 12 
     | 
    
         
            +
                    Config
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  provider(:lightsail, parallel: true) do
         
     | 
| 
      
 16 
     | 
    
         
            +
                    setup_i18n
         
     | 
| 
      
 17 
     | 
    
         
            +
                    require_relative 'provider'
         
     | 
| 
      
 18 
     | 
    
         
            +
                    Provider
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  # This initializes the internationalization strings.
         
     | 
| 
      
 22 
     | 
    
         
            +
                  def self.setup_i18n
         
     | 
| 
      
 23 
     | 
    
         
            +
                    I18n.load_path << File.expand_path('locales/en.yml', Lightsail.source_root)
         
     | 
| 
      
 24 
     | 
    
         
            +
                    I18n.reload!
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'vagrant'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'vagrant-lightsail/action'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module VagrantPlugins
         
     | 
| 
      
 5 
     | 
    
         
            +
              module Lightsail
         
     | 
| 
      
 6 
     | 
    
         
            +
                class Provider < Vagrant.plugin('2', :provider)
         
     | 
| 
      
 7 
     | 
    
         
            +
                  def initialize(machine)
         
     | 
| 
      
 8 
     | 
    
         
            +
                    @machine = machine
         
     | 
| 
      
 9 
     | 
    
         
            +
                  end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  def action(name)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    return Action.send(name) if Action.respond_to?(name)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    nil
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  def ssh_info
         
     | 
| 
      
 17 
     | 
    
         
            +
                    # Run a custom action called "read_ssh_info" which does what
         
     | 
| 
      
 18 
     | 
    
         
            +
                    # it says and puts the resulting SSH info into the
         
     | 
| 
      
 19 
     | 
    
         
            +
                    # `:machine_ssh_info` key in the environment.
         
     | 
| 
      
 20 
     | 
    
         
            +
                    env = @machine.action('read_ssh_info', lock: false)
         
     | 
| 
      
 21 
     | 
    
         
            +
                    env[:machine_ssh_info]
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  def state
         
     | 
| 
      
 25 
     | 
    
         
            +
                    # Run a custom action called "read_state" which does what it
         
     | 
| 
      
 26 
     | 
    
         
            +
                    # says and puts the state into the `:machine_state_id` key in
         
     | 
| 
      
 27 
     | 
    
         
            +
                    # the environment.
         
     | 
| 
      
 28 
     | 
    
         
            +
                    env = @machine.action('read_state', lock: false)
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                    state_id = env[:machine_state_id]
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                    # Get the short and long description
         
     | 
| 
      
 33 
     | 
    
         
            +
                    short = I18n.t("vagrant_lightsail.states.short_#{state_id}")
         
     | 
| 
      
 34 
     | 
    
         
            +
                    long  = I18n.t("vagrant_lightsail.states.long_#{state_id}")
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                    # Return the MachineState object
         
     | 
| 
      
 37 
     | 
    
         
            +
                    Vagrant::MachineState.new(state_id, short, long)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'vagrant-lightsail/version'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'vagrant-lightsail/plugin'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module VagrantPlugins
         
     | 
| 
      
 5 
     | 
    
         
            +
              module Lightsail
         
     | 
| 
      
 6 
     | 
    
         
            +
                # This returns the path to the source of this plugin.
         
     | 
| 
      
 7 
     | 
    
         
            +
                #
         
     | 
| 
      
 8 
     | 
    
         
            +
                # @return [Pathname]
         
     | 
| 
      
 9 
     | 
    
         
            +
                def self.source_root
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
    
        data/locales/en.yml
    ADDED
    
    | 
         @@ -0,0 +1,50 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            en:
         
     | 
| 
      
 2 
     | 
    
         
            +
              vagrant_lightsail:
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
                config:
         
     | 
| 
      
 5 
     | 
    
         
            +
                  aws_info_required: |-
         
     | 
| 
      
 6 
     | 
    
         
            +
                    One or more of the needed AWS credentials are missing. No
         
     | 
| 
      
 7 
     | 
    
         
            +
                    environment variables are set nor profile '%{profile}' exists
         
     | 
| 
      
 8 
     | 
    
         
            +
                    at '%{location}'
         
     | 
| 
      
 9 
     | 
    
         
            +
                  region_required: |-
         
     | 
| 
      
 10 
     | 
    
         
            +
                    A region must be specified via "region"
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                errors:
         
     | 
| 
      
 13 
     | 
    
         
            +
                  lightsail_error: |-
         
     | 
| 
      
 14 
     | 
    
         
            +
                    There was an error talking to AWS. The error message is shown
         
     | 
| 
      
 15 
     | 
    
         
            +
                    below:
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                    %{message}
         
     | 
| 
      
 18 
     | 
    
         
            +
                  public_key: |-
         
     | 
| 
      
 19 
     | 
    
         
            +
                    There was an issue reading the public key at:
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    Path: %{path}
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                    Please check the file's permissions.
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                already_status: |-
         
     | 
| 
      
 26 
     | 
    
         
            +
                  The machine is already %{status}.
         
     | 
| 
      
 27 
     | 
    
         
            +
                creating_key: |-
         
     | 
| 
      
 28 
     | 
    
         
            +
                  Creating new SSH key %{name}...
         
     | 
| 
      
 29 
     | 
    
         
            +
                launching_instance: |-
         
     | 
| 
      
 30 
     | 
    
         
            +
                  Launching an instance with the following settings...
         
     | 
| 
      
 31 
     | 
    
         
            +
                launch_no_keypair: |-
         
     | 
| 
      
 32 
     | 
    
         
            +
                  Warning! You didn't specify a keypair to launch your instance with.
         
     | 
| 
      
 33 
     | 
    
         
            +
                  This can sometimes result in not being able to access your instance.
         
     | 
| 
      
 34 
     | 
    
         
            +
                not_created: |-
         
     | 
| 
      
 35 
     | 
    
         
            +
                  Instance is not created. Please run `vagrant up` first.
         
     | 
| 
      
 36 
     | 
    
         
            +
                ready: |-
         
     | 
| 
      
 37 
     | 
    
         
            +
                  Machine is booted and ready for use!
         
     | 
| 
      
 38 
     | 
    
         
            +
                starting: |-
         
     | 
| 
      
 39 
     | 
    
         
            +
                  Starting the instance...
         
     | 
| 
      
 40 
     | 
    
         
            +
                stopping: |-
         
     | 
| 
      
 41 
     | 
    
         
            +
                  Stopping the instance...
         
     | 
| 
      
 42 
     | 
    
         
            +
                terminating: |-
         
     | 
| 
      
 43 
     | 
    
         
            +
                  Terminating the instance...
         
     | 
| 
      
 44 
     | 
    
         
            +
                waiting_for_ready: |-
         
     | 
| 
      
 45 
     | 
    
         
            +
                  Waiting for instance to become "ready"...
         
     | 
| 
      
 46 
     | 
    
         
            +
                waiting_for_ssh: |-
         
     | 
| 
      
 47 
     | 
    
         
            +
                  Waiting for SSH to become available...
         
     | 
| 
      
 48 
     | 
    
         
            +
                will_not_destroy: |-
         
     | 
| 
      
 49 
     | 
    
         
            +
                  The instance '%{name}' will not be destroyed, since the
         
     | 
| 
      
 50 
     | 
    
         
            +
                  confirmation was declined.
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
    
        data/test/Vagrantfile
    ADDED
    
    | 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Vagrant.require_plugin('vagrant-lightsail')
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Vagrant.configure('2') do |config|
         
     | 
| 
      
 4 
     | 
    
         
            +
              config.ssh.private_key_path = '~/.ssh/id_rsa'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              config.vm.synced_folder '.', '/vagrant', disabled: true
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              config.vm.provider :lightsail do |provider, override|
         
     | 
| 
      
 9 
     | 
    
         
            +
                override.vm.box       = 'lightsail'
         
     | 
| 
      
 10 
     | 
    
         
            +
                override.vm.box_url   = 'https://github.com/thejandroman/vagrant-lightsail/raw/master/box/lightsail.box'
         
     | 
| 
      
 11 
     | 
    
         
            +
                override.ssh.username = 'ubuntu'
         
     | 
| 
      
 12 
     | 
    
         
            +
                provider.keypair_name = 'Test-Key'
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              config.vm.provision :shell, path: 'scripts/provision.sh'
         
     | 
| 
      
 16 
     | 
    
         
            +
              config.puppet_install.puppet_version = :latest
         
     | 
| 
      
 17 
     | 
    
         
            +
              config.vm.provision 'puppet' do |puppet|
         
     | 
| 
      
 18 
     | 
    
         
            +
                puppet.environment_path = 'puppet'
         
     | 
| 
      
 19 
     | 
    
         
            +
                puppet.environment      = 'lightsail'
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            notify { 'Testing 1 2 3!': }
         
     | 
    
        data/test/test.sh
    ADDED
    
    | 
         @@ -0,0 +1,33 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/bin/bash
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            destroy() {
         
     | 
| 
      
 4 
     | 
    
         
            +
                ANSWER=$1
         
     | 
| 
      
 5 
     | 
    
         
            +
                read -r -d '' EXPECT_CMD <<EOF
         
     | 
| 
      
 6 
     | 
    
         
            +
            spawn bundle exec vagrant destroy
         
     | 
| 
      
 7 
     | 
    
         
            +
            expect {Are you sure you want to destroy}
         
     | 
| 
      
 8 
     | 
    
         
            +
            send "$ANSWER\r"
         
     | 
| 
      
 9 
     | 
    
         
            +
            interact
         
     | 
| 
      
 10 
     | 
    
         
            +
            EOF
         
     | 
| 
      
 11 
     | 
    
         
            +
                expect -c "$EXPECT_CMD"
         
     | 
| 
      
 12 
     | 
    
         
            +
            }
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            if ! bundle exec vagrant box list | grep lightsail 1>/dev/null; then
         
     | 
| 
      
 15 
     | 
    
         
            +
                bundle exec vagrant box add box/lightsail.box
         
     | 
| 
      
 16 
     | 
    
         
            +
            fi
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            cd test || exit
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            bundle exec vagrant up --provider=lightsail
         
     | 
| 
      
 21 
     | 
    
         
            +
            bundle exec vagrant up
         
     | 
| 
      
 22 
     | 
    
         
            +
            bundle exec vagrant provision
         
     | 
| 
      
 23 
     | 
    
         
            +
            bundle exec vagrant reload
         
     | 
| 
      
 24 
     | 
    
         
            +
            bundle exec vagrant halt
         
     | 
| 
      
 25 
     | 
    
         
            +
            bundle exec vagrant up
         
     | 
| 
      
 26 
     | 
    
         
            +
            destroy 'N'
         
     | 
| 
      
 27 
     | 
    
         
            +
            bundle exec vagrant destroy --force
         
     | 
| 
      
 28 
     | 
    
         
            +
            exit
         
     | 
| 
      
 29 
     | 
    
         
            +
            destroy 'N'
         
     | 
| 
      
 30 
     | 
    
         
            +
            destroy 'y'
         
     | 
| 
      
 31 
     | 
    
         
            +
            bundle exec vagrant destroy --force
         
     | 
| 
      
 32 
     | 
    
         
            +
            bundle exec vagrant provision
         
     | 
| 
      
 33 
     | 
    
         
            +
            bundle exec vagrant reload
         
     | 
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # coding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'vagrant-lightsail/version'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'English'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.name        = 'vagrant-lightsail'
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.version     = VagrantPlugins::Lightsail::VERSION
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.authors     = ['Alejandro Figueroa']
         
     | 
| 
      
 11 
     | 
    
         
            +
              spec.email       = ['alejandro@ideasftw.com']
         
     | 
| 
      
 12 
     | 
    
         
            +
              spec.summary     = 'Enables Vagrant to manage machines in AWS Lightsail.'
         
     | 
| 
      
 13 
     | 
    
         
            +
              spec.description = 'Enables Vagrant to manage machines in AWS Lightsail.'
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.homepage    = 'http://github.com/thejandroman/vagrant-lightsail'
         
     | 
| 
      
 15 
     | 
    
         
            +
              spec.license     = 'MIT'
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              spec.files         = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
         
     | 
| 
      
 18 
     | 
    
         
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
      
 19 
     | 
    
         
            +
              spec.require_paths = ['lib']
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              spec.add_runtime_dependency 'aws-sdk', '~> 2.6'
         
     | 
| 
      
 22 
     | 
    
         
            +
              spec.add_runtime_dependency 'iniparse', '~> 1.4'
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              spec.add_development_dependency 'bundler', '~> 1.12'
         
     | 
| 
      
 25 
     | 
    
         
            +
              spec.add_development_dependency 'rake', '~> 12.0'
         
     | 
| 
      
 26 
     | 
    
         
            +
              spec.add_development_dependency 'rubocop', '~> 0.46'
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     |