ventriloquist 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/CHANGELOG.md +47 -2
  4. data/Gemfile +2 -1
  5. data/Gemfile.lock +36 -28
  6. data/README.md +116 -41
  7. data/base_box/README.md +3 -0
  8. data/base_box/Vagrantfile +66 -0
  9. data/development/Vagrantfile +32 -11
  10. data/lib/ventriloquist/cap/platforms.rb +55 -0
  11. data/lib/ventriloquist/cap/{debian → platforms/debian}/elixir_install.rb +1 -0
  12. data/lib/ventriloquist/cap/{debian → platforms/debian}/erlang_install.rb +0 -0
  13. data/lib/ventriloquist/cap/{debian → platforms/debian}/go_install.rb +1 -1
  14. data/lib/ventriloquist/cap/{debian → platforms/debian}/phantomjs_install.rb +1 -1
  15. data/lib/ventriloquist/cap/{debian → platforms/debian}/python.rb +1 -0
  16. data/lib/ventriloquist/cap/{linux → platforms/linux}/nvm_install.rb +0 -0
  17. data/lib/ventriloquist/cap/{linux → platforms/linux}/nvm_install_nodejs.rb +0 -0
  18. data/lib/ventriloquist/cap/platforms/linux/rvm_install.rb +17 -0
  19. data/lib/ventriloquist/cap/{linux → platforms/linux}/rvm_install_ruby.rb +2 -3
  20. data/lib/ventriloquist/cap/services.rb +40 -0
  21. data/lib/ventriloquist/cap/{debian → services/debian}/mysql_install_client.rb +1 -1
  22. data/lib/ventriloquist/cap/{debian → services/debian}/mysql_install_headers.rb +1 -1
  23. data/lib/ventriloquist/cap/{debian → services/debian}/pg_install_client.rb +1 -1
  24. data/lib/ventriloquist/cap/{debian → services/debian}/pg_install_headers.rb +1 -1
  25. data/lib/ventriloquist/cap/{debian → services/debian}/ventriloquist_containers_upstart.rb +0 -0
  26. data/lib/ventriloquist/cap/{linux → services/linux}/mysql_configure_client.rb +0 -0
  27. data/lib/ventriloquist/cap/{linux → services/linux}/pg_export_pghost.rb +0 -0
  28. data/lib/ventriloquist/cap/utils.rb +40 -0
  29. data/lib/ventriloquist/cap/utils/debian/git_install.rb +13 -0
  30. data/lib/ventriloquist/cap/utils/debian/install_build_tools.rb +13 -0
  31. data/lib/ventriloquist/cap/utils/debian/install_packages.rb +47 -0
  32. data/lib/ventriloquist/cap/utils/debian/mercurial_install.rb +13 -0
  33. data/lib/ventriloquist/cap/utils/linux/download.rb +39 -0
  34. data/lib/ventriloquist/cap/{linux → utils/linux}/make.rb +0 -0
  35. data/lib/ventriloquist/cap/{linux → utils/linux}/untar.rb +0 -0
  36. data/lib/ventriloquist/config.rb +6 -3
  37. data/lib/ventriloquist/platforms/elixir.rb +1 -1
  38. data/lib/ventriloquist/platforms/go.rb +1 -1
  39. data/lib/ventriloquist/platforms/nodejs.rb +1 -0
  40. data/lib/ventriloquist/platforms/phantomjs.rb +1 -1
  41. data/lib/ventriloquist/platforms/ruby.rb +1 -0
  42. data/lib/ventriloquist/plugin.rb +3 -114
  43. data/lib/ventriloquist/provisioner.rb +12 -1
  44. data/lib/ventriloquist/service.rb +14 -7
  45. data/lib/ventriloquist/services/elastic_search.rb +12 -0
  46. data/lib/ventriloquist/services/mail_catcher.rb +12 -0
  47. data/lib/ventriloquist/services/memcached.rb +12 -0
  48. data/lib/ventriloquist/services/mysql.rb +5 -0
  49. data/lib/ventriloquist/services/postgresql.rb +5 -0
  50. data/lib/ventriloquist/services/redis.rb +12 -6
  51. data/lib/ventriloquist/services/rethink_db.rb +16 -0
  52. data/lib/ventriloquist/services_builder.rb +14 -5
  53. data/lib/ventriloquist/version.rb +1 -1
  54. data/locales/en.yml +6 -1
  55. data/services/base/Dockerfile +8 -7
  56. data/services/build-all.sh +6 -3
  57. data/services/elasticsearch/Dockerfile +6 -7
  58. data/services/mailcatcher/Dockerfile +3 -6
  59. data/services/memcached/Dockerfile +11 -12
  60. data/services/mysql/5.5/Dockerfile +17 -0
  61. data/services/mysql/{config → 5.5/config}/bin/add-mysql-user +0 -5
  62. data/services/mysql/5.6/Dockerfile +32 -0
  63. data/services/mysql/5.6/config/bin/add-mysql-user +15 -0
  64. data/services/mysql/5.6/config/etc/my.cnf +129 -0
  65. data/services/openjdk7/Dockerfile +1 -5
  66. data/services/postgresql/9.1/Dockerfile +5 -10
  67. data/services/postgresql/9.2/Dockerfile +7 -6
  68. data/services/postgresql/9.3/Dockerfile +16 -0
  69. data/services/postgresql/9.3/config/bin/prepare-postgres +25 -0
  70. data/services/postgresql/9.3/config/bin/start-postgres +6 -0
  71. data/services/postgresql/9.3/config/etc/postgresql/9.3/main/postgresql.conf +591 -0
  72. data/services/redis/Dockerfile +10 -6
  73. data/services/rethinkdb/Dockerfile +17 -0
  74. data/spec/unit/service_spec.rb +22 -12
  75. data/spec/unit/services_builder_spec.rb +26 -8
  76. data/ventriloquist.gemspec +1 -1
  77. metadata +46 -28
  78. data/lib/ventriloquist/cap/debian/git_install.rb +0 -18
  79. data/lib/ventriloquist/cap/debian/install_build_tools.rb +0 -18
  80. data/lib/ventriloquist/cap/debian/mercurial_install.rb +0 -18
  81. data/lib/ventriloquist/cap/linux/download.rb +0 -26
  82. data/lib/ventriloquist/cap/linux/rvm_install.rb +0 -17
  83. data/services/mysql/Dockerfile +0 -20
@@ -0,0 +1,13 @@
1
+ module VagrantPlugins
2
+ module Ventriloquist
3
+ module Cap
4
+ module Debian
5
+ module MercurialInstall
6
+ def self.mercurial_install(machine)
7
+ machine.guest.capability(:install_packages, 'mercurial')
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,39 @@
1
+ module VagrantPlugins
2
+ module Ventriloquist
3
+ module Cap
4
+ module Linux
5
+ module Download
6
+ def self.download(machine, src, destination)
7
+ machine.communicate.tap do |comm|
8
+ if comm.test('which wget')
9
+ download_with_wget(machine, src, destination)
10
+
11
+ elsif comm.test('which curl')
12
+ download_with_curl(machine, src, destination)
13
+
14
+ # If neither wget or curl could be found, try installing
15
+ # curl
16
+ elsif machine.capability?(:install_packages)
17
+ machine.guest.capability(:install_packages, 'curl')
18
+ download_with_curl(machine, src, destination)
19
+
20
+ else
21
+ raise 'Unable to download file for guest VM!'
22
+ end
23
+ end
24
+ end
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}")
29
+ end
30
+
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}")
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,11 +1,14 @@
1
1
  module VagrantPlugins
2
2
  module Ventriloquist
3
3
  class Config < Vagrant.plugin("2", :config)
4
- attr_reader :services, :platforms
4
+ attr_reader :services, :platforms, :packages
5
+ attr_accessor :docker_version
5
6
 
6
7
  def initialize
7
- @services = []
8
- @platforms = []
8
+ @services = []
9
+ @platforms = []
10
+ @packages = []
11
+ @docker_version = '0.7.0'
9
12
  end
10
13
  end
11
14
  end
@@ -3,7 +3,7 @@ module VagrantPlugins
3
3
  module Platforms
4
4
  class Elixir < Platform
5
5
  def provision(machine)
6
- @config[:version] = '0.10.3' if @config[:version] == 'latest'
6
+ @config[:version] = '0.11.2' if @config[:version] == 'latest'
7
7
  machine.guest.tap do |guest|
8
8
  guest.capability(:erlang_install)
9
9
  guest.capability(:elixir_install, @config[:version])
@@ -3,7 +3,7 @@ module VagrantPlugins
3
3
  module Platforms
4
4
  class Go < Platform
5
5
  def provision(machine)
6
- @config[:version] = '1.1.2' if @config[:version] == 'latest'
6
+ @config[:version] = '1.2' if @config[:version] == 'latest'
7
7
  machine.guest.capability(:mercurial_install)
8
8
  machine.guest.capability(:go_install, @config[:version])
9
9
  end
@@ -5,6 +5,7 @@ module VagrantPlugins
5
5
  def provision(machine)
6
6
  @config[:version] = '0.10' if @config[:version] == 'latest'
7
7
  machine.guest.tap do |guest|
8
+ guest.capability(:install_packages, 'curl', silent: true)
8
9
  guest.capability(:nvm_install)
9
10
  guest.capability(:nvm_install_nodejs, @config[:version])
10
11
  end
@@ -3,7 +3,7 @@ module VagrantPlugins
3
3
  module Platforms
4
4
  class PhantomJS < Platform
5
5
  def provision(machine)
6
- @config[:version] = '1.9.1' if config[:version] == 'latest'
6
+ @config[:version] = '1.9.2' if config[:version] == 'latest'
7
7
  machine.guest.capability(:phantomjs_install, @config[:version])
8
8
  end
9
9
  end
@@ -5,6 +5,7 @@ module VagrantPlugins
5
5
  def provision(machine)
6
6
  @config[:version] = '2.0.0' if @config[:version] == 'latest'
7
7
  machine.guest.tap do |guest|
8
+ guest.capability(:install_packages, 'curl', silent: true)
8
9
  guest.capability(:rvm_install)
9
10
  guest.capability(:rvm_install_ruby, @config[:version])
10
11
  end
@@ -25,120 +25,9 @@ module VagrantPlugins
25
25
  Config
26
26
  end
27
27
 
28
- guest_capability("debian", "pg_install_client") do
29
- require_relative "cap/debian/pg_install_client"
30
- Cap::Debian::PgInstallClient
31
- end
32
-
33
- guest_capability("debian", "pg_install_headers") do
34
- require_relative "cap/debian/pg_install_headers"
35
- Cap::Debian::PgInstallHeaders
36
- end
37
-
38
- guest_capability("linux", "pg_export_pghost") do
39
- require_relative "cap/linux/pg_export_pghost"
40
- Cap::Linux::PgExportPghost
41
- end
42
-
43
- guest_capability("debian", "mysql_install_client") do
44
- require_relative "cap/debian/mysql_install_client"
45
- Cap::Debian::MySqlInstallClient
46
- end
47
-
48
- guest_capability("debian", "mysql_install_headers") do
49
- require_relative "cap/debian/mysql_install_headers"
50
- Cap::Debian::MySqlInstallHeaders
51
- end
52
-
53
- guest_capability("linux", "mysql_configure_client") do
54
- require_relative "cap/linux/mysql_configure_client"
55
- Cap::Linux::MySqlConfigureClient
56
- end
57
-
58
- guest_capability("debian", "git_install") do
59
- require_relative "cap/debian/git_install"
60
- Cap::Debian::GitInstall
61
- end
62
-
63
- guest_capability("debian", "mercurial_install") do
64
- require_relative "cap/debian/mercurial_install"
65
- Cap::Debian::MercurialInstall
66
- end
67
-
68
- guest_capability("linux", "make") do
69
- require_relative "cap/linux/make"
70
- Cap::Linux::Make
71
- end
72
-
73
- guest_capability("debian", "install_build_tools") do
74
- require_relative "cap/debian/install_build_tools"
75
- Cap::Debian::InstallBuildTools
76
- end
77
-
78
- guest_capability("debian", "ventriloquist_containers_upstart") do
79
- require_relative "cap/debian/ventriloquist_containers_upstart"
80
- Cap::Debian::VentriloquistContainersUpstart
81
- end
82
-
83
- guest_capability("linux", "download") do
84
- require_relative "cap/linux/download"
85
- Cap::Linux::Download
86
- end
87
-
88
- guest_capability("linux", "untar") do
89
- require_relative "cap/linux/untar"
90
- Cap::Linux::Untar
91
- end
92
-
93
- guest_capability("linux", "nvm_install") do
94
- require_relative "cap/linux/nvm_install"
95
- Cap::Linux::NvmInstall
96
- end
97
-
98
- guest_capability("linux", "nvm_install_nodejs") do
99
- require_relative "cap/linux/nvm_install_nodejs"
100
- Cap::Linux::NvmInstallNodeJS
101
- end
102
-
103
- guest_capability("linux", "rvm_install") do
104
- require_relative "cap/linux/rvm_install"
105
- Cap::Linux::RvmInstall
106
- end
107
-
108
- guest_capability("debian", "phantomjs_install") do
109
- require_relative "cap/debian/phantomjs_install"
110
- Cap::Debian::PhantomjsInstall
111
- end
112
-
113
- guest_capability("debian", "go_install") do
114
- require_relative "cap/debian/go_install"
115
- Cap::Debian::GoInstall
116
- end
117
-
118
- guest_capability("linux", "rvm_install_ruby") do
119
- require_relative "cap/linux/rvm_install_ruby"
120
- Cap::Linux::RvmInstallRuby
121
- end
122
-
123
- guest_capability("debian", "erlang_install") do
124
- require_relative "cap/debian/erlang_install"
125
- Cap::Debian::ErlangInstall
126
- end
127
-
128
- guest_capability("debian", "elixir_install") do
129
- require_relative "cap/debian/elixir_install"
130
- Cap::Debian::ElixirInstall
131
- end
132
-
133
- guest_capability("debian", "pyenv_install") do
134
- require_relative "cap/debian/python"
135
- Cap::Debian::Python
136
- end
137
-
138
- guest_capability("debian", "pyenv_install_python") do
139
- require_relative "cap/debian/python"
140
- Cap::Debian::Python
141
- end
28
+ require_relative 'cap/platforms'
29
+ require_relative 'cap/utils'
30
+ require_relative 'cap/services'
142
31
  end
143
32
  end
144
33
  end
@@ -12,19 +12,30 @@ 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)
15
+ @installer = installer || Vocker::DockerInstaller.new(@machine, config.docker_version)
16
16
  @client = client || Vocker::DockerClient.new(@machine)
17
17
  end
18
18
 
19
19
  def provision
20
20
  @logger = Log4r::Logger.new("vagrant::provisioners::ventriloquist")
21
21
 
22
+ provision_packages
22
23
  provision_services
23
24
  provision_platforms
24
25
  end
25
26
 
26
27
  protected
27
28
 
29
+ def provision_packages
30
+ return if config.packages.empty?
31
+
32
+ if @machine.guest.capability?(:install_packages)
33
+ @machine.guest.capability(:install_packages, config.packages)
34
+ else
35
+ @machine.env.ui.warn(I18n.t 'ventriloquist.install_packages_unsupported')
36
+ end
37
+ end
38
+
28
39
  def provision_services
29
40
  return if config.services.empty?
30
41
 
@@ -10,13 +10,20 @@ module VagrantPlugins
10
10
  end
11
11
 
12
12
  def provision(machine)
13
- machine.env.ui.info("Starting #{@name} service")
14
- machine.communicate.sudo("mkdir -p #{CONTAINER_IDS_PATH}")
15
- # Reduce network latency, see https://groups.google.com/d/msg/docker-user/Z3zQuRawIsE/2AEkl30WpTQJ
16
- # for more info
17
- @config[:dns] = '127.0.0.1'
18
- @config[:cidfile] = "#{CONTAINER_IDS_PATH}/#{@name}"
19
- @docker_client.run_container(@config)
13
+ cidfile = "#{CONTAINER_IDS_PATH}/#{@name}"
14
+
15
+ if @docker_client.container_running?("$(cat #{cidfile})")
16
+ machine.env.ui.info("Service '#{@name}' already running")
17
+ else
18
+ machine.env.ui.info("Starting '#{@name}' service")
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
25
+ @docker_client.run_container(@config)
26
+ end
20
27
  end
21
28
  end
22
29
  end
@@ -0,0 +1,12 @@
1
+ module VagrantPlugins
2
+ module Ventriloquist
3
+ module Services
4
+ class ElasticSearch < Service
5
+ def initialize(*args)
6
+ super
7
+ @config[:ports] ||= ['9292:9292']
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module VagrantPlugins
2
+ module Ventriloquist
3
+ module Services
4
+ class MailCatcher < Service
5
+ def initialize(*args)
6
+ super
7
+ @config[:ports] ||= ['1025:1025', '1080:1080']
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module VagrantPlugins
2
+ module Ventriloquist
3
+ module Services
4
+ class Memcached < Service
5
+ def initialize(*args)
6
+ super
7
+ @config[:ports] ||= ['11211:11211']
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -2,6 +2,11 @@ module VagrantPlugins
2
2
  module Ventriloquist
3
3
  module Services
4
4
  class MySql < Service
5
+ def initialize(*args)
6
+ super
7
+ @config[:ports] ||= ['3306:3306']
8
+ end
9
+
5
10
  def provision(machine)
6
11
  super
7
12
 
@@ -2,6 +2,11 @@ module VagrantPlugins
2
2
  module Ventriloquist
3
3
  module Services
4
4
  class PostgreSQL < Service
5
+ def initialize(*args)
6
+ super
7
+ @config[:ports] ||= ['5432:5432']
8
+ end
9
+
5
10
  def provision(machine)
6
11
  super
7
12
 
@@ -2,6 +2,11 @@ module VagrantPlugins
2
2
  module Ventriloquist
3
3
  module Services
4
4
  class Redis < Service
5
+ def initialize(*args)
6
+ super
7
+ @config[:ports] ||= ['6379:6379']
8
+ end
9
+
5
10
  def provision(machine)
6
11
  super
7
12
  install_client(machine)
@@ -9,20 +14,21 @@ module VagrantPlugins
9
14
 
10
15
  protected
11
16
 
12
- # TODO: Use the same version as the configured service
13
17
  def install_client(machine)
14
18
  return if machine.communicate.test('which redis-cli > /dev/null')
15
19
 
20
+ redis_version = '2.8.2'
16
21
  machine.guest.tap do |guest|
17
22
  guest.capability(:install_build_tools)
18
- guest.capability(:download, 'http://download.redis.io/redis-stable.tar.gz', '/tmp/redis-stable.tar.gz')
19
- guest.capability(:untar, '/tmp/redis-stable.tar.gz', '/tmp')
20
- guest.capability(:make, '/tmp/redis-stable', 'redis-cli')
23
+ # TODO: Use the same version specified on the Vagrantfile
24
+ guest.capability(:download, "http://download.redis.io/releases/redis-#{redis_version}.tar.gz", "/tmp/redis-#{redis_version}.tar.gz")
25
+ guest.capability(:untar, "/tmp/redis-#{redis_version}.tar.gz", '/tmp')
26
+ guest.capability(:make, "/tmp/redis-#{redis_version}", 'redis-cli')
21
27
  end
22
28
 
23
29
  machine.communicate.tap do |comm|
24
- comm.sudo('cp /tmp/redis-stable/src/redis-cli /usr/local/bin')
25
- comm.execute('rm -rf /tmp/redis-stable*')
30
+ comm.sudo("cp /tmp/redis-#{redis_version}/src/redis-cli /usr/local/bin")
31
+ comm.execute('rm -rf /tmp/redis-*')
26
32
  end
27
33
  end
28
34
  end
@@ -0,0 +1,16 @@
1
+ module VagrantPlugins
2
+ module Ventriloquist
3
+ module Services
4
+ class RethinkDB < Service
5
+ def initialize(*args)
6
+ super
7
+ @config[:ports] ||= [
8
+ '28015:28015',
9
+ '29015:29015',
10
+ '8080:8080'
11
+ ]
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,15 +1,23 @@
1
1
  require_relative 'service'
2
2
  require_relative 'services/postgresql'
3
3
  require_relative 'services/redis'
4
+ require_relative 'services/mail_catcher'
5
+ require_relative 'services/memcached'
4
6
  require_relative 'services/mysql'
7
+ require_relative 'services/elastic_search'
8
+ require_relative 'services/rethink_db'
5
9
 
6
10
  module VagrantPlugins
7
11
  module Ventriloquist
8
12
  class ServicesBuilder
9
13
  MAPPING = {
10
- 'pg' => Services::PostgreSQL,
11
- 'mysql' => Services::MySql,
12
- 'redis' => Services::Redis
14
+ 'pg' => Services::PostgreSQL,
15
+ 'elasticsearch' => Services::ElasticSearch,
16
+ 'mailcatcher' => Services::MailCatcher,
17
+ 'mysql' => Services::MySql,
18
+ 'redis' => Services::Redis,
19
+ 'memcached' => Services::Memcached,
20
+ 'rethinkdb' => Services::RethinkDB,
13
21
  }
14
22
 
15
23
  def initialize(services, mapping = MAPPING)
@@ -44,13 +52,14 @@ module VagrantPlugins
44
52
 
45
53
  def create_service_provisioner(name, config, docker_client)
46
54
  name, tag = name.to_s.split(':')
55
+ type = config.delete(:type) || name
47
56
 
48
57
  # REFACTOR: This is a bit confusing...
49
58
  config[:tag] ||= (tag || 'latest')
50
- config[:image] ||= extract_image_name(name)
59
+ config[:image] ||= extract_image_name(config.delete(:vimage) || name)
51
60
  config[:image] << ":#{config[:tag]}"
52
61
 
53
- klass = @mapping.fetch(name, Service)
62
+ klass = @mapping.fetch(type, Service)
54
63
  klass.new(name, config, docker_client)
55
64
  end
56
65