-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun.rb
More file actions
71 lines (62 loc) · 1.2 KB
/
Copy pathrun.rb
File metadata and controls
71 lines (62 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
require 'sinatra'
require 'ansible-wrapper'
set server: 'thin'
set :environment, :production
set :bind, '0.0.0.0'
set :port, 4567
Process.setproctitle 'Ansible Streaming Example'
CONSOLE_OUTPUT_START = %{<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<style>
body {
background-color: #{background ||= 'black'}; color: #{color ||= 'white'};
}
.bold {
font-weight: bold;
}
.black {
color: black;
}
.red {
color: red;
}
.green {
color: green;
}
.yellow {
color: yellow;
}
.blue {
color: blue;
}
.magenta {
color: magenta;
}
.cyan {
color: cyan;
}
.white {
color: white;
}
.grey {
color: grey;
}
</style>
</head>
<body><pre><code>}
CONSOLE_OUTPUT_END = '</code></pre></body></html>'
get '/' do
"Ansible #{Ansible::Config::VERSION}"
end
get '/streaming' do
#content_type 'text/plain'
stream do |out|
out << CONSOLE_OUTPUT_START
Ansible.stream ['-i', 'localhost,', File.expand_path('../../../spec/fixtures/mock_playbook.yml', __FILE__)]*' ' do |line|
Ansible::Output.to_html line, out
end
out << CONSOLE_OUTPUT_END
end
end