baptize 0.0.1 → 0.0.2
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 +8 -8
- data/README.markdown +125 -16
- data/lib/baptize/dsl.rb +1 -0
- data/lib/baptize/install.rb +12 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjA0ODY3NjU4YjIzMzRkZjA1NjY5OTExY2YwZDFkZjFjYjI2NTU1NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjcxM2RiMjVhNzYwMDY1MDdiMjI5OWEzZTc3ZWUxOGQwMzVmOGU4OQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmYxMmMyN2Q1ZDU2ZmM1OWViMzYxYWQ4NzhkZmNmYzc2NTcxMGZhYjVlMjg1
|
10
|
+
ODAyMjg4NWI4OGE1ZTUxZDFmYjA3OTM0N2EwMDFjYTNlNTYwYzY4MjY5MTQ3
|
11
|
+
MWU0YjMxYmEzNTExMDkxNjY1ODJmMzUyZmVlODMwOGNlY2E2NGI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmEzZGEzZTFlMWYyMjU0ODI0ODgyMzhlYzgyNDBiZmYxMGNkNDc1MGE0Zjkx
|
14
|
+
ODM2ZmZjYTBiYTA1OTM0ZWEwYjRmYjRlMjNiZjYwNWIwM2FlZGFhYTZlYjU4
|
15
|
+
YWVlNTMzNjE3MWNjOWVjOWM0ODQzMTNjNDMwYWRiZTY5NmUwZGY=
|
data/README.markdown
CHANGED
@@ -1,26 +1,135 @@
|
|
1
1
|
Baptize
|
2
|
+
===
|
3
|
+
|
4
|
+
Baptize is an extension for Capistrano, that allows for server provisioning. The API resembles [Sprinkle](https://github.com/sprinkle-tool/sprinkle), but the underlying implementation is quite different. Where Sprinkle tries to compile a static payload of commands and push to the server, Baptize is executed in runtime. It also reuses much more of Capistrano, than Sprinkle does. Basically, each Baptize package is a capistrano task - Baptize just adds some helpers and fancy dsl on top, to make it look declarative.
|
5
|
+
|
6
|
+
Be warned that Baptize is less than a week old at the time of this writing, and it has no test coverage - so it's probably riddled with bugs. That said, I do eat my own dog food, so it's at least somewhat functional.
|
7
|
+
|
8
|
+
Setup
|
9
|
+
---
|
10
|
+
|
11
|
+
At some point, I'll probably wrap this procedure in a generator, but for now you'll have to do so manually.
|
12
|
+
|
13
|
+
To get started, create a `Gemfile`:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
source 'https://rubygems.org'
|
17
|
+
gem 'capistrano'
|
18
|
+
gem 'baptize'
|
19
|
+
```
|
20
|
+
|
21
|
+
And a `Capfile`:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'bundler'
|
25
|
+
require 'capistrano'
|
26
|
+
require 'baptize'
|
27
|
+
set :capistrano_path, "#{root_path}/capistrano"
|
28
|
+
set :assets_path, "#{capistrano_path}/assets"
|
29
|
+
load_configuration :roles
|
30
|
+
|
31
|
+
Dir.glob("#{capistrano_path}/packages/**/*.rb").each do |package|
|
32
|
+
load(package)
|
33
|
+
end
|
34
|
+
|
35
|
+
Dir.glob("#{capistrano_path}/recipes/**/*.rb").each do |recipe|
|
36
|
+
load(recipe)
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
And a couple of folders and files:
|
41
|
+
|
42
|
+
./capistrano/
|
43
|
+
./capistrano/config/
|
44
|
+
./capistrano/config/roles.rb # Globally applied configuration. Define roles here.
|
45
|
+
./capistrano/config/baptize.rb # Contains config files used by baptize packages. Define policies here.
|
46
|
+
./capistrano/packages/ # Put package definitions in here.
|
47
|
+
./capistrano/recipes/ # Put regular capistrano tasks in here.
|
48
|
+
./capistrano/assets/ # Place auxiliary files here.
|
49
|
+
|
50
|
+
And Finally, run the following command:
|
51
|
+
|
52
|
+
bundle
|
53
|
+
|
54
|
+
Sample configuration
|
2
55
|
---
|
3
56
|
|
4
|
-
|
57
|
+
First define some roles, by opening up `config/roles.rb` - This is just regular Capistrano stuff. For example:
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
role :server, "192.168.1.1"
|
61
|
+
```
|
62
|
+
|
63
|
+
Next define a policy for the server. Open up `config/baptize.rb` and put this:
|
5
64
|
|
6
|
-
|
65
|
+
```ruby
|
66
|
+
policy :server do
|
67
|
+
requires :system_update
|
68
|
+
end
|
69
|
+
```
|
7
70
|
|
8
|
-
|
71
|
+
This defines that the role `:server` needs a package `system_update`.
|
9
72
|
|
10
|
-
|
73
|
+
You probably should define which login credentials to use as well:
|
11
74
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
75
|
+
```ruby
|
76
|
+
# ssh login user
|
77
|
+
set :user, 'ubuntu'
|
78
|
+
# ssh key location
|
79
|
+
ssh_options[:keys] = '~/.ssh/aws-key.pem'
|
80
|
+
# run commands through sudo
|
81
|
+
set :use_sudo, true
|
82
|
+
```
|
18
83
|
|
19
|
-
|
20
|
-
load(package)
|
21
|
-
end
|
84
|
+
Note that since this is defined inside `config/baptize.rb`, it won't apply to capistrano recipes outside of baptize. The roles, on the other hand, is globally loaded (That happens in the `Capfile`).
|
22
85
|
|
23
|
-
|
24
|
-
|
25
|
-
|
86
|
+
Better create that packages then. Open up `packages/system_update.rb`:
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
package :system_update do
|
90
|
+
description "System Update"
|
91
|
+
install do
|
92
|
+
run 'apt-get update -y'
|
93
|
+
run 'apt-get upgrade -y'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
```
|
97
|
+
|
98
|
+
This defines a package, that will upgrade the apt package manager of the target system.
|
99
|
+
|
100
|
+
Deploying policies
|
101
|
+
---
|
102
|
+
|
103
|
+
You can now run the following command:
|
104
|
+
|
105
|
+
cap baptize
|
106
|
+
|
107
|
+
Which should make capistrano ssh in to the `:server` role and try to update apt. It'll probably fail, unless you actually have a server running at that IP.
|
108
|
+
|
109
|
+
If you want to just configure a single role, you can do so by running:
|
110
|
+
|
111
|
+
cap baptize:policies:server
|
112
|
+
|
113
|
+
Using Baptize alongside Capistrano
|
114
|
+
---
|
115
|
+
|
116
|
+
If you also want to use Capistrano for regular application deployment (what it's actually ment for), you might want to create a file in `config/deploy.rb` to hold settings for this. E.g.:
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
set :application, "set your application name here"
|
120
|
+
set :repository, "set your repository location here"
|
121
|
+
```
|
122
|
+
|
123
|
+
And to make sure it is loaded, modify your `Capfile` to include:
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
load 'deploy'
|
127
|
+
load 'deploy/assets' # For using Rails' asset pipeline
|
128
|
+
before 'deploy' do
|
129
|
+
load_configuration :deploy
|
130
|
+
end
|
131
|
+
```
|
132
|
+
|
133
|
+
---
|
26
134
|
|
135
|
+
TODO: There is more to Baptize, but that'll have to wait for now.
|
data/lib/baptize/dsl.rb
CHANGED
data/lib/baptize/install.rb
CHANGED
@@ -24,32 +24,29 @@ module Capistrano
|
|
24
24
|
install
|
25
25
|
end
|
26
26
|
|
27
|
-
desc "Configures all available
|
27
|
+
desc "Configures all available policies"
|
28
28
|
task :install do ; end
|
29
29
|
|
30
|
-
desc "List configured roles"
|
31
|
-
task :roles do
|
32
|
-
load_configuration
|
33
|
-
result = []
|
34
|
-
logger.info "Configured roles:"
|
35
|
-
top.roles.each do |name,r|
|
36
|
-
logger.info "#{name} [" + r.servers.join(", ") + "]"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
30
|
namespace :policies do
|
41
|
-
desc "List
|
31
|
+
desc "List available policies"
|
42
32
|
task :default do
|
43
33
|
load_configuration
|
44
|
-
logger.info "
|
34
|
+
logger.info "Available policies:"
|
45
35
|
tasks.flatten.each do |x|
|
46
36
|
if x.kind_of?(Capistrano::TaskDefinition) && x.fully_qualified_name != "baptize:policies"
|
47
37
|
name = x.fully_qualified_name.gsub(/^baptize:policies:/, "")
|
48
38
|
policy = Capistrano::Baptize::DSL.policies[name.to_sym]
|
49
|
-
logger.info "#{name}
|
39
|
+
logger.info "#{name}:"
|
40
|
+
logger.info "-> servers:"
|
41
|
+
top.roles[name.to_sym].servers.each do |s|
|
42
|
+
logger.info "-> #{s}"
|
43
|
+
end
|
44
|
+
logger.info "-> dependencies:"
|
45
|
+
policy.dependencies.each do |d|
|
46
|
+
logger.info "-> #{d}"
|
47
|
+
end
|
50
48
|
end
|
51
49
|
end
|
52
|
-
# logger.info "Policies have been defined for roles: " + policies.join(", ")
|
53
50
|
end
|
54
51
|
end
|
55
52
|
|