Sha256: 8e863abf83ffb91d48ae34ec959438a6513f5f694fe2cddc49fdd5bb23a1fa85

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

module Vagabond
  module Actions
    module Provision
      def _provision
        name_required!
        if(lxc.exists?)
          if(lxc.running?)
            do_provision
          else
            ui.error "Node is not currently running: #{name}"
          end
        else
          ui.error "Node not created: #{name}"
        end
      end
      
      private

      def do_provision
        ui.info "#{ui.color('Vagabond:', :bold)} Provisioning node: #{ui.color(name, :magenta)}"
        com = "#{sudo} knife bootstrap #{lxc.container_ip(10, true)} -d chef-full -N #{name} -i /opt/hw-lxc-config/id_rsa "
        com << "--no-host-key-verify --run-list \"#{config[:run_list].join(',')}\" "
        if(config[:environment])
          com << "-E #{config[:environment]}"
        end
        if(options[:knife_opts])
          com << options[:knife_opts]
        end
        debug(com)
        # Send the live stream out since people will generally want to
        # know what's happening
        cmd = Mixlib::ShellOut.new(com, :live_stream => STDOUT, :timeout => 2000)
        cmd.run_command
        # NOTE: cmd.status.success? won't be valid, so check for FATAL
        # TODO: This isn't really the best check, but should be good
        # enough for now
        unless(cmd.stdout.include?('FATAL: Stacktrace'))
          ui.info ui.color('  -> PROVISIONED', :magenta)
          true
        else
          ui.info ui.color('  -> PROVISION FAILED', :red)
          false
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vagabond-0.2.8 lib/vagabond/actions/provision.rb
vagabond-0.2.6 lib/vagabond/actions/provision.rb
vagabond-0.2.4 lib/vagabond/actions/provision.rb