puppet-herald 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -7
- data/.rubocop.yml +31 -0
- data/.rubocop_todo.yml +6 -0
- data/.travis.yml +7 -7
- data/Gemfile +5 -9
- data/README.md +152 -16
- data/Rakefile +67 -6
- data/bin/puppet-herald +1 -1
- data/config.ru +2 -2
- data/db/migrate/20141211165540_create_nodes.rb +5 -3
- data/db/migrate/20141211171305_create_reports.rb +12 -10
- data/db/migrate/20141211171326_create_log_entries.rb +9 -7
- data/db/schema.rb +24 -26
- data/lib/puppet-herald.rb +59 -21
- data/lib/puppet-herald/app/api.rb +111 -0
- data/lib/puppet-herald/app/configuration.rb +70 -0
- data/lib/puppet-herald/app/frontend.rb +61 -0
- data/lib/puppet-herald/{views → app/views}/app.erb +5 -8
- data/lib/puppet-herald/{views → app/views}/err500.erb +1 -4
- data/lib/puppet-herald/application.rb +27 -0
- data/lib/puppet-herald/cli.rb +66 -45
- data/lib/puppet-herald/client.rb +33 -0
- data/lib/puppet-herald/database.rb +84 -40
- data/lib/puppet-herald/javascript.rb +23 -17
- data/lib/puppet-herald/models/log-entry.rb +10 -3
- data/lib/puppet-herald/models/node.rb +15 -5
- data/lib/puppet-herald/models/report.rb +70 -63
- data/lib/puppet-herald/public/app.js +9 -8
- data/lib/puppet-herald/public/components/directives/status-button.html +1 -1
- data/lib/puppet-herald/public/components/directives/status-button.js +5 -3
- data/lib/puppet-herald/public/components/filters/filters.js +9 -4
- data/lib/puppet-herald/public/components/page.js +34 -0
- data/lib/puppet-herald/public/node/node.html +3 -1
- data/lib/puppet-herald/public/node/node.js +7 -4
- data/lib/puppet-herald/public/nodes/nodes.js +3 -2
- data/lib/puppet-herald/public/report/report.html +4 -1
- data/lib/puppet-herald/public/report/report.js +5 -3
- data/lib/puppet-herald/stubs/puppet.rb +20 -9
- data/lib/puppet-herald/version.rb +17 -7
- data/package.json +8 -3
- data/puppet-herald.gemspec +3 -6
- data/spec/integration/application_spec.rb +175 -0
- data/spec/integration/models/node_spec.rb +4 -4
- data/spec/integration/models/report_spec.rb +7 -7
- data/spec/spec_helper.rb +12 -7
- data/spec/support/active_record.rb +6 -10
- data/spec/support/reconnectdb.rb +13 -0
- data/spec/unit/puppet-herald/cli_spec.rb +45 -13
- data/spec/unit/puppet-herald/client_spec.rb +23 -0
- data/spec/unit/puppet-herald/database_spec.rb +8 -9
- data/spec/unit/puppet-herald/javascript_spec.rb +8 -13
- data/spec/unit/puppet-herald_spec.rb +4 -4
- data/test/javascript/karma.conf.js +43 -5
- data/test/javascript/src/app_test.js +90 -0
- data/test/javascript/src/components/artifact/artifact-directive_test.js +36 -0
- data/test/javascript/src/components/artifact/artifact_test.js +64 -0
- data/test/javascript/src/components/directives/status-button_test.js +159 -0
- data/test/javascript/src/components/filters/filters_test.js +35 -0
- data/test/javascript/src/node/node_test.js +87 -0
- data/test/javascript/src/nodes/nodes_test.js +56 -0
- data/test/javascript/src/report/report_test.js +94 -0
- metadata +98 -68
- data/lib/puppet-herald/app.rb +0 -103
- data/lib/puppet-herald/public/components/artifact/artifact-directive_test.js +0 -17
- data/spec/integration/app_spec.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NWQxYTc4MjVkZGQ2NzM5MTk4ZTUxNDUzY2I5MzYzMjMwNDA0ZTk0Ng==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZTdkYTA0MDU0OWM1ZGRhZTZmZTg0NzUzOTkzOWE3MTE4NjA0Y2IyNw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NDhjYTZiNDkyN2M0YzFlZWNkMzkwOGU4NTUzYjc1MDA0MDFjNjY5MzI0M2Q2
|
10
|
+
ZjhhYWVhMmMxOTNkM2Q1MzM0OWU5YWYyYzIyMGVkYmNjM2NiNGFiMDFlMTQ2
|
11
|
+
MGMxMjVjODY0N2JjZDU4ZGRlNzliNDk3MmFjNTVkYjg3NWJkYzQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MDRjOGZkMGFmZmU2ZWUyMWFiYzJkZGNjMWI1YmNhNGI0ODVmYzgzNDQ3M2Vj
|
14
|
+
YjUxNWM2YWQzYzY1ZjIwMWYxOTBmYWVkOWFhMzcwMWM4Mzk5NDE4MzJmYWMw
|
15
|
+
NjBhZTRiMjliNzE4ODg5NzU2NjhkMWUyMGZiYzExNTQxMDdjMmU=
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# This is the configuration used to check the rubocop source code.
|
2
|
+
|
3
|
+
inherit_from: .rubocop_todo.yml
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
Include:
|
7
|
+
- 'lib/**/*.rb'
|
8
|
+
- 'db/**/*.rb'
|
9
|
+
- 'bin/*'
|
10
|
+
- 'Rakefile'
|
11
|
+
- 'Gemfile'
|
12
|
+
- 'puppet-herald.gemspec'
|
13
|
+
- 'config.ru'
|
14
|
+
Exclude:
|
15
|
+
- '.**/*'
|
16
|
+
- 'test/**/*'
|
17
|
+
- 'spec/**/*'
|
18
|
+
- 'node_modules/**/*'
|
19
|
+
- 'coverage/**/*'
|
20
|
+
- '.vendor/**/*'
|
21
|
+
- 'vendor/**/*'
|
22
|
+
- '.bundle/**/*'
|
23
|
+
|
24
|
+
Metrics/LineLength:
|
25
|
+
Max: 120
|
26
|
+
|
27
|
+
Metrics/MethodLength:
|
28
|
+
Max: 15
|
29
|
+
|
30
|
+
Metrics/AbcSize:
|
31
|
+
Max: 20
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2014-12-17 02:10:52 +0100 using RuboCop version 0.28.0.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
data/.travis.yml
CHANGED
@@ -3,15 +3,15 @@ language: ruby
|
|
3
3
|
bundler_args: --without development
|
4
4
|
script:
|
5
5
|
- bundle exec rake test
|
6
|
-
# - ./node_modules/karma/bin/karma start --single-run --browsers PhantomJS test/javascript/karma.conf.js
|
7
6
|
before_install: rm -f Gemfile.lock
|
8
7
|
before_script:
|
9
8
|
- npm install
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
-
|
14
|
-
|
15
|
-
-
|
9
|
+
rvm:
|
10
|
+
- 1.9.3
|
11
|
+
- 2.0.0
|
12
|
+
- 2.1.0
|
13
|
+
env:
|
14
|
+
- PUPPET_HERALD_ENV=production
|
15
|
+
- PUPPET_HERALD_ENV=development
|
16
16
|
notifications:
|
17
17
|
email: false
|
data/Gemfile
CHANGED
@@ -1,30 +1,26 @@
|
|
1
|
-
source ENV['GEM_SOURCE'] ||
|
1
|
+
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
group :test do
|
6
|
-
|
7
6
|
gem 'rake', '~> 10.4'
|
8
7
|
gem 'rspec', '~> 3.1'
|
9
8
|
gem 'rspec-its', '~> 1.1'
|
9
|
+
gem 'webmock', '~> 1.20'
|
10
10
|
gem 'coveralls', '~> 0.7'
|
11
11
|
gem 'simplecov', '~> 0.9'
|
12
12
|
gem 'sqlite3', '~> 1.3'
|
13
|
-
|
13
|
+
gem 'rubocop', '~> 0.28'
|
14
14
|
end
|
15
15
|
|
16
16
|
group :development do
|
17
|
-
|
18
17
|
gem 'inch', '~> 0.5'
|
19
18
|
gem 'travis', '~> 1.6'
|
20
19
|
gem 'pry-byebug', '~> 2.0' if RUBY_VERSION >= '2.0.0'
|
21
20
|
gem 'pry-debugger', '~> 0.2' if RUBY_VERSION < '2.0.0'
|
22
|
-
|
23
21
|
end
|
24
22
|
|
25
|
-
local_gemfile = File.join(File.dirname(__FILE__),
|
26
|
-
if File.
|
27
|
-
eval_gemfile local_gemfile
|
28
|
-
end
|
23
|
+
local_gemfile = File.join(File.dirname(__FILE__), 'Gemfile.local')
|
24
|
+
eval_gemfile local_gemfile if File.exist?(local_gemfile)
|
29
25
|
|
30
26
|
# vim:ft=ruby
|
data/README.md
CHANGED
@@ -22,23 +22,18 @@ Herald is a puppet report processor. He provides a gateway for consuming puppet
|
|
22
22
|
Puppet module
|
23
23
|
-----
|
24
24
|
|
25
|
-
There is/will be a puppet module that handle installation and configuration of Herald and prerequisites.
|
25
|
+
There is/will be a puppet module that handle installation and configuration of Herald and prerequisites. Installing configuring and running with puppet is recommended. If you decided to take that approch check out: https://github.com/wavesoftware/puppet-herald
|
26
26
|
|
27
|
-
|
28
|
-
-----
|
29
|
-
|
30
|
-
* `libpq-dev`
|
27
|
+
Installation, configuration and usage point seen below does not apply to installing with puppet!
|
31
28
|
|
32
|
-
On Ubuntu/Debian system install them with:
|
33
|
-
|
34
|
-
```shell
|
35
|
-
sudo apt-get install libpq-dev
|
36
|
-
```
|
37
29
|
|
38
30
|
Installation
|
39
31
|
-----
|
40
32
|
|
41
|
-
|
33
|
+
Herald typically should be installed on the same node or in management network of your puppet master. It will listen by default to localhost (this can be changed by `--bind` option). You should take care to properlly secure Herald if its publicly avialable (SSL, Authorization, Access List, Firewalls etc.). This could be easily done with Apache web server. Is approch is taken in puppet module (see above).
|
34
|
+
|
35
|
+
If you decided to install Herald by yourself, issue just:
|
36
|
+
|
42
37
|
```shell
|
43
38
|
sudo gem install puppet-herald
|
44
39
|
```
|
@@ -46,13 +41,30 @@ sudo gem install puppet-herald
|
|
46
41
|
Configuration
|
47
42
|
-----
|
48
43
|
|
49
|
-
|
44
|
+
###PostgreSQL
|
45
|
+
|
46
|
+
PostgreSQL is recommended database backend for Herald. If you like to use PostgreSQL database to hold reports, you will need to configure it. By default, Herald will use a sqlite file that he tries to create in your home directory. Check out `puppet-herald --help` for description.
|
47
|
+
|
48
|
+
###Prerequisites for PostgreSQL
|
49
|
+
|
50
|
+
* `libpq-dev` system package
|
51
|
+
* `pg` gem package
|
52
|
+
|
53
|
+
On Ubuntu/Debian system install them with:
|
54
|
+
|
55
|
+
```shell
|
56
|
+
sudo apt-get install libpq-dev
|
57
|
+
sudo gem install pg
|
58
|
+
```
|
50
59
|
|
51
60
|
###Create a database
|
52
61
|
|
53
|
-
Just create a database for Herald (this is just a sample):
|
62
|
+
Just create a database for Herald (this is just a sample for PostgreSQL):
|
63
|
+
|
54
64
|
```sql
|
55
|
-
CREATE ROLE pherald LOGIN PASSWORD '<YOUR PASSWORD>'
|
65
|
+
CREATE ROLE pherald LOGIN PASSWORD '<YOUR PASSWORD>'
|
66
|
+
NOSUPERUSER INHERIT NOCREATEDB
|
67
|
+
NOCREATEROLE NOREPLICATION;
|
56
68
|
CREATE DATABASE "pherald" WITH OWNER = pherald
|
57
69
|
ENCODING = 'UTF8'
|
58
70
|
TABLESPACE = pg_default;
|
@@ -65,10 +77,134 @@ Usage
|
|
65
77
|
$ puppet-herald --help
|
66
78
|
```
|
67
79
|
|
68
|
-
Example of
|
80
|
+
Example usage of Herald with defaults:
|
81
|
+
|
82
|
+
```shell
|
83
|
+
puppet-herald # Navigate to http://localhost:11303/
|
84
|
+
```
|
85
|
+
|
86
|
+
Example usage of Herald with PostgreSQL and binding 127.0.1.1:
|
87
|
+
|
88
|
+
```shell
|
89
|
+
puppet-herald \
|
90
|
+
--dbconn postgresql://pherald@master.cluster.vm:5432/pherald \
|
91
|
+
--passfile /etc/pherald/passfile \
|
92
|
+
--bind 127.0.1.1 # Navigate to http://127.0.1.1:11303/
|
93
|
+
```
|
94
|
+
|
95
|
+
Example usage of Herald with SQLite3 and binding to other host and port:
|
96
|
+
|
97
|
+
```shell
|
98
|
+
puppet-herald \
|
99
|
+
--dbconn sqlite:///var/lib/puppet/reports/pherald.db \
|
100
|
+
--bind master.cluster.vm \
|
101
|
+
--port 8081 # Navigate to http://master.cluster.vm:8081/
|
102
|
+
```
|
103
|
+
|
104
|
+
Configuring puppet master
|
105
|
+
-------------------------
|
106
|
+
|
107
|
+
To send reports to Herald, you need to configure your puppet master to use custom report proccessor. This processor is also automatically configured if you choose to use a puppet module installation version. If not you must configure it by yourself.
|
108
|
+
|
109
|
+
First install a puppet-herald gem if you didn't do it already on puppet master:
|
110
|
+
|
111
|
+
```shell
|
112
|
+
sudo gem install puppet-herald
|
113
|
+
```
|
114
|
+
|
115
|
+
If you are running PE, run instead:
|
116
|
+
|
117
|
+
```shell
|
118
|
+
sudo /opt/puppet/bin/gem install puppet-herald
|
119
|
+
```
|
120
|
+
|
121
|
+
Then create a file in your puppet module directory (you can get modulepath with command: `puppet config print modulepath`). For example: `<puppet modules>/herald/lib/puppet/reports/herald.rb` with contents:
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
require 'puppet'
|
125
|
+
require 'puppet-herald/client'
|
126
|
+
|
127
|
+
Puppet::Reports.register_report(:herald) do
|
128
|
+
desc "Process reports via the Herald API."
|
129
|
+
def process
|
130
|
+
PuppetHerald::Client.new.process(self)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
```
|
134
|
+
|
135
|
+
If you need to post to other host or port use (defaults are: `localhost` and `11303`):
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
require 'puppet'
|
139
|
+
require 'puppet-herald/client'
|
140
|
+
|
141
|
+
Puppet::Reports.register_report(:herald) do
|
142
|
+
desc "Process reports via the Herald API."
|
143
|
+
def process
|
144
|
+
PuppetHerald::Client.new('master.secure.vm', 8082).process(self)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
```
|
148
|
+
|
149
|
+
Then edit your `puppet.conf` file and set `herald` as your report processor in section `main`:
|
150
|
+
|
151
|
+
```ini
|
152
|
+
[main]
|
153
|
+
reports = puppetdb,herald
|
154
|
+
```
|
155
|
+
|
156
|
+
###Testing a ruby code
|
157
|
+
|
158
|
+
There are two types of tests distributed with the module. Unit tests and integration tests that uses sqlite as database backend in memory.
|
159
|
+
|
160
|
+
For unit testing, make sure you have:
|
161
|
+
|
162
|
+
* rake
|
163
|
+
* bundler
|
164
|
+
|
165
|
+
Install the necessary gems (gems will be downloaded to private .vendor directory):
|
166
|
+
|
167
|
+
```shell
|
168
|
+
bundle install --path .vendor
|
169
|
+
```
|
170
|
+
|
171
|
+
And then run the unit tests (for integration tests simply swap `unit` to `integration`):
|
172
|
+
|
173
|
+
```shell
|
174
|
+
bundle exec rake spec:unit
|
175
|
+
```
|
176
|
+
|
177
|
+
You can run single test with:
|
178
|
+
|
179
|
+
```shell
|
180
|
+
bundle exec rspec spec/unit/puppet-herald/version_spec.rb
|
181
|
+
```
|
182
|
+
|
183
|
+
You can also run all test with `test` target
|
184
|
+
|
185
|
+
###Testing a javascript code
|
186
|
+
|
187
|
+
To test javascript code, make sure you have:
|
188
|
+
|
189
|
+
* nodejs
|
190
|
+
|
191
|
+
If so, issue this command to bootstart testing environment:
|
192
|
+
|
193
|
+
```shell
|
194
|
+
npm install
|
195
|
+
```
|
196
|
+
|
197
|
+
And then test Javascript code with:
|
198
|
+
|
199
|
+
```shell
|
200
|
+
bundle exec rake js
|
201
|
+
```
|
202
|
+
|
203
|
+
Check your code for quality with:
|
69
204
|
|
70
205
|
```shell
|
71
|
-
|
206
|
+
bundle exec rake rucocop
|
207
|
+
bundle exec rake inch
|
72
208
|
```
|
73
209
|
|
74
210
|
###Contributing
|
data/Rakefile
CHANGED
@@ -1,13 +1,74 @@
|
|
1
1
|
|
2
2
|
require 'sinatra/activerecord/rake'
|
3
3
|
require 'rspec/core/rake_task'
|
4
|
+
require 'rubocop/rake_task'
|
5
|
+
require 'rubocop'
|
6
|
+
require 'fileutils'
|
4
7
|
|
5
|
-
|
6
|
-
|
8
|
+
namespace :spec do
|
9
|
+
desc 'Run all spec tests at once.'
|
10
|
+
RSpec::Core::RakeTask.new(:all)
|
7
11
|
|
8
|
-
desc
|
9
|
-
|
10
|
-
|
12
|
+
desc 'Run unit spec tests.'
|
13
|
+
RSpec::Core::RakeTask.new(:unit) do |t|
|
14
|
+
t.pattern = [
|
15
|
+
'spec/unit'
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'Run integration spec tests.'
|
20
|
+
RSpec::Core::RakeTask.new(:integration) do |t|
|
21
|
+
t.pattern = [
|
22
|
+
'spec/zzz_integration'
|
23
|
+
]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Run javascript Jasmine/Karma tests on PhantomJS.'
|
28
|
+
task :js do
|
29
|
+
FileUtils.rm_rf 'coverage/javascript'
|
30
|
+
sh 'node_modules/karma/bin/karma start --browsers PhantomJS test/javascript/karma.conf.js'
|
31
|
+
path = Pathname.glob('coverage/javascript/PhantomJS*/text.txt').first
|
32
|
+
puts 'Coverage for Javascript:'
|
33
|
+
puts File.read(path)
|
34
|
+
end
|
35
|
+
|
36
|
+
tests = [
|
37
|
+
:'spec:all',
|
38
|
+
:js,
|
39
|
+
:rubocop
|
11
40
|
]
|
12
41
|
|
13
|
-
|
42
|
+
begin
|
43
|
+
require 'inch/rake'
|
44
|
+
Inch::Rake::Suggest.new :inch, '--pedantic'
|
45
|
+
tests << :inch
|
46
|
+
rescue LoadError # rubocop:disable all
|
47
|
+
# nothing here
|
48
|
+
end
|
49
|
+
|
50
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
51
|
+
# don't abort rake on failure
|
52
|
+
task.fail_on_error = true
|
53
|
+
end
|
54
|
+
|
55
|
+
namespace :rubocop do
|
56
|
+
namespace :todo do
|
57
|
+
desc 'Cleans a rubocop TODO list'
|
58
|
+
task :clean do
|
59
|
+
File.write('.rubocop_todo.yml', '')
|
60
|
+
Rake::Task[:rubocop].execute
|
61
|
+
end
|
62
|
+
|
63
|
+
desc 'Saves actual rubocop state into TODO list'
|
64
|
+
task :save do
|
65
|
+
rcli = RuboCop::CLI.new
|
66
|
+
rcli.run ['--auto-gen-config']
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
desc 'Run lint, and all spec tests.'
|
72
|
+
task test: tests
|
73
|
+
|
74
|
+
task default: :test
|
data/bin/puppet-herald
CHANGED
data/config.ru
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require 'puppet-herald/
|
2
|
-
run PuppetHerald::
|
1
|
+
require 'puppet-herald/application'
|
2
|
+
run PuppetHerald::Application
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# Migration
|
1
2
|
class CreateNodes < ActiveRecord::Migration
|
3
|
+
# Migration
|
2
4
|
def change
|
3
5
|
create_table :nodes do |t|
|
4
|
-
t.string
|
5
|
-
t.string
|
6
|
-
t.integer
|
6
|
+
t.string :name
|
7
|
+
t.string :status
|
8
|
+
t.integer :no_of_reports
|
7
9
|
t.datetime :last_run
|
8
10
|
end
|
9
11
|
end
|
@@ -1,16 +1,18 @@
|
|
1
|
+
# Migration
|
1
2
|
class CreateReports < ActiveRecord::Migration
|
3
|
+
# Migration
|
2
4
|
def change
|
3
5
|
create_table :reports do |t|
|
4
|
-
t.string
|
5
|
-
t.string
|
6
|
-
t.string
|
7
|
-
t.string
|
8
|
-
t.string
|
9
|
-
t.string
|
10
|
-
t.string
|
11
|
-
t.datetime
|
12
|
-
|
13
|
-
t.references
|
6
|
+
t.string :status
|
7
|
+
t.string :environment
|
8
|
+
t.string :transaction_uuid
|
9
|
+
t.string :configuration_version
|
10
|
+
t.string :puppet_version
|
11
|
+
t.string :kind
|
12
|
+
t.string :host
|
13
|
+
t.datetime :time
|
14
|
+
|
15
|
+
t.references :node
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|