linux_provision 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.linux_provision.json +3 -3
  3. data/CHANGES +4 -0
  4. data/Gemfile +8 -5
  5. data/Gemfile.lock +57 -9
  6. data/README.md +129 -35
  7. data/Vagrantfile +1 -1
  8. data/demo/.ruby-gemset +1 -0
  9. data/demo/.ruby-version +1 -0
  10. data/demo/Dockerfile +107 -0
  11. data/demo/Gemfile +7 -0
  12. data/demo/Gemfile.lock +45 -0
  13. data/demo/Rakefile +7 -0
  14. data/demo/app.rb +29 -0
  15. data/demo/bin/start-server.sh +7 -0
  16. data/demo/config.ru +3 -0
  17. data/demo/db/migrate/20140610203958_create_notes.rb +14 -0
  18. data/demo/db/migrate/20140610204302_add_notes.rb +7 -0
  19. data/demo/db/schema.rb +26 -0
  20. data/demo/db_setup.rb +11 -0
  21. data/demo/note.rb +2 -0
  22. data/demo/supervisord.conf +8 -0
  23. data/demo/views/index.erb +10 -0
  24. data/demo/views/layout.erb +8 -0
  25. data/demo/views/new.erb +12 -0
  26. data/demo/views/note.erb +3 -0
  27. data/docker/postgres/Dockerfile +61 -0
  28. data/docker/postgres/bin/create_db.sh +14 -0
  29. data/docker/sshd/Dockerfile +28 -0
  30. data/docker/supervisord/Dockerfile +28 -0
  31. data/docker/supervisord/supervisord.conf +8 -0
  32. data/lib/linux_provision/generic_provision.rb +28 -19
  33. data/lib/linux_provision/linux_provision.rb +7 -165
  34. data/lib/linux_provision/linux_provision_scripts.sh +65 -21
  35. data/lib/linux_provision/version.rb +1 -1
  36. data/presentation/virtualization/01-vagrant/slides.md +381 -0
  37. data/presentation/virtualization/02-provision/slides.md +400 -0
  38. data/presentation/virtualization/03-docker/slides.md +208 -0
  39. data/presentation/virtualization/04-conclusion/slides.md +36 -0
  40. data/presentation/virtualization/default.css +59 -0
  41. data/presentation/virtualization/default.tpl +2 -0
  42. data/presentation/virtualization/images/chef.jpg +0 -0
  43. data/presentation/virtualization/images/provisioning.jpg +0 -0
  44. data/presentation/virtualization/images/vagrant.jpg +0 -0
  45. data/presentation/virtualization/showoff.json +23 -0
  46. data/presentation/virtualization/simple.tpl +2 -0
  47. data/spec/linux_install_spec.rb +9 -2
  48. data/spec/linux_provision_spec.rb +1 -1
  49. data/stats/viewstats.json +1 -0
  50. data/thor/demo_scripts.sh +34 -0
  51. data/thor/docker.thor +31 -0
  52. data/thor/linux_install.thor +17 -115
  53. metadata +40 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ff91444c7d329e18ee5a392b2cea7149ee16ff8
4
- data.tar.gz: 18c581b611e851e32a8941744260f82675322393
3
+ metadata.gz: 67bdabcb3c624c52ba16480c542f22f787e99cdf
4
+ data.tar.gz: 18653423057d716c0a9d05c47439d070c7c46e17
5
5
  SHA512:
6
- metadata.gz: 747fed3e82209941373434be1bcb3d06132b4bdde7ef147b64cbe07f7b51617aa4695ce61876bfdf42a975042da6abc5d26196b6e33831c07194c20373ba9e7f
7
- data.tar.gz: 814473a3e83745ec764cf89d640c404c4c992aabdfbc5c74f25dbfd7f7e5470d7a35c2a15f4a1a6feee9406c08ccc62b74c282a3d6674b3c0724dbfedf4149e0
6
+ metadata.gz: 6f861f304edfff539a0043511a30b1e38a033d82df1d00174d4e68e11aac9eee41121ed6f3be0eb5747e126df7494eb64b00985fcc0f610aa680dcfc5b51190f
7
+ data.tar.gz: a393c7b4d03c02ca0d096e19a4db96c6cbb4c3739713bff428a9b45d4bafe541e6183846845b63df36fffec276e41dd2283d2ea577737f7f5b9ccf48021cb51e
@@ -9,20 +9,20 @@
9
9
  },
10
10
 
11
11
  "project": {
12
- "home": "#{node.home}/linux_provision",
12
+ "home": "#{node.home}/linux_provision/demo",
13
13
  "ruby_version": "1.9.3",
14
14
  "gemset": "linux_provision"
15
15
  },
16
16
 
17
17
  "postgres": {
18
18
  "hostname": "localhost", "user": "postgres", "password": "postgres",
19
- "app_user": "ruby_dev",
19
+ "app_user": "ruby_dev", "app_password": "ruby_dev",
20
20
  "app_schemas": ["ruby_dev_test", "ruby_dev_dev", "ruby_dev_prod"]
21
21
  },
22
22
 
23
23
  "mysql": {
24
24
  "hostname": "localhost", "user": "root", "password": "root",
25
- "app_user": "ruby_dev",
25
+ "app_user": "ruby_dev", "app_password": "ruby_dev",
26
26
  "app_schemas": ["ruby_dev_test", "ruby_dev_dev", "ruby_dev_prod"]
27
27
  }
28
28
 
data/CHANGES CHANGED
@@ -14,4 +14,8 @@
14
14
 
15
15
  == Version 0.9.3
16
16
 
17
+ * Bug fix.
18
+
19
+ == Version 0.9.4
20
+
17
21
  * Bug fix.
data/Gemfile CHANGED
@@ -14,13 +14,16 @@ end
14
14
 
15
15
  group :test do
16
16
  gem "rspec"
17
- gem "mocha"
18
17
  end
19
18
 
20
- # group :debug do
21
- # gem "ruby-debug-base19x", "0.11.30.pre15"
22
- # gem "ruby-debug-ide", "0.4.23.beta1"
23
- # end
19
+ group :debug do
20
+ gem "ruby-debug-base19x", "0.11.30.pre15"
21
+ gem "ruby-debug-ide", "0.4.23.beta1"
22
+ end
23
+
24
+ group "presentation" do
25
+ gem "showoff"
26
+ end
24
27
 
25
28
 
26
29
 
data/Gemfile.lock CHANGED
@@ -1,36 +1,82 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
+ addressable (2.3.6)
5
+ blankslate (2.1.2.4)
6
+ daemons (1.1.9)
7
+ debugger-ruby_core_source (1.3.5)
4
8
  diff-lcs (1.2.5)
9
+ em-websocket (0.3.8)
10
+ addressable (>= 2.1.1)
11
+ eventmachine (>= 0.12.9)
12
+ eventmachine (1.0.3)
5
13
  file_utils (1.0.7)
6
14
  gemcutter (0.7.1)
7
15
  gemspec_deps_gen (1.1.2)
8
16
  bundler
9
17
  file_utils
18
+ gli (2.11.0)
10
19
  highline (1.6.21)
20
+ htmlentities (4.3.2)
21
+ json (1.8.1)
11
22
  json_pure (1.8.1)
12
- metaclass (0.0.4)
13
- mocha (1.1.0)
14
- metaclass (~> 0.0.1)
23
+ mini_portile (0.6.0)
15
24
  net-ssh (2.9.1)
25
+ nokogiri (1.6.2.1)
26
+ mini_portile (= 0.6.0)
27
+ parslet (1.6.1)
28
+ blankslate (~> 2.0)
29
+ rack (1.5.2)
30
+ rack-protection (1.5.3)
31
+ rack
32
+ rake (10.3.2)
33
+ redcarpet (3.1.2)
16
34
  rspec (3.0.0)
17
35
  rspec-core (~> 3.0.0)
18
36
  rspec-expectations (~> 3.0.0)
19
37
  rspec-mocks (~> 3.0.0)
20
- rspec-core (3.0.0)
38
+ rspec-core (3.0.2)
21
39
  rspec-support (~> 3.0.0)
22
- rspec-expectations (3.0.0)
40
+ rspec-expectations (3.0.2)
23
41
  diff-lcs (>= 1.2.0, < 2.0)
24
42
  rspec-support (~> 3.0.0)
25
- rspec-mocks (3.0.1)
43
+ rspec-mocks (3.0.2)
26
44
  rspec-support (~> 3.0.0)
27
- rspec-support (3.0.0)
45
+ rspec-support (3.0.2)
46
+ ruby-debug-base19x (0.11.30.pre15)
47
+ debugger-ruby_core_source (> 0)
48
+ rake (>= 0.8.1)
49
+ ruby-debug-ide (0.4.23.beta1)
50
+ rake (>= 0.8.1)
28
51
  script_executor (1.4.2)
29
52
  highline (~> 1.6)
30
53
  net-ssh (~> 2.8)
31
54
  text-interpolator (~> 1.0)
32
- text-interpolator (1.1.4)
55
+ showoff (0.9.8.1)
56
+ gli (>= 1.3.2)
57
+ htmlentities
58
+ json
59
+ nokogiri
60
+ parslet
61
+ redcarpet
62
+ sinatra (~> 1.3)
63
+ sinatra-websocket
64
+ thin (~> 1.3)
65
+ sinatra (1.4.5)
66
+ rack (~> 1.4)
67
+ rack-protection (~> 1.4)
68
+ tilt (~> 1.3, >= 1.3.4)
69
+ sinatra-websocket (0.3.0)
70
+ em-websocket (~> 0.3.6)
71
+ eventmachine
72
+ thin (>= 1.3.1)
73
+ text-interpolator (1.1.5)
74
+ thin (1.6.2)
75
+ daemons (>= 1.0.9)
76
+ eventmachine (>= 1.0.0)
77
+ rack (>= 1.0.0)
33
78
  thor (0.19.1)
79
+ tilt (1.4.1)
34
80
 
35
81
  PLATFORMS
36
82
  ruby
@@ -39,8 +85,10 @@ DEPENDENCIES
39
85
  gemcutter (~> 0.7)
40
86
  gemspec_deps_gen (~> 1.1)
41
87
  json_pure (~> 1.8)
42
- mocha
43
88
  rspec
89
+ ruby-debug-base19x (= 0.11.30.pre15)
90
+ ruby-debug-ide (= 0.4.23.beta1)
44
91
  script_executor (~> 1.4)
92
+ showoff
45
93
  text-interpolator (~> 1.0)
46
94
  thor (~> 0.19)
data/README.md CHANGED
@@ -1,38 +1,132 @@
1
1
  # Linux Provision
2
2
 
3
- Library and thor tasks for provisioning of Linux computer initial setup for Ruby/Rails development
4
-
5
-
6
- # $ vagrant box add precise64 http://files.vagrantup.com/precise64.box
7
- # $ vagrant init precise64
8
- # $ vagrant up
9
- # $ vagrant reload
10
- # $ vagrant provision
11
- # $ vagrant suspend
12
- # $ vagrant halt
13
- # $ vagrant destroy
14
- # $ vagrant box remove precise64
15
- #
16
- # $ vagrant ssh
17
- # $ ssh vagrant@127.0.0.1 -p 2222
18
-
19
- # ```bash
20
- # vagrant ssh
21
- #
22
- # cd /vagrant
23
- #
24
- # rake db:dev:reset
25
- #
26
- # rspec
27
- #
28
- # ASSET_HOST=http://22.22.22.22:3000 rails s
29
- # ```
30
- #
31
- # * and then access it from the browser within [host computer](http://22.22.22.22:3000/app):
32
- #
33
- # ```
34
- # open http://22.22.22.22:3000/app
35
- # ```
36
-
37
- # $ vagrant package --vagrantfile Vagrantfile --output linux_provision.box
3
+ ## Library and thor tasks for provisioning of Linux computer initial setup for Ruby/Rails development
38
4
 
5
+ ```bash
6
+ vagrant box add precise64 http://files.vagrantup.com/precise64.box
7
+ vagrant init precise64
8
+
9
+ vagrant up
10
+ vagrant reload
11
+ vagrant provision
12
+
13
+ vagrant suspend
14
+ vagrant halt
15
+ vagrant destroy
16
+ vagrant box remove precise64
17
+
18
+ vagrant ssh
19
+
20
+ ssh vagrant@127.0.0.1 -p 2222
21
+
22
+ vagrant ssh
23
+
24
+ cd /vagrant
25
+
26
+ rake db:dev:reset
27
+
28
+ rspec
29
+
30
+ ASSET_HOST=http://22.22.22.22:3000 rails s
31
+ ```
32
+
33
+ and then access it from the browser within [host computer](http://22.22.22.22:3000/app):
34
+
35
+ ```bash
36
+ open http://22.22.22.22:3000/app
37
+ ```
38
+
39
+ ```bash
40
+ vagrant package --vagrantfile Vagrantfile --output linux_provision.box
41
+ ```
42
+
43
+
44
+ ## Docker
45
+
46
+
47
+ docker is an open-source project that makes creating and managing Linux containers really easy.
48
+ Containers are like extremely lightweight VMs – they allow code to run in isolation from other containers
49
+ but safely share the machine’s resources, all without the overhead of a hypervisor.
50
+
51
+ docker containers can boot extremely fast (in milliseconds!) which gives you unprecedented flexibility
52
+ in managing load across your cluster. For example, instead of running chef on each of your VMs,
53
+ it’s faster and more reliable to have your build system create a container and launch it on
54
+ the appropriate number of CoreOS hosts. When these containers start, they can signal your proxy (via etcd)
55
+ to start sending them traffic.
56
+
57
+
58
+ ## Installation
59
+
60
+ * Download and install VirtualBox for OSX
61
+
62
+ https://www.virtualbox.org/wiki/Downloads
63
+
64
+ * Install boot2docker and docker via homebrew:
65
+
66
+ ```bash
67
+ brew install boot2docker
68
+ ```
69
+ Docker will be installed as an dependency.
70
+
71
+ Initialize boot2docker virtual machine:
72
+
73
+ ```bash
74
+ boot2docker init
75
+ ```
76
+
77
+ Update .bash_profile file:
78
+
79
+
80
+ ```bash
81
+ export DOCKER_HOST=tcp://127.0.0.1:4243
82
+ ```
83
+
84
+ Start the docker daemon:
85
+
86
+ ```bash
87
+ boot2docker up
88
+ ```
89
+
90
+ or down:
91
+
92
+ ```bash
93
+ boot2docker down
94
+ ```
95
+
96
+ ssh it:
97
+
98
+ ```bash
99
+ boot2docker ssh
100
+
101
+ # User: docker
102
+ # Pwd: tcuser
103
+ ```
104
+
105
+ Download the small base image named busybox:
106
+
107
+ ```bash
108
+ docker pull busybox
109
+ docker pull ubuntu
110
+ docker pull centos
111
+ ```
112
+
113
+ Run and test as separate command:
114
+
115
+ ```bash
116
+ docker run -t -i ubuntu /bin/bash
117
+ ```
118
+
119
+ and interactively:
120
+
121
+
122
+ ```bash
123
+ docker run -t -i ubuntu /bin/bash
124
+ ```
125
+
126
+ ```bash
127
+ docker build -t demo docker/demo
128
+ ```
129
+
130
+ ```bash
131
+ docker run -p 49160:8080 -d busybox
132
+ ```
data/Vagrantfile CHANGED
@@ -44,7 +44,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
44
44
  # within the machine from a port on the host machine. In the example below,
45
45
  # accessing "localhost:8080" will access port 80 on the guest machine.
46
46
  # config.vm.network "forwarded_port", guest: 80, host: 8080
47
- config.vm.network "forwarded_port", guest: 3001, host: 3000
47
+ config.vm.network "forwarded_port", host: 9292, guest: 9292
48
48
 
49
49
  # Create a private network, which allows host-only access to the machine
50
50
  # using a specific IP.
data/demo/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ linux_provision_demo
@@ -0,0 +1 @@
1
+ ruby-1.9.3
data/demo/Dockerfile ADDED
@@ -0,0 +1,107 @@
1
+ FROM ubuntu:14.04
2
+
3
+ MAINTAINER Alexander Shvets "alexander.shvets@gmail.com"
4
+
5
+ # 1. Install general packages
6
+
7
+ RUN apt-get update
8
+
9
+ RUN apt-get install -y curl
10
+ RUN apt-get install -y g++
11
+ RUN apt-get install -y git
12
+ RUN apt-get -y -q install libpq-dev
13
+
14
+ # for rvm
15
+ RUN apt-get -y -q install gawk make libreadline6-dev libyaml-dev libsqlite3-dev sqlite3
16
+ RUN apt-get -y -q install autoconf libgdbm-dev libncurses5-dev automake libtool bison pkg-config libffi-dev
17
+
18
+ # 3. Install postgres
19
+
20
+ #RUN apt-get -y -q install postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
21
+
22
+ #USER postgres
23
+
24
+ #ADD bin/create_db.sh /src/
25
+ #RUN /src/create_db.sh
26
+
27
+ # Adjust PostgreSQL configuration so that remote connections to the
28
+ # database are possible.
29
+ #RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf
30
+
31
+ # And add ``listen_addresses`` to ``/etc/postgresql/9.3/main/postgresql.conf``
32
+ #RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf
33
+
34
+ # Expose the PostgreSQL port
35
+ #EXPOSE 5432
36
+
37
+ # Add VOLUMEs to allow backup of config, logs and databases
38
+ #VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
39
+
40
+ # Set the default command to run when starting the container
41
+ #CMD ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/var/lib/postgresql/9.3/main", "-c", "config_file=/etc/postgresql/9.3/main/postgresql.conf"]
42
+
43
+ #USER root
44
+
45
+ # 3. Install rvm & ruby
46
+
47
+ RUN curl -L https://get.rvm.io | bash
48
+
49
+ RUN /bin/bash -l -c "source /etc/profile.d/rvm.sh && rvm install ruby-1.9.3"
50
+
51
+ # 4. Install project
52
+
53
+ # Trick: make bundle command cashable
54
+
55
+ WORKDIR /tmp
56
+ ADD ./Gemfile Gemfile
57
+ ADD ./Gemfile.lock Gemfile.lock
58
+ RUN /bin/bash -l -c "rvm --create use 1.9.3@linux_provision_demo && bundle"
59
+
60
+ # Add project dir to docker
61
+
62
+ ADD . /opt/demo
63
+ WORKDIR /opt/demo
64
+
65
+ # Add 'web' user which will run the application
66
+ #RUN adduser web --home /home/web --shell /bin/bash --disabled-password --gecos ""
67
+
68
+ #RUN chown -R web:web /var/www &&\
69
+ # mkdir -p /var/bundle &&\
70
+ # chown -R web:web /var/bundle
71
+ #RUN su -c "cd /var/www && bundle install --deployment --path /var/bundle" -s /bin/bash -l web
72
+ #RUN chown -R web:web /var/www
73
+ #USER web
74
+
75
+ #RUN chmod +x /opt/demo/bin/create_db.sh
76
+ #RUN /bin/bash -l -c "rvm use 1.9.3@linux_provision_demo && rake db:migrate"
77
+
78
+ # Make server port available outside
79
+ EXPOSE 9292
80
+
81
+ # Start server
82
+ #ENTRYPOINT /opt/demo/bin/start-server.sh
83
+
84
+ CMD /bin/bash -l -c "rackup"
85
+
86
+ # 2. Install sshd
87
+
88
+ #RUN apt-get install -y openssh-server supervisor
89
+
90
+ #RUN mkdir /var/run/sshd
91
+ #RUN mkdir -p /var/log/supervisor
92
+
93
+ #RUN echo 'root:screencast' | chpasswd
94
+
95
+ #EXPOSE 22
96
+
97
+ #CMD /usr/sbin/sshd -D
98
+
99
+ #ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
100
+
101
+ #CMD ["/usr/bin/supervisord"]
102
+
103
+ # boot2docker ip
104
+
105
+ # docker build -t demo demo
106
+ # docker run --rm -p 9292:9292 -e POSTGRESQL_HOST='192.168.59.104' --name demo demo /bin/bash -l -c "rake db:migrate"
107
+ # docker run --rm -p 9292:9292 -e POSTGRESQL_HOST='192.168.59.104' --name demo demo /bin/bash -l -c "rackup"