baptize 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGRmM2Y4ZGE4YWM1NTNjNWFjYWY1Y2Q3YjBiZGQ5ZDczOTIxMGZlOA==
4
+ YjA0ODY3NjU4YjIzMzRkZjA1NjY5OTExY2YwZDFkZjFjYjI2NTU1NQ==
5
5
  data.tar.gz: !binary |-
6
- NWZhZGI1NDQ1YjdmZjg5NDY3N2M4OGE5ODY0M2NmYmRjYmY5M2EzNg==
6
+ MjcxM2RiMjVhNzYwMDY1MDdiMjI5OWEzZTc3ZWUxOGQwMzVmOGU4OQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MzRhMTc5NzI1ODA5MWJkOGFmZmE4YjJhZTQzMWUzODM1OTdiYmE3OTk1ZTFh
10
- MTRmYjE0OTRmOTY2Mjc2YjBjZDhkMmYyODcxNzMzYjE5ZTdjZGM1MzdkZmQ0
11
- NWIwNzViNGIwM2E3MTZhOGEyMDBlN2I5Yjc2NWE3OGEzYTQ5ZmM=
9
+ ZmYxMmMyN2Q1ZDU2ZmM1OWViMzYxYWQ4NzhkZmNmYzc2NTcxMGZhYjVlMjg1
10
+ ODAyMjg4NWI4OGE1ZTUxZDFmYjA3OTM0N2EwMDFjYTNlNTYwYzY4MjY5MTQ3
11
+ MWU0YjMxYmEzNTExMDkxNjY1ODJmMzUyZmVlODMwOGNlY2E2NGI=
12
12
  data.tar.gz: !binary |-
13
- MDU4NTc0ZmE3NDhjODY4YTk0ODU1MGZkYzIwZTQ4Yjc5OTM2Y2U4ZWE2ZWZh
14
- MTNmODVjYjNiMzA1ZDIxNWM5YWE2ZWRlZDI1NDdjZTg3YzZiYzVlZTQ5ZWJl
15
- NTQ4MTFhYzE1YTU1MzNmOWE4YzFiOTExNjNlYmM0Y2E1YmU3MWY=
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
- Entirely undocumented for the time being.
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
- To install, run:
65
+ ```ruby
66
+ policy :server do
67
+ requires :system_update
68
+ end
69
+ ```
7
70
 
8
- rake install
71
+ This defines that the role `:server` needs a package `system_update`.
9
72
 
10
- A sample `Capfile` to get you started:
73
+ You probably should define which login credentials to use as well:
11
74
 
12
- require 'bundler'
13
- require 'capistrano'
14
- require 'baptize'
15
- set :capistrano_path, "#{root_path}/capistrano"
16
- set :assets_path, "#{capistrano_path}/assets"
17
- load_configuration :roles
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
- Dir.glob("#{capistrano_path}/packages/**/*.rb").each do |package|
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
- Dir.glob("#{capistrano_path}/recipes/**/*.rb").each do |recipe|
24
- load(recipe)
25
- end
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
@@ -120,6 +120,7 @@ module Capistrano
120
120
  policy.instance_eval &block
121
121
  namespace :baptize do
122
122
  namespace :policies do
123
+ desc "Configures #{policy.role}"
123
124
  task policy.role do
124
125
  logger.info "Applying policy #{policy.role}"
125
126
  old_env_roles = ENV['ROLES']
@@ -24,32 +24,29 @@ module Capistrano
24
24
  install
25
25
  end
26
26
 
27
- desc "Configures all available roles"
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 configured policies"
31
+ desc "List available policies"
42
32
  task :default do
43
33
  load_configuration
44
- logger.info "Configured policies:"
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} [" + policy.dependencies.join(", ") + "]"
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baptize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Troels Knak-Nielsen