DEVELOPMENT STOPPED. EOL.
Fast KISS deployment tool.
Why bleetz ?
I tried Capistrano, Minas. They are great (No irony) but not for me.
I prefere when I know what is going on.
Requirements
You need rubygems installed.
Tested with Ruby:
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0-preview1
Installation
gem install bleetz
or for development:
git clone https://github.com/TibshoOT/bleetz.git
gem build bleetz.gemspec
gem install ./bleetz
Configuration
There are two files. Main configuration file and .bleetz file:
- Main configuration is located where you want.
- .bleetz has to be in bleetz binary call directory.
For example:
$ mkdir -p ~/bleetz
$ touch ~/bleetz/bleetz.conf
$ mkdir a_project_path
$ cd a_project_path
$ echo 'config: \'~/bleetz/bleetz.conf\'' > .bleetz
$ bleetz -l
Following options have to be written in ~/bleetz/bleetz.conf in our example.
Not the most important but...
The most helpful to understand your configuration, comment !
# This is a fraking great comment !
SSH configuration
Bleetz has wrapped net-ssh library options to configure your ssh connection(s).
Mandatory:
Option | Conf symbol | Type |
---|---|---|
Host | :host | String |
Username | :username | String |
Optionnal:
These options are set by default but you can overide them (if you are sure what you are doing...)
Option | Conf symbol | Type | Default value |
---|---|---|---|
Port | :port | Integer | 22 |
Proxy Command | :proxycmd | String | empty |
Timeout | :timeout | Integer | 10 |
Private Key | :keys | Array of String | ["~/.ssh/id_dsa", "~/.ssh2/id_dsa", "~/.ssh/id_rsa", "~/.ssh2/id_rsa"] |
Compression | :compression | String | 'none' |
Compression level | :compression_level | Integer | 6 |
Encryption | :encryption | String || Array of String | '3des-cbc' |
Host key | :host_key | String || Array of String | 'ssh-dss' |
Check example file here.
Generally, you don't have to change these options except :port, :timeout and :keys.
How to configure
You have to use set function. In order to configure a user, you can do this:
set :username, 'a_login'
Actions
This is the main feature of Bleetz. Actions.
Actions are kind of functions where you write shell script that will be executed over SSH.
Bleetz has been coded to deploy code but you can use it for different purpose (restart some services, backup, etc).
Defining action
To define an action:
action(:action_name) {
# blabla
}
or
action :action_name do
# blabla
end
If you want to put a description, you can do this:
action(:action_name, "a fraking awesome description") {
}
You will see why you've put this after :action_name (See Usage chapter, -l option).
Write shell script
Imagine that you want to write an action that print "42".
action(:forty_two) {
shell "echo '42'"
}
This part will execute echo 42 after SSH connection.
Yo dawg, I heard you like to call action, so I put an action in an action so...
You can !
Taking our previous :forty_two action:
action(:forty_two) {
shell "echo '42'"
}
Imagine that you want print 42 in another action, :new_action here, but you want to stay DRY:
action(:forty_two) {
shell "echo '42'"
}
action :new_action, "A description !" do
shell "echo 'I will print 42 !'"
call :forty_two
end
That's it. If you call :new_action, 'I will print 42 !' and '42' will be printed after SSH connection. :)
Callbacks
If you want to run LOCAL shell scripts with bleetz before or after action, you can !
before(:test) {
shell "echo 'Command will be runned in local before ssh'"
}
action(:test) {
shell "echo 'Command over ssh'"
}
after(:test) {
shell "echo 'Command will be rrunned in local after ssh'"
}
After and Before callback are called ONLY FOR THE MAIN action. Don't worry about calls in action.
Example, if you have defined this:
before(:test) {
shell "echo 'Command will be runned in local before ssh'"
}
action(:test) {
shell "echo 'Command over ssh'"
}
after(:test) {
shell "echo 'after ssh command in local'"
}
before(:testbis) {
shell "echo 'Command will be runned in local before ssh'"
}
action(:testbis) {
call :test
shell "echo 'Command over ssh'"
}
If you call bleetz test, that will execute before(:test), action(:test) and finally, after(:test).
If you call bleetz testbis, that will execute before(:testbis), action(:testbis), action(:test), that's all.
.bleetz file (YAML)
At the moment, there is only one option. Mandatory if you don't use -c command option.
Attribute | Argument | Explanation |
---|---|---|
config | A configuration filee path | Tell bleetz binary to check configuration file without giving -c . |
Example:
$ cat .bleetz
You should see:
config: 'a/path/to/bleetz/configuration/file'
Usage
It's important to notice that action name has to be put at end of command.
Available options
Option | Need an argument ? | Explanation |
---|---|---|
-c | Yes, a configuration file | If you want to skip .bleetz file, use -c option. |
-h | No. | Display help. |
-l | No. | List configured actions in configuration file. |
-s | No. | Test configured SSH connection. |
-t | Yes, action's name. | Test actions, just print commands. |
-v | No. | Verbose mode. |
-V | No. | Display version. |
Examples
List available actions:
bleetz -c /etc/bleetz.conf -l
Test SSH connction (with .bleetz file):
bleetz -s
Test :deploy action:
bleetz -c /etc/bleetz.conf -t deploy
Exexute :deploy action in verbose mode (with .bleetz file):
bleetz -v deploy
Common errors
SOON.
Want a feature ? Problem ?
Open an issue ;)