linux_provision 0.9.3 → 0.9.4
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.
- checksums.yaml +4 -4
- data/.linux_provision.json +3 -3
- data/CHANGES +4 -0
- data/Gemfile +8 -5
- data/Gemfile.lock +57 -9
- data/README.md +129 -35
- data/Vagrantfile +1 -1
- data/demo/.ruby-gemset +1 -0
- data/demo/.ruby-version +1 -0
- data/demo/Dockerfile +107 -0
- data/demo/Gemfile +7 -0
- data/demo/Gemfile.lock +45 -0
- data/demo/Rakefile +7 -0
- data/demo/app.rb +29 -0
- data/demo/bin/start-server.sh +7 -0
- data/demo/config.ru +3 -0
- data/demo/db/migrate/20140610203958_create_notes.rb +14 -0
- data/demo/db/migrate/20140610204302_add_notes.rb +7 -0
- data/demo/db/schema.rb +26 -0
- data/demo/db_setup.rb +11 -0
- data/demo/note.rb +2 -0
- data/demo/supervisord.conf +8 -0
- data/demo/views/index.erb +10 -0
- data/demo/views/layout.erb +8 -0
- data/demo/views/new.erb +12 -0
- data/demo/views/note.erb +3 -0
- data/docker/postgres/Dockerfile +61 -0
- data/docker/postgres/bin/create_db.sh +14 -0
- data/docker/sshd/Dockerfile +28 -0
- data/docker/supervisord/Dockerfile +28 -0
- data/docker/supervisord/supervisord.conf +8 -0
- data/lib/linux_provision/generic_provision.rb +28 -19
- data/lib/linux_provision/linux_provision.rb +7 -165
- data/lib/linux_provision/linux_provision_scripts.sh +65 -21
- data/lib/linux_provision/version.rb +1 -1
- data/presentation/virtualization/01-vagrant/slides.md +381 -0
- data/presentation/virtualization/02-provision/slides.md +400 -0
- data/presentation/virtualization/03-docker/slides.md +208 -0
- data/presentation/virtualization/04-conclusion/slides.md +36 -0
- data/presentation/virtualization/default.css +59 -0
- data/presentation/virtualization/default.tpl +2 -0
- data/presentation/virtualization/images/chef.jpg +0 -0
- data/presentation/virtualization/images/provisioning.jpg +0 -0
- data/presentation/virtualization/images/vagrant.jpg +0 -0
- data/presentation/virtualization/showoff.json +23 -0
- data/presentation/virtualization/simple.tpl +2 -0
- data/spec/linux_install_spec.rb +9 -2
- data/spec/linux_provision_spec.rb +1 -1
- data/stats/viewstats.json +1 -0
- data/thor/demo_scripts.sh +34 -0
- data/thor/docker.thor +31 -0
- data/thor/linux_install.thor +17 -115
- metadata +40 -2
data/demo/Gemfile
ADDED
data/demo/Gemfile.lock
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activemodel (4.1.1)
|
5
|
+
activesupport (= 4.1.1)
|
6
|
+
builder (~> 3.1)
|
7
|
+
activerecord (4.1.1)
|
8
|
+
activemodel (= 4.1.1)
|
9
|
+
activesupport (= 4.1.1)
|
10
|
+
arel (~> 5.0.0)
|
11
|
+
activesupport (4.1.1)
|
12
|
+
i18n (~> 0.6, >= 0.6.9)
|
13
|
+
json (~> 1.7, >= 1.7.7)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
thread_safe (~> 0.1)
|
16
|
+
tzinfo (~> 1.1)
|
17
|
+
arel (5.0.1.20140414130214)
|
18
|
+
builder (3.2.2)
|
19
|
+
i18n (0.6.9)
|
20
|
+
json (1.8.1)
|
21
|
+
minitest (5.3.4)
|
22
|
+
pg (0.17.1)
|
23
|
+
rack (1.5.2)
|
24
|
+
rack-protection (1.5.3)
|
25
|
+
rack
|
26
|
+
sinatra (1.4.5)
|
27
|
+
rack (~> 1.4)
|
28
|
+
rack-protection (~> 1.4)
|
29
|
+
tilt (~> 1.3, >= 1.3.4)
|
30
|
+
sinatra-activerecord (2.0.2)
|
31
|
+
activerecord (>= 3.2)
|
32
|
+
sinatra (~> 1.0)
|
33
|
+
thread_safe (0.3.4)
|
34
|
+
tilt (1.4.1)
|
35
|
+
tzinfo (1.2.1)
|
36
|
+
thread_safe (~> 0.1)
|
37
|
+
|
38
|
+
PLATFORMS
|
39
|
+
ruby
|
40
|
+
|
41
|
+
DEPENDENCIES
|
42
|
+
activerecord
|
43
|
+
pg
|
44
|
+
sinatra
|
45
|
+
sinatra-activerecord
|
data/demo/Rakefile
ADDED
data/demo/app.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'sinatra/activerecord'
|
3
|
+
|
4
|
+
require './note'
|
5
|
+
require './db_setup'
|
6
|
+
|
7
|
+
get "/" do
|
8
|
+
@notes = Note.order("created_at DESC")
|
9
|
+
redirect "/new" if @notes.empty?
|
10
|
+
erb :index
|
11
|
+
end
|
12
|
+
|
13
|
+
get "/new" do
|
14
|
+
erb :new
|
15
|
+
end
|
16
|
+
|
17
|
+
post "/new" do
|
18
|
+
@note = Note.new(params[:note])
|
19
|
+
if @note.save
|
20
|
+
redirect "note/#{@note.id}"
|
21
|
+
else
|
22
|
+
erb :new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
get "/note/:id" do
|
27
|
+
@note = Note.find_by_id(params[:id])
|
28
|
+
erb :note
|
29
|
+
end
|
data/demo/config.ru
ADDED
data/demo/db/schema.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(version: 20140610204302) do
|
15
|
+
|
16
|
+
# These are extensions that must be enabled in order to support this database
|
17
|
+
enable_extension "plpgsql"
|
18
|
+
|
19
|
+
create_table "notes", force: true do |t|
|
20
|
+
t.string "title"
|
21
|
+
t.text "body"
|
22
|
+
t.datetime "created_at"
|
23
|
+
t.datetime "updated_at"
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/demo/db_setup.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
postgresql_host = ENV['POSTGRESQL_HOST'].nil? ? 'localhost' : ENV['POSTGRESQL_HOST']
|
2
|
+
|
3
|
+
ActiveRecord::Base.establish_connection(
|
4
|
+
:adapter => 'postgresql',
|
5
|
+
:host => postgresql_host,
|
6
|
+
:username => 'ruby_dev',
|
7
|
+
:password => 'ruby_dev',
|
8
|
+
:database => 'ruby_dev_dev',
|
9
|
+
:port => "5432",
|
10
|
+
:encoding => 'utf8'
|
11
|
+
)
|
data/demo/note.rb
ADDED
data/demo/views/new.erb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
<h1>New Note</h1>
|
2
|
+
<form action="/new" method="post">
|
3
|
+
<label for="title">Title:</label><br />
|
4
|
+
<input id="title" name="note[title]" type="text" />
|
5
|
+
<br />
|
6
|
+
|
7
|
+
<label for="body">Body:</label><br />
|
8
|
+
<textarea id="body" name="note[body]" rows="10"></textarea>
|
9
|
+
<br />
|
10
|
+
|
11
|
+
<button type="submit">Save</button>
|
12
|
+
</form>
|
data/demo/views/note.erb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# https://docs.docker.com/examples/postgresql_service/
|
2
|
+
|
3
|
+
FROM ubuntu
|
4
|
+
MAINTAINER SvenDowideit@docker.com
|
5
|
+
|
6
|
+
# Add the PostgreSQL PGP key to verify their Debian packages.
|
7
|
+
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
|
8
|
+
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
|
9
|
+
|
10
|
+
# Add PostgreSQL's repository. It contains the most recent stable release
|
11
|
+
# of PostgreSQL, ``9.3``.
|
12
|
+
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
|
13
|
+
|
14
|
+
# Update the Ubuntu and PostgreSQL repository indexes
|
15
|
+
RUN apt-get update
|
16
|
+
|
17
|
+
# Install ``python-software-properties``, ``software-properties-common`` and PostgreSQL 9.3
|
18
|
+
# There are some warnings (in red) that show up during the build. You can hide
|
19
|
+
# them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive
|
20
|
+
RUN apt-get -y -q install python-software-properties software-properties-common
|
21
|
+
RUN apt-get -y -q install postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
|
22
|
+
|
23
|
+
# Note: The official Debian and Ubuntu images automatically ``apt-get clean``
|
24
|
+
# after each ``apt-get``
|
25
|
+
|
26
|
+
# Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed``
|
27
|
+
USER postgres
|
28
|
+
|
29
|
+
# Create a PostgreSQL role named ``docker`` with ``docker`` as the password and
|
30
|
+
# then create a database `docker` owned by the ``docker`` role.
|
31
|
+
# Note: here we use ``&&\`` to run commands one after the other - the ``\``
|
32
|
+
# allows the RUN command to span multiple lines.
|
33
|
+
#RUN /etc/init.d/postgresql start &&\
|
34
|
+
# psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" &&\
|
35
|
+
# createdb -O docker docker
|
36
|
+
|
37
|
+
ADD bin/create_db.sh /src/
|
38
|
+
RUN /src/create_db.sh
|
39
|
+
|
40
|
+
|
41
|
+
# Adjust PostgreSQL configuration so that remote connections to the
|
42
|
+
# database are possible.
|
43
|
+
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf
|
44
|
+
|
45
|
+
# And add ``listen_addresses`` to ``/etc/postgresql/9.3/main/postgresql.conf``
|
46
|
+
RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf
|
47
|
+
|
48
|
+
# Expose the PostgreSQL port
|
49
|
+
EXPOSE 5432
|
50
|
+
|
51
|
+
# Add VOLUMEs to allow backup of config, logs and databases
|
52
|
+
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
|
53
|
+
|
54
|
+
# Set the default command to run when starting the container
|
55
|
+
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"]
|
56
|
+
|
57
|
+
# docker stop postgres
|
58
|
+
# docker rm postgres
|
59
|
+
# docker build -t postgres docker/postgres
|
60
|
+
# docker run -d -p 5432:5432 --name postgres postgres
|
61
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
/etc/init.d/postgresql start
|
4
|
+
|
5
|
+
psql --command "CREATE USER ruby_dev WITH SUPERUSER PASSWORD 'ruby_dev';"
|
6
|
+
|
7
|
+
createdb -O ruby_dev ruby_dev_test
|
8
|
+
createdb -O ruby_dev ruby_dev_dev
|
9
|
+
createdb -O ruby_dev ruby_dev_prod
|
10
|
+
|
11
|
+
psql -l
|
12
|
+
|
13
|
+
/etc/init.d/postgresql stop
|
14
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# https://registry.hub.docker.com/u/dhrp/sshd/
|
2
|
+
# http://stackoverflow.com/questions/23014684/how-to-get-ssh-connection-with-docker-container-on-osxboot2docker
|
3
|
+
|
4
|
+
# sshd
|
5
|
+
#
|
6
|
+
# VERSION 0.0.1
|
7
|
+
|
8
|
+
FROM ubuntu
|
9
|
+
MAINTAINER Thatcher R. Peskens "thatcher@dotcloud.com"
|
10
|
+
|
11
|
+
# make sure the package repository is up to date
|
12
|
+
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
|
13
|
+
RUN apt-get update
|
14
|
+
|
15
|
+
RUN apt-get install -y openssh-server
|
16
|
+
RUN mkdir /var/run/sshd
|
17
|
+
RUN echo 'root:screencast' |chpasswd
|
18
|
+
|
19
|
+
EXPOSE 22
|
20
|
+
|
21
|
+
CMD /usr/sbin/sshd -D
|
22
|
+
|
23
|
+
# docker build -t sshd docker/sshd
|
24
|
+
# docker run -d -P --name sshd sshd
|
25
|
+
|
26
|
+
# docker port sshd 22
|
27
|
+
# boot2docker ip
|
28
|
+
# ssh root@192.168.59.104 -p 49153
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# http://docs.docker.com/examples/using_supervisord/
|
2
|
+
|
3
|
+
FROM ubuntu:latest
|
4
|
+
MAINTAINER examples@docker.io
|
5
|
+
|
6
|
+
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
|
7
|
+
RUN apt-get update
|
8
|
+
RUN apt-get upgrade -y
|
9
|
+
|
10
|
+
RUN apt-get install -y openssh-server apache2 supervisor
|
11
|
+
RUN mkdir -p /var/run/sshd
|
12
|
+
RUN mkdir -p /var/log/supervisor
|
13
|
+
|
14
|
+
RUN echo 'root:screencast' |chpasswd
|
15
|
+
|
16
|
+
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
17
|
+
|
18
|
+
EXPOSE 22 80
|
19
|
+
|
20
|
+
CMD ["/usr/bin/supervisord"]
|
21
|
+
|
22
|
+
|
23
|
+
# docker build -t supervisord docker/supervisord
|
24
|
+
# docker run -p 22 -p 80 -t -i --name supervisord supervisord
|
25
|
+
|
26
|
+
# docker port sshd 22
|
27
|
+
# boot2docker ip
|
28
|
+
# ssh root@192.168.59.104 -p 49154
|
@@ -10,7 +10,7 @@ class GenericProvision
|
|
10
10
|
|
11
11
|
attr_reader :interpolator, :env, :script_list, :server_info
|
12
12
|
|
13
|
-
def initialize config_file_name, scripts_file_names
|
13
|
+
def initialize parent_class, config_file_name, scripts_file_names
|
14
14
|
@interpolator = TextInterpolator.new
|
15
15
|
|
16
16
|
@env = read_config(config_file_name)
|
@@ -21,30 +21,39 @@ class GenericProvision
|
|
21
21
|
@script_list.merge!(scripts(name))
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
create_script_methods
|
25
|
+
|
26
|
+
create_thor_methods(parent_class) if parent_class.ancestors.include?(Thor)
|
25
27
|
|
26
28
|
@server_info = env[:node] ? env[:node] : {}
|
27
29
|
end
|
28
30
|
|
29
|
-
# def create_script_methods parent, current
|
30
|
-
# parent_metaclass = parent.singleton_class
|
31
|
-
# current_metaclass = current.singleton_class
|
32
|
-
#
|
33
|
-
# current.script_list.keys.each do |name|
|
34
|
-
# # create methods on parent, e.g. thor or rake file
|
35
|
-
# parent_metaclass.send(:define_method, name.to_sym) do |*args, &block|
|
36
|
-
# current.send(name, args, block)
|
37
|
-
# end
|
38
|
-
#
|
39
|
-
# # create methods on installer
|
40
|
-
# current_metaclass.send(:define_method, name.to_sym) do |_, _|
|
41
|
-
# current.send :run, current.server_info, name.to_s, current.env
|
42
|
-
# end
|
43
|
-
# end
|
44
|
-
# end
|
45
|
-
|
46
31
|
protected
|
47
32
|
|
33
|
+
def create_script_methods
|
34
|
+
script_list.keys.each do |name|
|
35
|
+
singleton_class.send(:define_method, name.to_sym) do
|
36
|
+
self.send :run, server_info, name.to_s, env
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_thor_methods parent_class
|
42
|
+
provision = self
|
43
|
+
|
44
|
+
provision.script_list.each do |name, value|
|
45
|
+
title = provision.script_title(value)
|
46
|
+
|
47
|
+
title = title.nil? ? name : title
|
48
|
+
|
49
|
+
parent_class.send(:desc, name, title) if parent_class.respond_to?(:desc)
|
50
|
+
|
51
|
+
parent_class.send(:define_method, name.to_sym) do
|
52
|
+
provision.send "#{name}".to_sym
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
48
57
|
def read_config config_file_name
|
49
58
|
hash = JSON.parse(File.read(config_file_name), :symbolize_names => true)
|
50
59
|
|