Sha256: 10451743d18ca4277fc2dfab4538d87a97d3bfe26a455ca2080a55cdfac0d7f9

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

module Vagabond
  module Actions
    module Provision
      def provision
        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(Config[:knife_opts])
          com << Config[: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)
        cmd.run_command
        # NOTE: cmd.status.success? won't be valid, so check for FATAL
        unless(cmd.stdout.split("\n").last.to_s.include?('FATAL'))
          ui.info ui.color('  -> PROVISIONED', :magenta)
        else
          ui.info ui.color('  -> PROVISION FAILED', :red)
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagabond-0.1.4 lib/vagabond/actions/provision.rb
vagabond-0.1.2 lib/vagabond/actions/provision.rb