Sha256: 9d3308930ae1b28554648411370d9b700fd781d226b83f85e64180bef6f53fa6

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 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::provisioners::vocker")

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

        # Attempt to start service if not running
        @client.start_service
        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

2 entries across 2 versions & 1 rubygems

Version Path
vocker-0.3.3 lib/vocker/provisioner.rb
vocker-0.3.2 lib/vocker/provisioner.rb