Sha256: e2d2d394620d94f0a4791536fa036e58638b5a6b243a6c23b63ce798d725fcba

Contents?: true

Size: 2 KB

Versions: 16

Compression:

Stored size: 2 KB

Contents

require 'beaker-hostgenerator/data'
require 'beaker-hostgenerator/hypervisor'
require 'deep_merge/rails_compat'

module BeakerHostGenerator
  module Hypervisor
    class Docker < BeakerHostGenerator::Hypervisor::Interface
      include BeakerHostGenerator::Data

      def generate_node(node_info, base_config, bhg_version)
        base_config['docker_cmd'] = ['/sbin/init']
        base_config['image'] = node_info['ostype'].sub(/(\d)/, ':\1')
        base_config['image'].sub!(/\w+/, 'oraclelinux') if node_info['ostype'] =~ /^oracle/
        base_config['image'].sub!(/(\w+)/, '\1/leap') if node_info['ostype'] =~ /^opensuse/
        base_config['image'].sub!(/(\d{2})/, '\1.') if node_info['ostype'] =~ /^ubuntu/
        if node_info['bits'] == '64'
          base_config['image'] = "amd64/#{base_config['image']}"
        end

        docker_commands = []

        case node_info['ostype']
        when /^ubuntu/
          docker_commands << 'cp /bin/true /sbin/agetty'

          if node_info['ostype'] =~ /1404/
            docker_commands << 'rm /usr/sbin/policy-rc.d'
            docker_commands << 'rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl'
          end

          extra_packages_to_install = case node_info['ostype']
                                      when /1404/
                                        ['apt-transport-https']
                                      when /1604/
                                        ['locales']
                                      else
                                        ['locales', 'iproute2', 'gnupg']
                                      end

          docker_commands << "apt-get install -y net-tools wget #{extra_packages_to_install.join(' ')}"
          docker_commands << 'locale-gen en_US.UTF-8'
          docker_commands << 'echo LANG=en_US.UTF-8 > /etc/default/locale'

          base_config['docker_image_commands'] = docker_commands
        end

        return base_generate_node(node_info, base_config, bhg_version, :docker)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
beaker-hostgenerator-1.18.0 lib/beaker-hostgenerator/hypervisor/docker.rb
beaker-hostgenerator-1.17.0 lib/beaker-hostgenerator/hypervisor/docker.rb
beaker-hostgenerator-1.16.0 lib/beaker-hostgenerator/hypervisor/docker.rb
beaker-hostgenerator-1.15.0 lib/beaker-hostgenerator/hypervisor/docker.rb
beaker-hostgenerator-1.14.0 lib/beaker-hostgenerator/hypervisor/docker.rb
beaker-hostgenerator-1.13.0 lib/beaker-hostgenerator/hypervisor/docker.rb
beaker-hostgenerator-1.12.0 lib/beaker-hostgenerator/hypervisor/docker.rb
beaker-hostgenerator-1.11.1 lib/beaker-hostgenerator/hypervisor/docker.rb
beaker-hostgenerator-1.11.0 lib/beaker-hostgenerator/hypervisor/docker.rb
beaker-hostgenerator-1.10.0 lib/beaker-hostgenerator/hypervisor/docker.rb
beaker-hostgenerator-1.9.0 lib/beaker-hostgenerator/hypervisor/docker.rb
beaker-hostgenerator-1.8.0 lib/beaker-hostgenerator/hypervisor/docker.rb
beaker-hostgenerator-1.7.1 lib/beaker-hostgenerator/hypervisor/docker.rb
beaker-hostgenerator-1.7.0 lib/beaker-hostgenerator/hypervisor/docker.rb
beaker-hostgenerator-1.6.1 lib/beaker-hostgenerator/hypervisor/docker.rb
beaker-hostgenerator-1.6.0 lib/beaker-hostgenerator/hypervisor/docker.rb