inventory-server 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +3 -0
- data/.travis.yml +12 -0
- data/Dockerfile +22 -0
- data/Dockerfile-passenger +18 -0
- data/Dockerfile-unicorn +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +2 -0
- data/bin/inventory-server +33 -0
- data/circle.yml +26 -0
- data/config.ru +8 -0
- data/docker/passenger/passenger.conf +15 -0
- data/docker/passenger/run-httpd.sh +8 -0
- data/docker/unicorn/nginx.conf +45 -0
- data/docker/unicorn/run-unicorn.sh +5 -0
- data/docker/unicorn/unicorn.conf +31 -0
- data/docker/unicorn/unicorn.rb +19 -0
- data/fig.yml +18 -0
- data/inventory-server.gemspec +45 -0
- data/lib/inventory/server.rb +30 -0
- data/lib/inventory/server/cli.rb +59 -0
- data/lib/inventory/server/config.rb +80 -0
- data/lib/inventory/server/email_parser.rb +28 -0
- data/lib/inventory/server/http_server.rb +49 -0
- data/lib/inventory/server/inventory_error.rb +9 -0
- data/lib/inventory/server/loader.rb +60 -0
- data/lib/inventory/server/logger.rb +16 -0
- data/lib/inventory/server/smtp_server.rb +36 -0
- data/lib/inventory/server/version.rb +5 -0
- data/plugins/facts_parser.rb +95 -0
- data/plugins/index.rb +56 -0
- data/plugins/json_schema_validator.rb +33 -0
- data/plugins/log_failures_on_disk.rb +35 -0
- data/public/.gitignore +0 -0
- data/spec/integration/fixtures/facter.xml +4543 -0
- data/spec/integration/http_spec.rb +24 -0
- data/spec/spec_helper.rb +96 -0
- data/spec/unit/cli_spec.rb +54 -0
- data/spec/unit/config_spec.rb +65 -0
- data/spec/unit/email_parser_spec.rb +53 -0
- data/spec/unit/facts_parser_spec.rb +176 -0
- data/spec/unit/fixtures/simple_plugin.rb +2 -0
- data/spec/unit/http_server_spec.rb +58 -0
- data/spec/unit/index_spec.rb +77 -0
- data/spec/unit/json_schema_validator_spec.rb +126 -0
- data/spec/unit/loader_spec.rb +34 -0
- data/spec/unit/log_failures_on_disk_spec.rb +50 -0
- data/spec/unit/server_spec.rb +11 -0
- data/spec/unit/smtp_server_spec.rb +68 -0
- data/tmp/.gitignore +0 -0
- metadata +434 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 34cbc8d1572c70edb39377ffa1981fea38a03a21
|
4
|
+
data.tar.gz: 423f3ca495ed66887c283618484ce7e1ad9baefa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d73c6ac09d52200f1bd0b332a7e15fdfdd7e79947dec8d1fb3593781a01955834033f8ba03e1086a7a576281fc0eff309a710c6bbb15403c810e12c26f0001ae
|
7
|
+
data.tar.gz: 458a1968d101447e15b1dab21d3ade878d720df78975025a60fde4ae268ce429cc1e6723ae10c98288a29930aadaba7cc738665aed62c6bc163832f5a1660083
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Dockerfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
FROM centos
|
2
|
+
MAINTAINER Filirom1 <filirom1@gmail.com>
|
3
|
+
|
4
|
+
ADD . /app
|
5
|
+
|
6
|
+
RUN yum install -y epel-release
|
7
|
+
RUN yum install -y patch tar git ruby ruby-devel rubygem-bundler make gcc gcc-c++ zlib-devel libxml2-devel nginx
|
8
|
+
|
9
|
+
RUN cd /app && bundle install
|
10
|
+
|
11
|
+
RUN cp /app/docker/unicorn/unicorn.conf /etc/nginx/conf.d/unicorn.conf && \
|
12
|
+
cp /app/docker/unicorn/nginx.conf /etc/nginx/nginx.conf && \
|
13
|
+
echo "daemon off;" >> /etc/nginx/nginx.conf
|
14
|
+
|
15
|
+
RUN mkdir -p /var/log/inventory && chmod o+rwX /var/log/inventory && \
|
16
|
+
mkdir -p /var/lib/inventory/ && chmod o+rwX /var/lib/inventory && \
|
17
|
+
mkdir -p /var/run/inventory/ && chmod o+rwX /var/run/inventory
|
18
|
+
|
19
|
+
VOLUME ["/var/log/nginx", "/var/log/inventory"]
|
20
|
+
|
21
|
+
EXPOSE 80
|
22
|
+
CMD ["/app/docker/unicorn/run-unicorn.sh"]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
FROM centos
|
2
|
+
MAINTAINER Filirom1 <filirom1@gmail.com>
|
3
|
+
|
4
|
+
ADD . /app
|
5
|
+
|
6
|
+
RUN yum install -y epel-release
|
7
|
+
RUN yum install -y patch tar git ruby ruby-devel rubygem-bundler make gcc gcc-c++ zlib-devel libxml2-devel httpd \
|
8
|
+
http://puias.math.ias.edu/data/puias/unsupported/7/x86_64/mod_passenger-4.0.18-9.5.sdl7.x86_64.rpm \
|
9
|
+
http://puias.math.ias.edu/data/puias/unsupported/7/x86_64/rubygem-passenger-4.0.18-9.5.sdl7.x86_64.rpm \
|
10
|
+
http://puias.math.ias.edu/data/puias/unsupported/7/x86_64/rubygem-passenger-native-4.0.18-9.5.sdl7.x86_64.rpm \
|
11
|
+
http://puias.math.ias.edu/data/puias/unsupported/7/x86_64/rubygem-passenger-native-libs-4.0.18-9.5.sdl7.x86_64.rpm
|
12
|
+
|
13
|
+
RUN cd /app && bundle install
|
14
|
+
RUN cp /app/docker/passenger/passenger.conf /etc/httpd/conf.d/passenger.conf
|
15
|
+
RUN mkdir -p /var/log/inventory && chmod o+rwX /var/log/inventory
|
16
|
+
|
17
|
+
EXPOSE 80
|
18
|
+
CMD ["/app/docker/passenger/run-httpd.sh"]
|
data/Dockerfile-unicorn
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
FROM centos
|
2
|
+
MAINTAINER Filirom1 <filirom1@gmail.com>
|
3
|
+
|
4
|
+
ADD . /app
|
5
|
+
|
6
|
+
RUN yum install -y epel-release
|
7
|
+
RUN yum install -y patch tar git ruby ruby-devel rubygem-bundler make gcc gcc-c++ zlib-devel libxml2-devel nginx
|
8
|
+
|
9
|
+
RUN cd /app && bundle install
|
10
|
+
|
11
|
+
RUN cp /app/docker/unicorn/unicorn.conf /etc/nginx/conf.d/unicorn.conf && \
|
12
|
+
cp /app/docker/unicorn/nginx.conf /etc/nginx/nginx.conf && \
|
13
|
+
echo "daemon off;" >> /etc/nginx/nginx.conf
|
14
|
+
|
15
|
+
RUN mkdir -p /var/log/inventory && chmod o+rwX /var/log/inventory && \
|
16
|
+
mkdir -p /var/lib/inventory/ && chmod o+rwX /var/lib/inventory && \
|
17
|
+
mkdir -p /var/run/inventory/ && chmod o+rwX /var/run/inventory
|
18
|
+
|
19
|
+
VOLUME ["/var/log/nginx", "/var/log/inventory"]
|
20
|
+
|
21
|
+
EXPOSE 80
|
22
|
+
CMD ["/app/docker/unicorn/run-unicorn.sh"]
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Filirom1
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Inventory::Server [![Build Status](https://travis-ci.org/Filirom1/inventory.svg?branch=master)](https://travis-ci.org/Filirom1/inventory) [![Code Climate](https://codeclimate.com/github/Filirom1/inventory/badges/gpa.svg)](https://codeclimate.com/github/Filirom1/inventory) [![Test Coverage](https://codeclimate.com/github/Filirom1/inventory/badges/coverage.svg)](https://codeclimate.com/github/Filirom1/inventory)
|
2
|
+
|
3
|
+
Inventory server store and index data sent from the agent
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install `postfix` with the following configuration
|
8
|
+
|
9
|
+
mydestination = $myhostname, localhost.$mydomain, localhost
|
10
|
+
relay_domains = $mydestination
|
11
|
+
relayhost = 127.0.0.1:2525
|
12
|
+
|
13
|
+
Install ElasticSearch
|
14
|
+
|
15
|
+
Install ruby and bundler
|
16
|
+
|
17
|
+
Then
|
18
|
+
|
19
|
+
bundle install
|
20
|
+
bundle exec ruby smtp_server.rb
|
21
|
+
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it ( https://github.com/[my-github-username]/inventory-server/fork )
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'inventory/server'
|
4
|
+
require 'inventory/server/cli'
|
5
|
+
require 'inventory/server/logger'
|
6
|
+
require 'inventory/server/smtp_server'
|
7
|
+
|
8
|
+
cli_options = Inventory::Server::CLI.new().parse! ARGV
|
9
|
+
|
10
|
+
server = Inventory::Server::Server.new(cli_options)
|
11
|
+
options = server.config
|
12
|
+
|
13
|
+
Inventory::Server::InventoryLogger.logger.info "SMTP Server started, listening on #{options[:host]}:#{options[:smtp_port]}"
|
14
|
+
|
15
|
+
smtp_server = Inventory::Server::SMTPServer.new(options, server.middlewares)
|
16
|
+
smtp_server.start
|
17
|
+
smtp_server.join
|
18
|
+
|
19
|
+
BEGIN {
|
20
|
+
at_exit {
|
21
|
+
if smtp_server
|
22
|
+
Inventory::Server::InventoryLogger.logger.info "Server is shutting down gracefully"
|
23
|
+
smtp_server.shutdown()
|
24
|
+
|
25
|
+
unless smtp_server.connections == 0
|
26
|
+
Inventory::Server::InventoryLogger.logger.info "Still #{smtp_server.connections} connections, wait 1 seconds"
|
27
|
+
sleep 1
|
28
|
+
end
|
29
|
+
|
30
|
+
smtp_server.stop
|
31
|
+
end
|
32
|
+
}
|
33
|
+
}
|
data/circle.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
machine:
|
2
|
+
services:
|
3
|
+
- docker
|
4
|
+
|
5
|
+
dependencies:
|
6
|
+
override:
|
7
|
+
- sudo curl -o /usr/local/bin/fig -L https://github.com/docker/fig/releases/download/1.0.1/fig-`uname -s`-`uname -m`
|
8
|
+
- sudo chmod +x /usr/local/bin/fig
|
9
|
+
- fig build
|
10
|
+
|
11
|
+
database:
|
12
|
+
override:
|
13
|
+
- /bin/true
|
14
|
+
|
15
|
+
test:
|
16
|
+
override:
|
17
|
+
- fig up -d
|
18
|
+
- fig run web cd /app && bundle install
|
19
|
+
- fig run web cd /app && bundle exec rspec spec
|
20
|
+
- fig run web cd /app && bundle exec rspec spec --tag integration
|
21
|
+
|
22
|
+
deployment:
|
23
|
+
prod:
|
24
|
+
branch: master
|
25
|
+
commands:
|
26
|
+
- curl --data "build=true" -X POST https://registry.hub.docker.com/u/filirom1/inventory/trigger/$DOCKER_HUB_TOKEN/
|
data/config.ru
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'inventory/server'
|
3
|
+
require 'inventory/server/http_server'
|
4
|
+
|
5
|
+
server = Inventory::Server::Server.new({})
|
6
|
+
Inventory::Server::HTTPServer.set :config, server.config
|
7
|
+
Inventory::Server::HTTPServer.set :middlewares, server.middlewares
|
8
|
+
run Inventory::Server::HTTPServer
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<IfModule mod_passenger.c>
|
2
|
+
PassengerRoot /usr/share/gems/gems/passenger-4.0.18/lib/phusion_passenger/locations.ini
|
3
|
+
PassengerRuby /usr/bin/ruby
|
4
|
+
</IfModule>
|
5
|
+
|
6
|
+
<VirtualHost *:80>
|
7
|
+
ServerName localhost
|
8
|
+
DocumentRoot /app/public
|
9
|
+
<Directory /app/public>
|
10
|
+
Require all granted
|
11
|
+
Allow from all
|
12
|
+
Options -MultiViews
|
13
|
+
</Directory>
|
14
|
+
</VirtualHost>
|
15
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# For more information on configuration, see:
|
2
|
+
# * Official English Documentation: http://nginx.org/en/docs/
|
3
|
+
# * Official Russian Documentation: http://nginx.org/ru/docs/
|
4
|
+
|
5
|
+
user nginx;
|
6
|
+
worker_processes 1;
|
7
|
+
|
8
|
+
error_log /var/log/nginx/error.log;
|
9
|
+
#error_log /var/log/nginx/error.log notice;
|
10
|
+
#error_log /var/log/nginx/error.log info;
|
11
|
+
|
12
|
+
pid /run/nginx.pid;
|
13
|
+
|
14
|
+
|
15
|
+
events {
|
16
|
+
worker_connections 1024;
|
17
|
+
}
|
18
|
+
|
19
|
+
|
20
|
+
http {
|
21
|
+
include /etc/nginx/mime.types;
|
22
|
+
default_type application/octet-stream;
|
23
|
+
|
24
|
+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
25
|
+
'$status $body_bytes_sent "$http_referer" '
|
26
|
+
'"$http_user_agent" "$http_x_forwarded_for"';
|
27
|
+
|
28
|
+
access_log /var/log/nginx/access.log main;
|
29
|
+
|
30
|
+
sendfile on;
|
31
|
+
#tcp_nopush on;
|
32
|
+
|
33
|
+
#keepalive_timeout 0;
|
34
|
+
keepalive_timeout 65;
|
35
|
+
|
36
|
+
#gzip on;
|
37
|
+
|
38
|
+
index index.html index.htm;
|
39
|
+
|
40
|
+
# Load modular configuration files from the /etc/nginx/conf.d directory.
|
41
|
+
# See http://nginx.org/en/docs/ngx_core_module.html#include
|
42
|
+
# for more information.
|
43
|
+
include /etc/nginx/conf.d/*.conf;
|
44
|
+
}
|
45
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# use the socket we configured in our unicorn.rb
|
2
|
+
upstream unicorn_server {
|
3
|
+
server unix:/var/lib/inventory/unicorn.sock
|
4
|
+
fail_timeout=0;
|
5
|
+
}
|
6
|
+
|
7
|
+
# configure the virtual host
|
8
|
+
server {
|
9
|
+
# replace with your domain name
|
10
|
+
server_name localhost;
|
11
|
+
# replace this with your static Sinatra app files, root + public
|
12
|
+
root /app/public;
|
13
|
+
# port to listen for requests on
|
14
|
+
listen 80;
|
15
|
+
# maximum accepted body size of client request
|
16
|
+
client_max_body_size 4G;
|
17
|
+
# the server will close connections after this time
|
18
|
+
keepalive_timeout 5;
|
19
|
+
|
20
|
+
location / {
|
21
|
+
try_files $uri @app;
|
22
|
+
}
|
23
|
+
|
24
|
+
location @app {
|
25
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
26
|
+
proxy_set_header Host $http_host;
|
27
|
+
proxy_redirect off;
|
28
|
+
# pass to the upstream unicorn server mentioned above
|
29
|
+
proxy_pass http://unicorn_server;
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# set path to app that will be used to configure unicorn,
|
2
|
+
# note the trailing slash in this example
|
3
|
+
@dir = File.expand_path '../../', File.dirname(__FILE__)
|
4
|
+
|
5
|
+
worker_processes 2
|
6
|
+
working_directory @dir
|
7
|
+
|
8
|
+
timeout 30
|
9
|
+
|
10
|
+
# Specify path to socket unicorn listens to,
|
11
|
+
# we will use this in our nginx.conf later
|
12
|
+
listen "/var/lib/inventory/unicorn.sock", :backlog => 64
|
13
|
+
|
14
|
+
# Set process id path
|
15
|
+
pid "/var/run/inventory/unicorn.pid"
|
16
|
+
|
17
|
+
# Set log file paths
|
18
|
+
stderr_path "/var/log/inventory/unicorn-error.log"
|
19
|
+
stdout_path "/var/log/inventory/unicorn.log"
|
data/fig.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
web:
|
2
|
+
build: .
|
3
|
+
links:
|
4
|
+
- elasticsearch
|
5
|
+
ports:
|
6
|
+
- "80:80"
|
7
|
+
environment:
|
8
|
+
INVENTORY_ES_HOST: http://elasticsearch:9200
|
9
|
+
kibana:
|
10
|
+
image: bobrik/kibana4:4.0.0-rc1
|
11
|
+
ports:
|
12
|
+
- 5601:5601
|
13
|
+
links:
|
14
|
+
- elasticsearch
|
15
|
+
environment:
|
16
|
+
KIBANA_ES_URL: http://elasticsearch:9200
|
17
|
+
elasticsearch:
|
18
|
+
image: elasticsearch:1.4.4
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'inventory/server/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "inventory-server"
|
8
|
+
spec.version = Inventory::Server::VERSION
|
9
|
+
spec.authors = ["Filirom1"]
|
10
|
+
spec.email = ["filirom1@gmail.com"]
|
11
|
+
spec.summary = %q{Inventory server store and index data sent from the agent}
|
12
|
+
spec.description = %q{Inventory server store and index data sent from the agent}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'midi-smtp-server', '~> 1.1'
|
22
|
+
spec.add_dependency 'rest-client', '~> 1.7'
|
23
|
+
spec.add_dependency 'gserver', '~> 0.0'
|
24
|
+
spec.add_dependency 'mail', '~> 2.6'
|
25
|
+
spec.add_dependency 'filum', '~> 2.2'
|
26
|
+
spec.add_dependency 'json', '~> 1.8'
|
27
|
+
spec.add_dependency 'activesupport', '~> 4.2'
|
28
|
+
spec.add_dependency 'libxml-to-hash', '~> 0.2'
|
29
|
+
spec.add_dependency 'middleware', '~> 0.1'
|
30
|
+
spec.add_dependency 'app_configuration', '~> 0.0'
|
31
|
+
spec.add_dependency 'sinatra', '~> 1.4'
|
32
|
+
spec.add_dependency 'ensure-encoding', '~> 0.1'
|
33
|
+
spec.add_dependency 'json-schema', '~> 2.5'
|
34
|
+
spec.add_dependency 'unicorn', '~> 4.8'
|
35
|
+
|
36
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
37
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
38
|
+
spec.add_development_dependency "rack-test", "~> 0.6"
|
39
|
+
spec.add_development_dependency "codeclimate-test-reporter", "~> 0.4"
|
40
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
41
|
+
spec.add_development_dependency "rspec-mocks", "~> 3.2"
|
42
|
+
spec.add_development_dependency "webmock", "~> 1.20"
|
43
|
+
spec.add_development_dependency 'thin', '~> 1.6'
|
44
|
+
spec.add_development_dependency 'parallel', '~> 1.4'
|
45
|
+
end
|