ventriloquist 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -4
  3. data/CHANGELOG.md +31 -0
  4. data/DEVELOPMENT.md +37 -0
  5. data/Gemfile +13 -13
  6. data/Gemfile.lock +48 -50
  7. data/LICENSE.txt +1 -1
  8. data/README.md +65 -114
  9. data/development/Vagrantfile +20 -55
  10. data/lib/ventriloquist/cap/platforms/debian/elixir_install.rb +23 -16
  11. data/lib/ventriloquist/cap/platforms/debian/erlang_install.rb +13 -10
  12. data/lib/ventriloquist/cap/platforms/debian/go_install.rb +18 -3
  13. data/lib/ventriloquist/cap/platforms/debian/phantomjs_install.rb +22 -4
  14. data/lib/ventriloquist/cap/platforms/debian/python.rb +2 -0
  15. data/lib/ventriloquist/cap/platforms/linux/nvm_install_nodejs.rb +2 -0
  16. data/lib/ventriloquist/cap/platforms/linux/rvm_install_ruby.rb +2 -0
  17. data/lib/ventriloquist/cap/services/debian/ventriloquist_containers_upstart.rb +1 -1
  18. data/lib/ventriloquist/cap/utils/debian/prepare_container_for_docker.rb +35 -0
  19. data/lib/ventriloquist/cap/utils/linux/download.rb +24 -10
  20. data/lib/ventriloquist/cap/utils.rb +5 -0
  21. data/lib/ventriloquist/config.rb +1 -1
  22. data/lib/ventriloquist/platforms/elixir.rb +7 -2
  23. data/lib/ventriloquist/platforms/erlang.rb +3 -0
  24. data/lib/ventriloquist/platforms/go.rb +7 -2
  25. data/lib/ventriloquist/platforms/nodejs.rb +9 -2
  26. data/lib/ventriloquist/platforms/phantomjs.rb +7 -2
  27. data/lib/ventriloquist/platforms/python.rb +9 -2
  28. data/lib/ventriloquist/platforms/ruby.rb +9 -2
  29. data/lib/ventriloquist/platforms_builder.rb +7 -2
  30. data/lib/ventriloquist/plugin.rb +0 -4
  31. data/lib/ventriloquist/provisioner.rb +10 -5
  32. data/lib/ventriloquist/service.rb +4 -5
  33. data/lib/ventriloquist/services/elastic_search.rb +1 -1
  34. data/lib/ventriloquist/services/mail_catcher.rb +1 -1
  35. data/lib/ventriloquist/services/memcached.rb +1 -1
  36. data/lib/ventriloquist/services/mysql.rb +1 -1
  37. data/lib/ventriloquist/services/postgresql.rb +1 -1
  38. data/lib/ventriloquist/services/redis.rb +2 -2
  39. data/lib/ventriloquist/services/rethink_db.rb +1 -5
  40. data/lib/ventriloquist/services_builder.rb +10 -7
  41. data/lib/ventriloquist/version.rb +1 -1
  42. data/services/base/Dockerfile +19 -11
  43. data/services/build-all.sh +11 -11
  44. data/services/elasticsearch/Dockerfile +4 -1
  45. data/services/mailcatcher/Dockerfile +11 -1
  46. data/services/memcached/Dockerfile +9 -4
  47. data/services/mysql/5.5/Dockerfile +1 -0
  48. data/services/mysql/5.6/Dockerfile +8 -4
  49. data/services/openjdk7/Dockerfile +6 -1
  50. data/services/postgresql/9.1/Dockerfile +8 -5
  51. data/services/postgresql/9.1/config/bin/prepare-postgres +2 -0
  52. data/services/postgresql/9.2/Dockerfile +7 -5
  53. data/services/postgresql/9.2/config/bin/prepare-postgres +2 -0
  54. data/services/postgresql/9.3/Dockerfile +5 -5
  55. data/services/postgresql/9.3/config/bin/prepare-postgres +2 -0
  56. data/services/redis/Dockerfile +7 -4
  57. data/services/rethinkdb/Dockerfile +8 -1
  58. data/spec/spec_helper.rb +7 -9
  59. data/spec/unit/platforms_builder_spec.rb +5 -9
  60. data/spec/unit/service_spec.rb +14 -16
  61. data/spec/unit/services_builder_spec.rb +10 -20
  62. data/ventriloquist.gemspec +0 -2
  63. metadata +11 -23
@@ -1,71 +1,36 @@
1
1
  # -*- mode: ruby -*-
2
2
  # vi: set ft=ruby :
3
3
 
4
- Vagrant.require_plugin 'vagrant-lxc'
5
- Vagrant.require_plugin 'vagrant-cachier'
6
- Vagrant.require_plugin 'vagrant-pristine'
7
- Vagrant.require_plugin 'vagrant-global-status'
8
- Vagrant.require_plugin 'ventriloquist'
9
-
10
4
  Vagrant.configure("2") do |config|
11
- config.vm.box = "raring64"
12
- config.vm.synced_folder "../", "/vagrant", id: 'vagrant-root'
13
-
14
- config.vm.network :private_network, ip: "192.168.123.123"
15
-
16
- config.cache.auto_detect = true
17
-
18
- config.vm.provider :virtualbox do |_, override|
19
- override.vm.box_url = 'http://cloud-images.ubuntu.com/vagrant/raring/current/raring-server-cloudimg-amd64-vagrant-disk1.box'
20
- end
21
-
22
5
  config.vm.provider :lxc do |lxc, override|
6
+ override.vm.box = 'fgrehm/raring64-lxc'
23
7
  # Required to boot nested containers
24
8
  lxc.customize 'aa_profile', 'unconfined'
25
- override.vm.box_url = 'http://bit.ly/vagrant-lxc-raring64-2013-10-23'
26
9
  end
27
10
 
28
- # Required to boot nested containers
29
- # Disable default lxc bridge
30
- config.vm.provision :shell, inline: %[
31
- cat <<STR > /etc/default/lxc
32
- LXC_AUTO="false"
33
- USE_LXC_BRIDGE="false"
34
- STR
35
- ]
11
+ config.vm.synced_folder "../", "/vagrant", id: 'vagrant-root'
36
12
 
37
- config.vm.provision :ventriloquist do |env|
38
- # Basic examples
39
- env.services << %w( redis memcached pg mailcatcher mysql rethinkdb )
40
- env.platforms << %w( nodejs phantomjs go erlang elixir python:2.7.5 )
13
+ config.cache.scope = :machine
14
+ config.ssh.forward_agent = true
41
15
 
42
- # Test custom ports and tagging
16
+ config.vm.provision :ventriloquist do |env|
17
+ # Test packages installation
18
+ env.packages << %w( htop telnet )
19
+ env.services << %w( redis-2.8 memcached-1.4 postgres-9.3 mailcatcher-0.5 mysql-5.6 rethinkdb-1.12 elasticsearch-1.1 )
43
20
  env.services << {
44
- 'es' => {
45
- image: 'fgrehm/ventriloquist-elasticsearch',
46
- # Check if container will get the built in elasticsearch configs
47
- type: 'elasticsearch',
48
- },
49
- 'pg-9.1' => {
50
- image: 'fgrehm/ventriloquist-pg',
51
- tag: '9.1' },
52
- 'es-2' => {
53
- image: 'fgrehm/ventriloquist-elasticsearch',
54
- tag: '0.90.3',
55
- ports: [':9200']
56
- } }
57
-
58
- # Test hash usage
59
- env.platforms << { ruby: { version: '2.0.0' } }
21
+ 'mc' => { vimage: 'memcached-1.4', args: '-P' }
22
+ }
60
23
 
61
- # Test packages installation
62
- env.packages << %w( htop sqlite3 curl wget )
24
+ # This will intentionally show some warnings
25
+ env.platforms << %w( phantomjs go erlang elixir python ruby nodejs )
63
26
  end
64
27
 
65
- # Remove docker dependency on lxc-net
66
- config.vm.provision :shell, inline: %[
67
- if $(grep -q 'and started' /etc/init/docker.conf); then
68
- sed -i.bkp 's/and started.*//' /etc/init/docker.conf
69
- fi
70
- ]
28
+ config.vm.provision :ventriloquist do |env|
29
+ env.platforms << %w( phantomjs-1.9.2 go-1.2.1 erlang elixir-0.11.1 python-3.0.1 )
30
+ env.platforms << {
31
+ # The first version provided will be set as the default
32
+ nodejs: { versions: ['0.10', '0.9'] },
33
+ ruby: { versions: ['2.1.1', '2.1.0'] }
34
+ }
35
+ end
71
36
  end
@@ -3,31 +3,38 @@ module VagrantPlugins
3
3
  module Cap
4
4
  module Debian
5
5
  module ElixirInstall
6
- ELIXIR_PRECOMPILED = "https://github.com/elixir-lang/elixir/releases/download/vVERSION/vVERSION.zip"
6
+ ELIXIR_PRECOMPILED_1 = "https://github.com/elixir-lang/elixir/releases/download/vVERSION/Precompiled.zip"
7
+ ELIXIR_PRECOMPILED_2 = "https://github.com/elixir-lang/elixir/releases/download/vVERSION/vVERSION.zip"
7
8
 
8
9
  def self.elixir_install(machine,version)
9
10
  @version = version
10
11
 
11
12
  machine.communicate.tap do |comm|
12
- if ! comm.test('which iex > /dev/null')
13
- bin_path = "/usr/local/elixir/bin"
14
- ELIXIR_PRECOMPILED.gsub!(/VERSION/,@version)
13
+ if comm.test('which iex > /dev/null')
14
+ machine.env.ui.info("Skipping Elixir installation")
15
+ return
16
+ end
17
+
18
+ bin_path = "/usr/local/elixir/bin"
19
+ srcs = [
20
+ ELIXIR_PRECOMPILED_1.gsub(/VERSION/, @version),
21
+ ELIXIR_PRECOMPILED_2.gsub(/VERSION/, @version)
22
+ ]
15
23
 
16
- machine.env.ui.info("Installing Elixir #{@version}")
24
+ machine.env.ui.info("Installing Elixir #{@version}")
17
25
 
18
- path = download_path(comm)
26
+ path = download_path(comm)
19
27
 
20
- unless comm.test("test -f #{path}")
21
- machine.guest.capability(:download, ELIXIR_PRECOMPILED, path)
22
- end
28
+ unless comm.test("test -f #{path}")
29
+ machine.guest.capability(:download, srcs, path)
30
+ end
23
31
 
24
- # TODO: Create unzip capability
25
- comm.sudo('apt-get install -y unzip')
26
- comm.sudo("unzip -o #{path} -d /usr/local/elixir")
32
+ # TODO: Create unzip capability
33
+ comm.sudo('apt-get install -y unzip')
34
+ comm.sudo("unzip -o #{path} -d /usr/local/elixir")
27
35
 
28
- if ! comm.test("grep -q '#{bin_path}' /etc/profile.d/ventriloquist.sh 2>/dev/null")
29
- comm.sudo("echo 'export PATH=$PATH:#{bin_path}' >> /etc/profile.d/ventriloquist.sh")
30
- end
36
+ if ! comm.test("grep -q '#{bin_path}' /etc/profile.d/ventriloquist.sh 2>/dev/null")
37
+ comm.sudo("echo 'export PATH=$PATH:#{bin_path}' >> /etc/profile.d/ventriloquist.sh")
31
38
  end
32
39
  end
33
40
  end
@@ -35,7 +42,7 @@ module VagrantPlugins
35
42
  private
36
43
 
37
44
  def self.download_path(comm)
38
- # If vagrant-cachier apt cache bucket is available, drop it there
45
+ # If vagrant-cachier cache bucket are available, drop it there
39
46
  if comm.test("test -d /tmp/vagrant-cache")
40
47
  "/tmp/vagrant-cache/elixir-v#{@version}.zip"
41
48
  else
@@ -3,22 +3,25 @@ module VagrantPlugins
3
3
  module Cap
4
4
  module Debian
5
5
  module ErlangInstall
6
- ERLANG_SOLUTIONS_PKG = "https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb"
6
+ ERLANG_SOLUTIONS_PKG = "http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb"
7
7
 
8
8
  def self.erlang_install(machine)
9
9
  machine.communicate.tap do |comm|
10
- if ! comm.test('which erl > /dev/null')
11
- machine.env.ui.info('Installing Erlang')
10
+ if comm.test('which erl > /dev/null')
11
+ machine.env.ui.info("Skipping Erlang installation")
12
+ return
13
+ end
12
14
 
13
- path = download_path(comm)
14
- unless comm.test("test -f #{path}")
15
- machine.guest.capability(:download, ERLANG_SOLUTIONS_PKG, path)
16
- end
17
- comm.sudo("dpkg -i #{path}")
15
+ machine.env.ui.info('Installing Erlang')
18
16
 
19
- comm.sudo('apt-get update')
20
- comm.sudo('apt-get -y install erlang')
17
+ path = download_path(comm)
18
+ unless comm.test("test -f #{path}")
19
+ machine.guest.capability(:download, ERLANG_SOLUTIONS_PKG, path)
21
20
  end
21
+ comm.sudo("dpkg -i #{path}")
22
+
23
+ comm.sudo('apt-get update')
24
+ comm.sudo('apt-get -y install erlang')
22
25
  end
23
26
  end
24
27
 
@@ -4,7 +4,10 @@ module VagrantPlugins
4
4
  module Debian
5
5
  module GoInstall
6
6
  def self.go_install(machine, version)
7
- return if machine.communicate.test('which go > /dev/null')
7
+ if machine.communicate.test('which go > /dev/null')
8
+ machine.env.ui.info("Skipping go installation")
9
+ return
10
+ end
8
11
 
9
12
  src = "https://go.googlecode.com/files/go#{version}.linux-amd64.tar.gz"
10
13
  bin_path = "/usr/local/go/bin"
@@ -13,8 +16,11 @@ module VagrantPlugins
13
16
  machine.env.ui.info("Installing go #{version}")
14
17
  machine.communicate.tap do |comm|
15
18
  comm.sudo('apt-get install curl -y -q')
16
- # TODO: Use download + untar capability and leverage vagrant-cachier
17
- comm.execute("cd /usr/local && curl #{src} | sudo tar xzfv -")
19
+ path = download_path(comm, version)
20
+ unless comm.test("test -f #{path}")
21
+ machine.guest.capability(:download, src, path)
22
+ end
23
+ comm.sudo("tar xzfv #{path} -C /usr/local")
18
24
 
19
25
  if ! comm.test("grep -q '#{bin_path}' /etc/profile.d/ventriloquist.sh 2>/dev/null")
20
26
  comm.sudo("echo 'export PATH=$PATH:#{bin_path}' >> /etc/profile.d/ventriloquist.sh")
@@ -27,6 +33,15 @@ module VagrantPlugins
27
33
  end
28
34
  end
29
35
  end
36
+
37
+ def self.download_path(comm, version)
38
+ # If vagrant-cachier cache buckets are available, drop it there
39
+ if comm.test("test -d /tmp/vagrant-cache")
40
+ "/tmp/vagrant-cache/go-#{version}.tar.gz"
41
+ else
42
+ "/tmp/go-#{version}.tar.gz"
43
+ end
44
+ end
30
45
  end
31
46
  end
32
47
  end
@@ -4,19 +4,37 @@ module VagrantPlugins
4
4
  module Debian
5
5
  module PhantomjsInstall
6
6
  def self.phantomjs_install(machine, version)
7
- return if machine.communicate.test('which phantomjs > /dev/null')
7
+ if machine.communicate.test('which phantomjs > /dev/null')
8
+ machine.env.ui.info("Skipping phantomjs installation")
9
+ return
10
+ end
8
11
 
9
- src = "https://phantomjs.googlecode.com/files/phantomjs-#{version}-linux-x86_64.tar.bz2"
12
+ src_1 = "https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-#{version}-linux-x86_64.tar.bz2"
13
+ src_2 = "https://phantomjs.googlecode.com/files/phantomjs-#{version}-linux-x86_64.tar.bz2"
10
14
  executable = "/usr/local/share/phantomjs-#{version}-linux-x86_64/bin/phantomjs"
11
15
 
12
16
  machine.env.ui.info("Installing phantomjs #{version}")
13
17
  machine.communicate.tap do |comm|
14
18
  comm.sudo('apt-get install -y fontconfig libfreetype6 curl -y -q')
15
- # TODO: Use download + untar capability and leverage vagrant-cachier
16
- comm.execute("cd /usr/local/share && curl #{src} | sudo tar xjfv -")
19
+ path = download_path(comm, version)
20
+ unless comm.test("test -f #{path}")
21
+ machine.guest.capability(:download, [src_1, src_2], path)
22
+ end
23
+ comm.sudo("tar xjfv #{path} -C /usr/local/share")
17
24
  comm.sudo("ln -s #{executable} /usr/local/bin/phantomjs")
18
25
  end
19
26
  end
27
+
28
+ private
29
+
30
+ def self.download_path(comm, version)
31
+ # If vagrant-cachier cache buckets are available, drop it there
32
+ if comm.test("test -d /tmp/vagrant-cache")
33
+ "/tmp/vagrant-cache/phantomjs-#{version}.tar.bz2"
34
+ else
35
+ "/tmp/phantomjs-#{version}.tar.bz2"
36
+ end
37
+ end
20
38
  end
21
39
  end
22
40
  end
@@ -26,6 +26,8 @@ module VagrantPlugins
26
26
  machine.env.ui.info("Installing Python #{version}")
27
27
  machine.communicate.execute("pyenv install #{version}")
28
28
  machine.communicate.execute("pyenv global #{version}")
29
+ else
30
+ machine.env.ui.info("Skipping Python '#{version}' installation")
29
31
  end
30
32
  end
31
33
  end
@@ -8,6 +8,8 @@ module VagrantPlugins
8
8
  machine.env.ui.info("Installing NodeJS #{version}")
9
9
  machine.communicate.execute("nvm install #{version}")
10
10
  machine.communicate.execute("nvm alias default #{version}")
11
+ else
12
+ machine.env.ui.info("Skipping NodeJS '#{version}' installation")
11
13
  end
12
14
  end
13
15
  end
@@ -8,6 +8,8 @@ module VagrantPlugins
8
8
  machine.env.ui.info("Installing Ruby #{version}")
9
9
  machine.communicate.sudo("rvm install #{version}")
10
10
  machine.guest.capability(:install_packages, 'libxslt1-dev', silent: true)
11
+ else
12
+ machine.env.ui.info("Skipping Ruby #{version} installation")
11
13
  end
12
14
  end
13
15
  end
@@ -7,7 +7,7 @@ module VagrantPlugins
7
7
  machine.communicate.tap do |comm|
8
8
  if ! comm.test('test -f /etc/init/ventriloquist.conf')
9
9
  machine.env.ui.info('Configuring Ventriloquist services upstart')
10
- machine.communicate.sudo '
10
+ comm.sudo '
11
11
  cat<<EOF > /etc/init/ventriloquist.conf
12
12
  description "Restart configured Ventriloquist services after reboot"
13
13
 
@@ -0,0 +1,35 @@
1
+ module VagrantPlugins
2
+ module Ventriloquist
3
+ module Cap
4
+ module Debian
5
+ module PrepareContainerForDocker
6
+ def self.prepare_container_for_docker(machine)
7
+ machine.communicate.tap do |comm|
8
+ # Disable the default lxc bridge to prevent issues when starting the container
9
+ if ! comm.test('test -f /etc/default/lxc')
10
+ comm.sudo '
11
+ cat <<STR > /etc/default/lxc
12
+ LXC_AUTO="false"
13
+ USE_LXC_BRIDGE="false"
14
+ STR
15
+ apt-get update && \
16
+ apt-get install -y --force-yes lxc \
17
+ -o Dpkg::Options::="--force-confdef" \
18
+ -o Dpkg::Options::="--force-confold"'
19
+ end
20
+
21
+ # Switch to lxc execution driver as wasn't able to get libcontainer to work
22
+ if ! comm.test('$(grep -q "-e lxc" /etc/default/docker)')
23
+ comm.sudo '
24
+ cat <<STR >> /etc/default/docker
25
+ DOCKER_OPTS="-e lxc ${DOCKER_OPTS}"
26
+ STR
27
+ service docker restart'
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -3,19 +3,19 @@ module VagrantPlugins
3
3
  module Cap
4
4
  module Linux
5
5
  module Download
6
- def self.download(machine, src, destination)
6
+ def self.download(machine, srcs, destination)
7
7
  machine.communicate.tap do |comm|
8
8
  if comm.test('which wget')
9
- download_with_wget(machine, src, destination)
9
+ download_with_wget(machine, srcs, destination)
10
10
 
11
11
  elsif comm.test('which curl')
12
- download_with_curl(machine, src, destination)
12
+ download_with_curl(machine, srcs, destination)
13
13
 
14
14
  # If neither wget or curl could be found, try installing
15
15
  # curl
16
16
  elsif machine.capability?(:install_packages)
17
17
  machine.guest.capability(:install_packages, 'curl')
18
- download_with_curl(machine, src, destination)
18
+ download_with_curl(machine, srcs, destination)
19
19
 
20
20
  else
21
21
  raise 'Unable to download file for guest VM!'
@@ -23,14 +23,28 @@ module VagrantPlugins
23
23
  end
24
24
  end
25
25
 
26
- def self.download_with_wget(machine, src, destination)
27
- machine.env.ui.info("Downloading #{src} to #{destination}")
28
- machine.communicate.execute("wget #{src} -O #{destination}")
26
+ def self.download_with_wget(machine, srcs, destination)
27
+ Array(srcs).each_with_index do |src, idx|
28
+ machine.env.ui.info("Attempting to download '#{src}' to '#{destination}'")
29
+ begin
30
+ machine.communicate.execute("wget #{src} -O #{destination} || { rm -f #{destination} && exit 1; }")
31
+ break
32
+ rescue Vagrant::Errors::VagrantError => e
33
+ raise if idx + 1 == srcs.size
34
+ end
35
+ end
29
36
  end
30
37
 
31
- def self.download_with_curl(machine, src, destination)
32
- machine.env.ui.info("Downloading #{src} to #{destination}")
33
- machine.communicate.execute("curl #{src} -o #{destination}")
38
+ def self.download_with_curl(machine, srcs, destination)
39
+ Array(srcs).each_with_index do |src, idx|
40
+ machine.env.ui.info("Attempting to download '#{src}' to '#{destination}'")
41
+ begin
42
+ machine.communicate.execute("curl #{src} -o #{destination} || { rm -f #{destination} && exit 1; }")
43
+ break
44
+ rescue Vagrant::Errors::VagrantError => e
45
+ raise if idx + 1 == srcs.size
46
+ end
47
+ end
34
48
  end
35
49
  end
36
50
  end
@@ -1,6 +1,11 @@
1
1
  module VagrantPlugins
2
2
  module Ventriloquist
3
3
  class Plugin < Vagrant.plugin("2")
4
+ guest_capability("debian", "prepare_container_for_docker") do
5
+ require_relative "utils/debian/prepare_container_for_docker"
6
+ Cap::Debian::PrepareContainerForDocker
7
+ end
8
+
4
9
  guest_capability("debian", "git_install") do
5
10
  require_relative "utils/debian/git_install"
6
11
  Cap::Debian::GitInstall
@@ -8,7 +8,7 @@ module VagrantPlugins
8
8
  @services = []
9
9
  @platforms = []
10
10
  @packages = []
11
- @docker_version = '0.7.0'
11
+ @docker_version = '0.9.1'
12
12
  end
13
13
  end
14
14
  end
@@ -3,10 +3,15 @@ module VagrantPlugins
3
3
  module Platforms
4
4
  class Elixir < Platform
5
5
  def provision(machine)
6
- @config[:version] = '0.11.2' if @config[:version] == 'latest'
6
+ if @config[:versions].empty?
7
+ machine.env.ui.warn('No elixir version specified, skipping installation')
8
+ return
9
+ elsif @config[:versions].size > 1
10
+ machine.env.ui.warn('Multiple versions specified for elixir, installing the first one configured')
11
+ end
7
12
  machine.guest.tap do |guest|
8
13
  guest.capability(:erlang_install)
9
- guest.capability(:elixir_install, @config[:version])
14
+ guest.capability(:elixir_install, @config[:versions].first)
10
15
  end
11
16
  end
12
17
  end
@@ -3,6 +3,9 @@ module VagrantPlugins
3
3
  module Platforms
4
4
  class Erlang < Platform
5
5
  def provision(machine)
6
+ if ! @config[:versions].empty?
7
+ machine.env.ui.warn('Multiple versions of erlang were specified but the latest one will be installed')
8
+ end
6
9
  machine.guest.capability(:erlang_install)
7
10
  end
8
11
  end
@@ -3,9 +3,14 @@ module VagrantPlugins
3
3
  module Platforms
4
4
  class Go < Platform
5
5
  def provision(machine)
6
- @config[:version] = '1.2' if @config[:version] == 'latest'
6
+ if @config[:versions].empty?
7
+ machine.env.ui.warn('No golang version specified, skipping installation')
8
+ return
9
+ elsif @config[:versions].size > 1
10
+ machine.env.ui.warn('Multiple versions specified for golang, installing the first one configured')
11
+ end
7
12
  machine.guest.capability(:mercurial_install)
8
- machine.guest.capability(:go_install, @config[:version])
13
+ machine.guest.capability(:go_install, @config[:versions].first)
9
14
  end
10
15
  end
11
16
  end
@@ -3,11 +3,18 @@ module VagrantPlugins
3
3
  module Platforms
4
4
  class NodeJS < Platform
5
5
  def provision(machine)
6
- @config[:version] = '0.10' if @config[:version] == 'latest'
6
+ if @config[:versions].empty?
7
+ machine.env.ui.warn('No nodejs version was specified and only nvm will be installed')
8
+ end
9
+
7
10
  machine.guest.tap do |guest|
8
11
  guest.capability(:install_packages, 'curl', silent: true)
9
12
  guest.capability(:nvm_install)
10
- guest.capability(:nvm_install_nodejs, @config[:version])
13
+ # Reverse array so that the first version specified is installed last
14
+ # and gets set as the default
15
+ @config[:versions].reverse.each do |version|
16
+ guest.capability(:nvm_install_nodejs, version)
17
+ end
11
18
  end
12
19
  end
13
20
  end
@@ -3,8 +3,13 @@ module VagrantPlugins
3
3
  module Platforms
4
4
  class PhantomJS < Platform
5
5
  def provision(machine)
6
- @config[:version] = '1.9.2' if config[:version] == 'latest'
7
- machine.guest.capability(:phantomjs_install, @config[:version])
6
+ if @config[:versions].empty?
7
+ machine.env.ui.warn('No phantomjs version specified, skipping installation')
8
+ return
9
+ elsif @config[:versions].size > 1
10
+ machine.env.ui.warn('Multiple versions specified for phantomjs, installing the first one configured')
11
+ end
12
+ machine.guest.capability(:phantomjs_install, @config[:versions].first)
8
13
  end
9
14
  end
10
15
  end
@@ -3,10 +3,17 @@ module VagrantPlugins
3
3
  module Platforms
4
4
  class Python < Platform
5
5
  def provision(machine)
6
- @config[:version] = '3.3.2' if @config[:version] == 'latest'
6
+ if @config[:versions].empty?
7
+ machine.env.ui.warn('No python version was specified and only pyenv will be installed')
8
+ end
9
+
7
10
  machine.guest.tap do |guest|
8
11
  guest.capability(:pyenv_install)
9
- guest.capability(:pyenv_install_python, @config[:version])
12
+ # Reverse array so that the first version specified is installed last
13
+ # and gets set as the default
14
+ @config[:versions].reverse.each do |version|
15
+ guest.capability(:pyenv_install_python, version)
16
+ end
10
17
  end
11
18
  end
12
19
  end
@@ -3,11 +3,18 @@ module VagrantPlugins
3
3
  module Platforms
4
4
  class Ruby < Platform
5
5
  def provision(machine)
6
- @config[:version] = '2.0.0' if @config[:version] == 'latest'
6
+ if @config[:versions].empty?
7
+ machine.env.ui.warn('No ruby version was specified and only rvm will be installed')
8
+ end
9
+
7
10
  machine.guest.tap do |guest|
8
11
  guest.capability(:install_packages, 'curl', silent: true)
9
12
  guest.capability(:rvm_install)
10
- guest.capability(:rvm_install_ruby, @config[:version])
13
+ # Reverse array so that the first version specified is installed last
14
+ # and gets set as the default
15
+ @config[:versions].reverse.each do |version|
16
+ guest.capability(:rvm_install_ruby, version)
17
+ end
11
18
  end
12
19
  end
13
20
  end
@@ -51,8 +51,13 @@ module VagrantPlugins
51
51
  end
52
52
 
53
53
  def create_platform_provisioner(name, config)
54
- name, version = name.to_s.split(':')
55
- config[:version] ||= (version || 'latest')
54
+ name, version = name.to_s.split('-')
55
+
56
+ if version
57
+ config[:versions] = [version]
58
+ else
59
+ config[:versions] = Array(config[:versions])
60
+ end
56
61
 
57
62
  klass = @mapping.fetch(name.to_s)
58
63
  klass.new(name, config)
@@ -1,7 +1,3 @@
1
- require "vagrant"
2
-
3
- Vagrant.require_plugin "vocker"
4
-
5
1
  require_relative "version"
6
2
 
7
3
  I18n.load_path << File.expand_path(File.dirname(__FILE__) + '/../../locales/en.yml')
@@ -1,5 +1,5 @@
1
- require "vocker/docker_client"
2
- require "vocker/docker_installer"
1
+ require Vagrant.source_root.join("plugins/provisioners/docker/client")
2
+ require Vagrant.source_root.join("plugins/provisioners/docker/installer")
3
3
 
4
4
  require_relative "errors"
5
5
  require_relative "services_builder"
@@ -12,8 +12,8 @@ module VagrantPlugins
12
12
  class Provisioner < Vagrant.plugin("2", :provisioner)
13
13
  def initialize(machine, config, installer = nil, client = nil)
14
14
  super(machine, config)
15
- @installer = installer || Vocker::DockerInstaller.new(@machine, config.docker_version)
16
- @client = client || Vocker::DockerClient.new(@machine)
15
+ @installer = installer || Docker::Installer.new(@machine, config.docker_version)
16
+ @client = client || Docker::Client.new(@machine)
17
17
  end
18
18
 
19
19
  def provision
@@ -46,8 +46,13 @@ module VagrantPlugins
46
46
  @machine.guest.capability(:ventriloquist_containers_upstart)
47
47
  end
48
48
 
49
+ if @machine.provider_name == :lxc && @machine.guest.capability?(:prepare_container_for_docker)
50
+ @logger.info("vagrant-lxc container detected, will install lxc and tweak Docker settings")
51
+ @machine.guest.capability(:prepare_container_for_docker)
52
+ end
53
+
49
54
  unless @client.daemon_running?
50
- raise Vocker::Errors::DockerNotRunning
55
+ raise 'Docker client is not running'
51
56
  end
52
57
 
53
58
  ServicesBuilder.build(config.services, @client).each do |service|
@@ -17,11 +17,10 @@ module VagrantPlugins
17
17
  else
18
18
  machine.env.ui.info("Starting '#{@name}' service")
19
19
  machine.communicate.sudo("mkdir -p #{CONTAINER_IDS_PATH}")
20
- # Reduce network latency, see https://groups.google.com/d/msg/docker-user/Z3zQuRawIsE/2AEkl30WpTQJ
21
- # for more info
22
- @config[:dns] = '127.0.0.1'
23
- @config[:name] = @name
24
- @config[:cidfile] = cidfile
20
+ @config[:cidfile] = cidfile
21
+ @config[:daemonize] = true
22
+ @config[:name] = @name
23
+ @config[:auto_assign_name] = true
25
24
  @docker_client.run_container(@config)
26
25
  end
27
26
  end