Sha256: befa704e8d9758d778912af33ea0cda8899079029c5d3aa8fe0bbb58b9b8ed53

Contents?: true

Size: 1.75 KB

Versions: 12

Compression:

Stored size: 1.75 KB

Contents

require_relative "../container/provisioner"

require_relative "client"
require_relative "installer"

module VagrantPlugins
  module DockerProvisioner
    class DockerError < Vagrant::Errors::VagrantError
      error_namespace("vagrant.provisioners.docker")
    end

    class Provisioner < VagrantPlugins::ContainerProvisioner::Provisioner
      def initialize(machine, config, installer = nil, client = nil)
        super(machine, config)

        @installer = installer || Installer.new(@machine)
        @client    = client    || Client.new(@machine)
        @logger = Log4r::Logger.new("vagrant::provisioners::docker")
      end

      def provision
        @logger.info("Checking for Docker installation...")
        if @installer.ensure_installed
          if !config.post_install_provisioner.nil?
            @logger.info("Running post setup provision script...")
            env = {
                  callable: method(:run_provisioner),
                  provisioner: config.post_install_provisioner,
                  machine: machine}
            machine.env.hook(:run_provisioner, env)
          end
        end

        # Attempt to start service if not running
        @client.start_service
        raise DockerError, :not_running if !@client.daemon_running?

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

        if config.build_images.any?
          @machine.ui.info(I18n.t("vagrant.docker_building_images"))
          @client.build_images(config.build_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

12 entries across 12 versions & 3 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/provisioners/docker/provisioner.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/provisioners/docker/provisioner.rb
vagrant-unbundled-2.3.3.0 plugins/provisioners/docker/provisioner.rb
vagrant-unbundled-2.3.2.0 plugins/provisioners/docker/provisioner.rb
vagrant-unbundled-2.2.19.0 plugins/provisioners/docker/provisioner.rb
vagrant-unbundled-2.2.18.0 plugins/provisioners/docker/provisioner.rb
vagrant-unbundled-2.2.16.0 plugins/provisioners/docker/provisioner.rb
vagrant-unbundled-2.2.14.0 plugins/provisioners/docker/provisioner.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/provisioners/docker/provisioner.rb
vagrant-unbundled-2.2.10.0 plugins/provisioners/docker/provisioner.rb
vagrant-unbundled-2.2.9.0 plugins/provisioners/docker/provisioner.rb
vagrant-unbundled-2.2.8.0 plugins/provisioners/docker/provisioner.rb