izanami 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.env.development +6 -0
- data/.gitignore +23 -0
- data/Gemfile +8 -0
- data/LICENSE +20 -0
- data/README.md +133 -0
- data/Rakefile +34 -0
- data/assets/css/app.css +1 -0
- data/assets/css/bootstrap.css +6805 -0
- data/assets/css/bootstrap.min.css +9 -0
- data/assets/js/app.js +47 -0
- data/assets/js/bootstrap.js +1999 -0
- data/assets/js/bootstrap.min.js +6 -0
- data/assets/js/jquery-2.0.3.min.js +6 -0
- data/bin/izanami +14 -0
- data/bin/izanami-app +14 -0
- data/bin/izanami-watchdog +12 -0
- data/izanami.gemspec +30 -0
- data/lib/izanami/app.rb +165 -0
- data/lib/izanami/channel.rb +133 -0
- data/lib/izanami/mapper.rb +64 -0
- data/lib/izanami/mappers/command.rb +161 -0
- data/lib/izanami/version.rb +3 -0
- data/lib/izanami/worker.rb +59 -0
- data/lib/izanami/workers/command.rb +82 -0
- data/lib/izanami/workers/watchdog.rb +65 -0
- data/lib/izanami.rb +5 -0
- data/spec/helper.rb +12 -0
- data/spec/izanami/app_spec.rb +195 -0
- data/spec/izanami/channel/input_spec.rb +38 -0
- data/spec/izanami/channel_spec.rb +66 -0
- data/spec/izanami/mapper_spec.rb +48 -0
- data/spec/izanami/mappers/command_spec.rb +154 -0
- data/spec/izanami/workers/command_spec.rb +122 -0
- data/spec/sandbox/Capfile +4 -0
- data/spec/sandbox/Gemfile +3 -0
- data/views/_commands_panel.erb +12 -0
- data/views/command.erb +10 -0
- data/views/home.erb +44 -0
- data/views/layout.erb +32 -0
- metadata +207 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
N2RlYTk4ZDQ1ZDZiMmNlM2NiNjY0YTBjZGRiZGQ2NDZlZDg2MjNjYQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NjI4ZDI0ZDZmOTdiNzY2NzM0ZDNjYTVmMDM3NzdhZmVmNTAwZmYyMg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NmQxMTM3ZWE3NDRlMWM3YzY5MjQ5YWRmNGQ3YzMyMjIzZjcyMDgzY2I1MDk0
|
10
|
+
ODY3M2I5NGEyMDc2NWVjNmZjYTVmMTMxNzI3ZWNhZjkxMGY4NGE1NDRiMTUz
|
11
|
+
OTI4ZTZmOWZjZjY2MTBjMzJjYzZmODhjMWVmY2YxMTI5NjdjMWI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NmZhODcxYWIzYmI2YzU5YjU1YTU3ZWM5NDc3YjY1NDk5ZWNhNTU4YjhkNmZk
|
14
|
+
MDU2YjVlODAxNzM4NTBlOTcxMGVkZDZmYjkxYzk4NjFlYTQwZDJiYmUyOWEz
|
15
|
+
NWE4OTEyNWFhZDIzZjI1YzQwMTkzOTY1MjQ1MDMwZjU4ZDJmNGM=
|
data/.env.development
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
coverage
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
lib/bundler/man
|
9
|
+
pkg
|
10
|
+
rdoc
|
11
|
+
spec/reports
|
12
|
+
test/tmp
|
13
|
+
test/version_tmp
|
14
|
+
tmp
|
15
|
+
vendor/bundle
|
16
|
+
spec/sandbox/vendor/bundle
|
17
|
+
.env
|
18
|
+
Procfile
|
19
|
+
|
20
|
+
# YARD artifacts
|
21
|
+
.yardoc
|
22
|
+
_yardoc
|
23
|
+
doc/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Juan Hernández
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
# Izanami
|
2
|
+
|
3
|
+
Opitionated web app to handle capistrano recipes.
|
4
|
+
|
5
|
+
## Rationale
|
6
|
+
|
7
|
+
Izanami is a Sinatra app that tries to execute `capistrano` commands as a normal user.
|
8
|
+
When a set of tasks is sent, Izanami forks a new process that executes that tasks as a UNIX command, and streams the output (via redis's `pub/sub` system) to the web app.
|
9
|
+
The commands are stored in redis, with the sent tasks, an unique ID, the output of the command and the process status (pending, success or fail).
|
10
|
+
All the redis keys are prefixed with a namespace called `izanami`.
|
11
|
+
|
12
|
+
Izanami can work with any kind of `capistrano` projects. To do so, it assumes that the `capistrano` recipes are in a separated directory.
|
13
|
+
This directory is the *sandbox* and it MUST be a ruby project handled by bundler. Every `capistrano` command will be executed as:
|
14
|
+
|
15
|
+
$ pwd
|
16
|
+
/path/to/sandbox
|
17
|
+
$ bundle exec cap [tasks]
|
18
|
+
|
19
|
+
It's the admin reponsibility to set up that directory and to have all the bundler dependencies installed.
|
20
|
+
|
21
|
+
Other thing to be aware of is that Izanami doesn't handle interactive `capistrano` tasks. It cannot send inputs to a running command. That means
|
22
|
+
that the `capistrano` commands need to be non interactive.
|
23
|
+
|
24
|
+
Izanami tries to be a simple interface over `capistrano`, not a complete replacement for the shell.
|
25
|
+
It can help to handle basic tasks in a healthy system, but nothing beats the terminal when you need to solve more serious problems.
|
26
|
+
|
27
|
+
## Showcase
|
28
|
+
|
29
|
+
You can see a small [demo of the app here](http://cl.ly/Qt3c).
|
30
|
+
|
31
|
+
## Dependencies
|
32
|
+
|
33
|
+
Izanami stores all the data about the commands executed inside redis. All the keys expire after a week.
|
34
|
+
It also uses the redis' `pub/sub` feature to show the output of a running command.
|
35
|
+
|
36
|
+
## Installation
|
37
|
+
|
38
|
+
You can install it by using the following command:
|
39
|
+
|
40
|
+
$ gem install izanami
|
41
|
+
|
42
|
+
Or build the gem:
|
43
|
+
|
44
|
+
$ gem build izanami.gemspec
|
45
|
+
$ gem install izanami-x.y.x.gem
|
46
|
+
|
47
|
+
## Usage
|
48
|
+
|
49
|
+
### Configuration
|
50
|
+
|
51
|
+
Izanami configuration is handled via environment variables:
|
52
|
+
|
53
|
+
* `RACK_ENV`: App environment (e.g: `development`, `production`, `test`. Defaults to `development`).
|
54
|
+
* `IZANAMI_PORT`: Web app port (defaults to `4567`).
|
55
|
+
* `IZANAMI_USER`: User for the HTTP Basic Authentication (e.g: `izanami`).
|
56
|
+
* `IZANAMI_PASSWORD`: Password for the HTTP Basic Authentication (e.g: `$3cr3t`).
|
57
|
+
* `IZANAMI_RESIS_URL`: Redis configuration in URL format (defaults to `redis://127.0.0.1:6379/0`).
|
58
|
+
* `IZANAMI_SANDBOX`: Path to the directory with the capistrano recipes.
|
59
|
+
* `IZANAMI_WATCHDOG_SLEEP_TIME`: The time the watchdog sleeps before update the sandbox git repository (default to 300 seconds).
|
60
|
+
|
61
|
+
### Running the web app
|
62
|
+
|
63
|
+
Izanami runs with `thin` by default. You can start the app with:
|
64
|
+
|
65
|
+
$ IZANAMI_USER=izanami IZANAMI_PASSWORD=izanami IZANAMI_SANDBOX=/path/to/recipes izanami app
|
66
|
+
|
67
|
+
But Izanami is a simple Sinatra app, so you can run it with any ruby server that handles a `config.ru` file:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
# simple config.ru file
|
71
|
+
require 'rack'
|
72
|
+
require 'izanami/app'
|
73
|
+
|
74
|
+
run Izanami::App
|
75
|
+
```
|
76
|
+
|
77
|
+
The app uses the Sinatra `stream` feature, so you will need a server that can handle it, as `thin` does.
|
78
|
+
|
79
|
+
### The sandbox watchdog
|
80
|
+
|
81
|
+
The sandbox directory is a git repository, Izanami comes with a simple script that watches this repo and updates it (`git pull`) every 300 seconds (or any defined time period).
|
82
|
+
This way, you can always have the latest version of the recipes.
|
83
|
+
|
84
|
+
To run the watchdog, simply start the watchdog:
|
85
|
+
|
86
|
+
$ IZANAMI_SANDBOX=/path/to/recipes izanami watchdog
|
87
|
+
|
88
|
+
The watchdog outputs to the standard output the result of executing `git pull` and the status of the command.
|
89
|
+
|
90
|
+
### Tip: Using foreman
|
91
|
+
|
92
|
+
To handle the configuration of the app, it can be a good idea to use [foreman](https://github.com/ddollar/foreman).
|
93
|
+
|
94
|
+
This is an example for an `.env` file:
|
95
|
+
|
96
|
+
RACK_ENV=production
|
97
|
+
IZANAMI_PORT=8899
|
98
|
+
IZANAMI_USER=izanami
|
99
|
+
IZANAMI_PASSWORD=supersecretpass
|
100
|
+
IZANAMI_RESIS_URL=redis://redis.provider.com:6379/0
|
101
|
+
IZANAMI_SANDBOX=/var/recipes/
|
102
|
+
IZANAMI_WATCHDOG_SLEEP_TIME=600
|
103
|
+
|
104
|
+
And this can be a `Procfile`:
|
105
|
+
|
106
|
+
app: izanami app
|
107
|
+
watchdog: izanami watchdog
|
108
|
+
|
109
|
+
Also, `foreman` can be exported to `init.d` scripts an so on. Check the `foreman` documentation for more info.
|
110
|
+
|
111
|
+
## Specs
|
112
|
+
|
113
|
+
To run the specs, it is necessary to prepare the dummy sandbox directory after the first clone of the repository.
|
114
|
+
|
115
|
+
There is a `rake` task to do it:
|
116
|
+
|
117
|
+
$ bundle exec rake spec:prepare
|
118
|
+
|
119
|
+
After this, you can run the specs:
|
120
|
+
|
121
|
+
$ bundle exec rake spec
|
122
|
+
|
123
|
+
## About the name
|
124
|
+
|
125
|
+
*Izanami* is the name of the japanese goddess of both creation and death. Find out more about this at [wikipedia](http://en.wikipedia.org/wiki/Izanami).
|
126
|
+
|
127
|
+
## Contributing
|
128
|
+
|
129
|
+
1. Fork it
|
130
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
131
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
132
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
133
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'open3'
|
4
|
+
|
5
|
+
Rake::TestTask.new do |t|
|
6
|
+
t.pattern = 'spec/**/*_spec.rb'
|
7
|
+
end
|
8
|
+
|
9
|
+
namespace :spec do
|
10
|
+
desc 'prepare the spec environment, initializing the sandbox dir'
|
11
|
+
task :prepare do
|
12
|
+
$stdout.puts '===> Initializing `spec/sandbox` directory with bundler'
|
13
|
+
|
14
|
+
# remove bundler env vars for the Open3 process.
|
15
|
+
bundler_keys = ENV.select { |var, _| var.to_s.match(/\ABUNDLE/) }.keys
|
16
|
+
env = bundler_keys.reduce({}) do |hash, (k,_)|
|
17
|
+
hash[k] = nil
|
18
|
+
hash
|
19
|
+
end
|
20
|
+
|
21
|
+
options = { chdir: 'spec/sandbox'}
|
22
|
+
Open3.popen2e(env, 'bundle install', options) do |stdin, stdout, thread|
|
23
|
+
while line = stdout.gets
|
24
|
+
$stdout.puts line.chomp
|
25
|
+
end
|
26
|
+
|
27
|
+
stdin.close
|
28
|
+
stdout.close
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
task spec: [:test]
|
33
|
+
|
34
|
+
task default: [:test]
|
data/assets/css/app.css
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
body { padding-top: 70px; }
|