ventriloquist 0.0.1 → 0.1.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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.rspec +2 -0
  4. data/CHANGELOG.md +3 -0
  5. data/Gemfile +16 -0
  6. data/Gemfile.lock +118 -0
  7. data/Guardfile +5 -0
  8. data/LICENSE.txt +1 -1
  9. data/README.md +191 -9
  10. data/Rakefile +2 -0
  11. data/development/Vagrantfile +50 -0
  12. data/lib/ventriloquist/cap/debian/git_install.rb +18 -0
  13. data/lib/ventriloquist/cap/debian/go_install.rb +34 -0
  14. data/lib/ventriloquist/cap/debian/install_build_tools.rb +18 -0
  15. data/lib/ventriloquist/cap/debian/mercurial_install.rb +18 -0
  16. data/lib/ventriloquist/cap/debian/mysql_install_client.rb +18 -0
  17. data/lib/ventriloquist/cap/debian/mysql_install_headers.rb +18 -0
  18. data/lib/ventriloquist/cap/debian/nodejs_install.rb +21 -0
  19. data/lib/ventriloquist/cap/debian/pg_install_client.rb +18 -0
  20. data/lib/ventriloquist/cap/debian/pg_install_headers.rb +18 -0
  21. data/lib/ventriloquist/cap/debian/phantomjs_install.rb +24 -0
  22. data/lib/ventriloquist/cap/debian/ventriloquist_containers_upstart.rb +33 -0
  23. data/lib/ventriloquist/cap/linux/download.rb +26 -0
  24. data/lib/ventriloquist/cap/linux/make.rb +14 -0
  25. data/lib/ventriloquist/cap/linux/mysql_configure_client.rb +18 -0
  26. data/lib/ventriloquist/cap/linux/pg_export_pghost.rb +18 -0
  27. data/lib/ventriloquist/cap/linux/rvm_install.rb +17 -0
  28. data/lib/ventriloquist/cap/linux/rvm_install_ruby.rb +18 -0
  29. data/lib/ventriloquist/cap/linux/untar.rb +14 -0
  30. data/lib/ventriloquist/config.rb +12 -0
  31. data/lib/ventriloquist/errors.rb +8 -0
  32. data/lib/ventriloquist/platform.rb +11 -0
  33. data/lib/ventriloquist/platforms/go.rb +13 -0
  34. data/lib/ventriloquist/platforms/nodejs.rb +11 -0
  35. data/lib/ventriloquist/platforms/phantomjs.rb +12 -0
  36. data/lib/ventriloquist/platforms/ruby.rb +15 -0
  37. data/lib/ventriloquist/platforms_builder.rb +56 -0
  38. data/lib/ventriloquist/plugin.rb +119 -0
  39. data/lib/ventriloquist/provisioner.rb +59 -0
  40. data/lib/ventriloquist/service.rb +23 -0
  41. data/lib/ventriloquist/services/mysql.rb +39 -0
  42. data/lib/ventriloquist/services/postgresql.rb +39 -0
  43. data/lib/ventriloquist/services/redis.rb +31 -0
  44. data/lib/ventriloquist/services_builder.rb +66 -0
  45. data/lib/ventriloquist/version.rb +4 -2
  46. data/lib/ventriloquist.rb +1 -5
  47. data/locales/en.yml +1 -0
  48. data/services/base/Dockerfile +15 -0
  49. data/services/build-all.sh +20 -0
  50. data/services/elasticsearch/Dockerfile +12 -0
  51. data/services/memcached/Dockerfile +17 -0
  52. data/services/mysql/Dockerfile +20 -0
  53. data/services/mysql/config/bin/add-mysql-user +19 -0
  54. data/services/openjdk7/Dockerfile +9 -0
  55. data/services/postgresql/9.1/Dockerfile +20 -0
  56. data/services/postgresql/9.1/config/bin/prepare-postgres +27 -0
  57. data/services/postgresql/9.1/config/bin/start-postgres +6 -0
  58. data/services/postgresql/9.1/config/etc/postgresql/9.1/main/pg_hba.conf +3 -0
  59. data/services/postgresql/9.2/Dockerfile +15 -0
  60. data/services/postgresql/9.2/config/bin/prepare-postgres +25 -0
  61. data/services/postgresql/9.2/config/bin/start-postgres +6 -0
  62. data/services/postgresql/9.2/config/etc/postgresql/9.2/main/postgresql.conf +573 -0
  63. data/services/redis/Dockerfile +11 -0
  64. data/spec/spec_helper.rb +26 -0
  65. data/spec/unit/platforms_builder_spec.rb +50 -0
  66. data/spec/unit/service_spec.rb +38 -0
  67. data/spec/unit/services_builder_spec.rb +54 -0
  68. data/tasks/spec.rake +9 -0
  69. data/ventriloquist.gemspec +16 -13
  70. metadata +88 -9
@@ -0,0 +1,66 @@
1
+ require_relative 'service'
2
+ require_relative 'services/postgresql'
3
+ require_relative 'services/redis'
4
+ require_relative 'services/mysql'
5
+
6
+ module VagrantPlugins
7
+ module Ventriloquist
8
+ class ServicesBuilder
9
+ MAPPING = {
10
+ 'pg' => Services::PostgreSQL,
11
+ 'mysql' => Services::MySql,
12
+ 'redis' => Services::Redis
13
+ }
14
+
15
+ def initialize(services, mapping = MAPPING)
16
+ @services = services.flatten
17
+ @mapping = mapping
18
+ end
19
+
20
+ def self.build(services, docker_client)
21
+ new(services).build(docker_client)
22
+ end
23
+
24
+ def build(docker_client)
25
+ @services.each_with_object([]) do |cfg, built_services|
26
+ case cfg
27
+ when Hash
28
+ built_services.concat build_services(cfg, docker_client)
29
+ when String, Symbol
30
+ built_services << create_service_provisioner(cfg, {}, docker_client)
31
+ else
32
+ raise "Unknown cfg type: #{cfg.class}"
33
+ end
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def build_services(cfg_hash, docker_client)
40
+ cfg_hash.map do |name, config|
41
+ create_service_provisioner(name, config, docker_client)
42
+ end
43
+ end
44
+
45
+ def create_service_provisioner(name, config, docker_client)
46
+ name, tag = name.to_s.split(':')
47
+
48
+ # REFACTOR: This is a bit confusing...
49
+ config[:tag] ||= (tag || 'latest')
50
+ config[:image] ||= extract_image_name(name)
51
+ config[:image] << ":#{config[:tag]}"
52
+
53
+ klass = @mapping.fetch(name, Service)
54
+ klass.new(name, config, docker_client)
55
+ end
56
+
57
+ def extract_image_name(name)
58
+ if name =~ /(\w+\/\w+)/
59
+ $1
60
+ else
61
+ "fgrehm/ventriloquist-#{name}"
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -1,3 +1,5 @@
1
- module Ventriloquist
2
- VERSION = "0.0.1"
1
+ module VagrantPlugins
2
+ module Ventriloquist
3
+ VERSION = "0.1.0"
4
+ end
3
5
  end
data/lib/ventriloquist.rb CHANGED
@@ -1,5 +1 @@
1
- require "ventriloquist/version"
2
-
3
- module Ventriloquist
4
- # Your code goes here...
5
- end
1
+ require "ventriloquist/plugin"
data/locales/en.yml ADDED
@@ -0,0 +1 @@
1
+ vagrant:
@@ -0,0 +1,15 @@
1
+ # Base image for creating Ventriloquist services
2
+ #
3
+ # VERSION 0.0.1
4
+
5
+ FROM ubuntu:quantal
6
+ MAINTAINER Fabio Rehm "fgrehm@gmail.com"
7
+
8
+ ENV LC_ALL C
9
+ ENV DEBIAN_FRONTEND noninteractive
10
+
11
+ RUN echo "deb http://archive.ubuntu.com/ubuntu quantal main universe" > /etc/apt/sources.list
12
+ RUN apt-get update && apt-get -y upgrade && apt-get clean
13
+
14
+ RUN apt-get install -y wget curl vim language-pack-en build-essential software-properties-common && apt-get autoremove && apt-get clean
15
+ RUN locale-gen en_US && echo 'LANG="en_US.UTF-8"' >> /etc/default/locale
@@ -0,0 +1,20 @@
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ PREFIX='fgrehm/ventriloquist'
6
+
7
+ docker build -t ${PREFIX}-base base
8
+
9
+ docker build -t ${PREFIX}-pg:latest postgresql/9.2
10
+ docker tag ${PREFIX}-pg:latest ${PREFIX}-pg 9.2
11
+ docker build -t ${PREFIX}-pg:9.1 postgresql/9.1
12
+
13
+ docker build -t ${PREFIX}-mysql mysql
14
+
15
+ docker build -t ${PREFIX}-openjdk7 openjdk7
16
+ docker build -t ${PREFIX}-elasticsearch elasticsearch
17
+
18
+ docker build -t ${PREFIX}-memcached memcached
19
+
20
+ docker build -t ${PREFIX}-redis redis
@@ -0,0 +1,12 @@
1
+ # Elasticsearch 0.90.3
2
+ #
3
+ # VERSION 0.0.1
4
+
5
+ FROM fgrehm/ventriloquist-openjdk7
6
+ MAINTAINER Fabio Rehm "fgrehm@gmail.com"
7
+
8
+ ADD . /
9
+ RUN /tmp/install-elasticsearch.sh && rm /tmp/install-elasticsearch.sh
10
+
11
+ EXPOSE 9200:9200
12
+ CMD ["/usr/share/elasticsearch/bin/elasticsearch", "-f"]
@@ -0,0 +1,17 @@
1
+ # Memcached
2
+ #
3
+ # VERSION 0.0.1
4
+
5
+ FROM fgrehm/ventriloquist-base
6
+ MAINTAINER Fabio Rehm "fgrehm@gmail.com"
7
+
8
+ # prevent apt from starting postgres right after the installation
9
+ RUN echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d; chmod +x /usr/sbin/policy-rc.d
10
+
11
+ RUN apt-get install -y -q memcached && apt-get clean
12
+
13
+ # allow autostart again
14
+ RUN rm /usr/sbin/policy-rc.d
15
+
16
+ EXPOSE 11211:11211
17
+ CMD ["/usr/bin/memcached", "-u", "daemon"]
@@ -0,0 +1,20 @@
1
+ # MySQL 5.5
2
+ #
3
+ # VERSION 0.0.1
4
+
5
+ FROM fgrehm/ventriloquist-base
6
+ MAINTAINER Fabio Rehm "fgrehm@gmail.com"
7
+
8
+ # prevent apt from starting mysql right after the installation
9
+ RUN echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d; chmod +x /usr/sbin/policy-rc.d
10
+
11
+ RUN apt-get -q -y install mysql-server-5.5 && apt-get clean
12
+
13
+ # allow autostart again
14
+ RUN rm /usr/sbin/policy-rc.d
15
+
16
+ ADD config /
17
+ RUN /bin/add-mysql-user vagrant vagrant
18
+
19
+ EXPOSE 3306:3306
20
+ CMD ["/usr/sbin/mysqld"]
@@ -0,0 +1,19 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ user=$1
6
+ password=$2
7
+
8
+ user='vagrant'
9
+ password='vagrant'
10
+
11
+ sed -i 's/127.0.0.1/0.0.0.0/' /etc/mysql/my.cnf
12
+
13
+ mysqld& sleep 3
14
+
15
+ mysqladmin -u root password $password
16
+
17
+ echo "create user '${user}'@'%' identified by '${password}'" | mysql -u root -p$password
18
+ echo "grant all on *.* to '${user}'@'%' with grant option" | mysql -u root -p$password
19
+ echo "FLUSH PRIVILEGES;" | mysql -uroot -p${password}
@@ -0,0 +1,9 @@
1
+ # Elasticsearch
2
+ # PostgreSQL 9.1 and 9.2
3
+ #
4
+ # VERSION 0.0.1
5
+
6
+ FROM fgrehm/ventriloquist-base
7
+ MAINTAINER Fabio Rehm "fgrehm@gmail.com"
8
+
9
+ RUN apt-get install -y openjdk-7-jre-headless && apt-get clean
@@ -0,0 +1,20 @@
1
+ # PostgreSQL 9.1
2
+ #
3
+ # VERSION 0.0.1
4
+
5
+ FROM fgrehm/ventriloquist-base
6
+ MAINTAINER Fabio Rehm "fgrehm@gmail.com"
7
+
8
+ # prevent apt from starting postgres right after the installation
9
+ RUN echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d; chmod +x /usr/sbin/policy-rc.d
10
+
11
+ RUN apt-get install -y -q postgresql-9.1 postgresql-contrib-9.1 && apt-get clean
12
+
13
+ # allow autostart again
14
+ RUN rm /usr/sbin/policy-rc.d
15
+
16
+ ADD config /
17
+ RUN /bin/prepare-postgres vagrant vagrant
18
+
19
+ EXPOSE 5432:5432
20
+ CMD ["/bin/start-postgres"]
@@ -0,0 +1,27 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ user=$1
6
+ password=$2
7
+
8
+ /etc/init.d/postgresql start
9
+
10
+ su postgres -c "createuser --superuser ${user}"
11
+ su postgres -c "createdb ${user}"
12
+ su postgres -c "psql -c \"ALTER ROLE ${user} PASSWORD '${password}'\""
13
+
14
+ # Based on https://gist.github.com/ffmike/877447
15
+ su postgres -c "psql postgres -c \"update pg_database set datallowconn = TRUE where datname = 'template0';\""
16
+ su postgres -c "psql template0 -c \"update pg_database set datistemplate = FALSE where datname = 'template1';\""
17
+ su postgres -c "psql template0 -c \"drop database template1;\""
18
+ su postgres -c "psql template0 -c \"create database template1 with template = template0 encoding = 'UTF8';\""
19
+ su postgres -c "psql template0 -c \"update pg_database set datistemplate = TRUE where datname = 'template1';\""
20
+ su postgres -c "psql template1 -c \"update pg_database set datallowconn = FALSE where datname = 'template0';\""
21
+
22
+ /etc/init.d/postgresql stop
23
+
24
+ # Avoid password for local connections
25
+ echo 'host all all all trust' >> /etc/postgresql/9.1/main/pg_hba.conf
26
+ # Allow connections from any IP
27
+ echo "listen_addresses='*'" >> /etc/postgresql/9.1/main/postgresql.conf
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ /etc/init.d/postgresql start
6
+ tail -f /var/log/postgresql/postgresql-9.1-main.log
@@ -0,0 +1,3 @@
1
+ local all postgres peer
2
+ local all all peer
3
+ host all all all trust
@@ -0,0 +1,15 @@
1
+ # PostgreSQL 9.2
2
+ #
3
+ # VERSION 0.0.1
4
+
5
+ FROM fgrehm/ventriloquist-base
6
+ MAINTAINER Fabio Rehm "fgrehm@gmail.com"
7
+
8
+ RUN add-apt-repository ppa:pitti/postgresql && apt-get update
9
+ RUN apt-get install -y postgresql-9.2 postgresql-contrib-9.2 && apt-get clean
10
+
11
+ ADD config /
12
+ RUN /bin/prepare-postgres vagrant vagrant
13
+
14
+ EXPOSE 5432:5432
15
+ CMD ["/bin/start-postgres"]
@@ -0,0 +1,25 @@
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ user=$1
6
+ password=$2
7
+
8
+ /etc/init.d/postgresql start
9
+
10
+ su postgres -c "createuser --superuser ${user}"
11
+ su postgres -c "createdb ${user}"
12
+ su postgres -c "psql -c \"ALTER ROLE ${user} PASSWORD '${password}'\""
13
+
14
+ # Based on https://gist.github.com/ffmike/877447
15
+ su postgres -c "psql postgres -c \"update pg_database set datallowconn = TRUE where datname = 'template0';\""
16
+ su postgres -c "psql template0 -c \"update pg_database set datistemplate = FALSE where datname = 'template1';\""
17
+ su postgres -c "psql template0 -c \"drop database template1;\""
18
+ su postgres -c "psql template0 -c \"create database template1 with template = template0 encoding = 'UTF8';\""
19
+ su postgres -c "psql template0 -c \"update pg_database set datistemplate = TRUE where datname = 'template1';\""
20
+ su postgres -c "psql template1 -c \"update pg_database set datallowconn = FALSE where datname = 'template0';\""
21
+
22
+ /etc/init.d/postgresql stop
23
+
24
+ # Avoid password for local connections
25
+ echo 'host all all all trust' >> /etc/postgresql/9.2/main/pg_hba.conf
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ /etc/init.d/postgresql start
6
+ tail -f /var/log/postgresql/postgresql-9.2-main.log