Sha256: e46891fb72146860b7e4fb0a248a94c6ca419fbd75d671d32edb8b73377b811a

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require_relative "errors"
require_relative "docker_client"
require_relative "docker_installer"

module VagrantPlugins
  module Vocker
    # TODO: Improve handling of vagrant-lxc specifics (like checking for apparmor
    #       profile stuff + autocorrection)
    class Provisioner < Vagrant.plugin("2", :provisioner)
      def initialize(machine, config, installer = nil, client = nil)
        super(machine, config)
        @installer = installer || DockerInstaller.new(@machine)
        @client    = client    || DockerClient.new(@machine)
      end

      def provision
        @logger = Log4r::Logger.new("vagrant::plugins::docker-provisioner")

        @logger.info("Checking for Docker installation...")
        @installer.ensure_installed

        unless @client.daemon_running?
          raise Errors::DockerNotRunning
        end

        if config.images.any?
          @machine.ui.info(I18n.t("vagrant.docker_pulling_images"))
          @client.pull_images(*config.images)
        end

        if config.containers.any?
          @machine.ui.info(I18n.t("vagrant.docker_starting_containers"))
          @client.run(config.containers)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vocker-0.1.0 lib/vocker/provisioner.rb