pristine 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -3
- data/bin/pristine +1 -4
- data/lib/pristine/cli.rb +10 -0
- data/lib/pristine/config.rb +55 -8
- data/lib/pristine/daemon.rb +3 -1
- data/lib/pristine/log.rb +1 -1
- data/lib/pristine/version.rb +1 -1
- metadata +3 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0eb20ebacf82b1dd7daf7bd2c0e50ab11aa03981
|
4
|
+
data.tar.gz: 119cbe33b15d18bb6c0b33688ea11f30a58d4900
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82c10c9cc9844f159342c4f4900f70c5c699e3bfeb90618d3816d9c2d7759fbab2e600b7374abd97a5b57995e296b0cd92fb396414636dc8b0f05ea3dc5093ee
|
7
|
+
data.tar.gz: f9576653c5505a01924903d6dbac8ac048ce0a6b7a7e2b4aadbb5b38186f339e6b754de4dbf6a5db3e9abacb7513aee5b1a980ca962b68087badef87b1480440
|
data/README.md
CHANGED
@@ -2,9 +2,25 @@
|
|
2
2
|
|
3
3
|
Watches if any file managed by Puppet was modified.
|
4
4
|
|
5
|
+
# Usage
|
6
|
+
|
7
|
+
```
|
8
|
+
$ ./bin/pristine -h
|
9
|
+
Usage: pristine [options]
|
10
|
+
--config FILE Config file
|
11
|
+
-l, --log FILE Log output
|
12
|
+
-f, --files Files list to watch
|
13
|
+
-h, --help Show this message
|
14
|
+
--version Show version
|
5
15
|
```
|
16
|
+
|
17
|
+
# Example
|
18
|
+
|
19
|
+
|
20
|
+
```
|
21
|
+
$ git clone https://github.com/carlasouza/pristine.git; cd pristine
|
6
22
|
$ ./example/create_example_files.sh
|
7
|
-
$ ./bin/pristine
|
23
|
+
$ ./bin/pristine -c config.yaml
|
8
24
|
W, [2016-04-17T19:18:34.376080 #29074] WARN -- : /foo/bar does not exist.
|
9
25
|
I, [2016-04-17T19:18:34.376153 #29074] INFO -- : /tmp/pristine/example/ watcher created.
|
10
26
|
I, [2016-04-17T19:18:34.376190 #29074] INFO -- : /tmp/pristine/example/a watcher created.
|
@@ -22,6 +38,8 @@ I, [2016-04-17T19:19:28.959390 #29074] INFO -- : /tmp/pristine/example/a/c - [:
|
|
22
38
|
|
23
39
|
# TODO
|
24
40
|
|
41
|
+
* Arguments sanity check
|
42
|
+
|
25
43
|
* Check if `puppet` is installed
|
26
44
|
|
27
45
|
* Filter out concats from resources file
|
@@ -30,10 +48,10 @@ I, [2016-04-17T19:19:28.959390 #29074] INFO -- : /tmp/pristine/example/a/c - [:
|
|
30
48
|
|
31
49
|
If directory, monitor recursevly
|
32
50
|
|
33
|
-
|
34
51
|
* Add `:access` to files that contain passwords
|
35
52
|
|
36
|
-
* Add a watcher to the `file_list` file
|
53
|
+
* Add a watcher to the `file_list` file and then reload itself upon modification
|
54
|
+
|
37
55
|
|
38
56
|
|
39
57
|
# Copyright
|
data/bin/pristine
CHANGED
data/lib/pristine/cli.rb
ADDED
data/lib/pristine/config.rb
CHANGED
@@ -1,25 +1,66 @@
|
|
1
|
-
require '
|
1
|
+
require 'yaml'
|
2
|
+
require 'optparse'
|
3
|
+
require 'ostruct'
|
4
|
+
require 'pristine/version'
|
2
5
|
|
3
6
|
module Pristine
|
4
7
|
class Config
|
5
8
|
|
9
|
+
DEFAULT_LOG = STDOUT
|
10
|
+
DEFAULT_FLAGS = :modify #Lets watch IN_MODIFY events for now
|
6
11
|
DEFAULT_FILES_LIST = '/var/lib/puppet/state/resources.txt'
|
7
12
|
|
8
|
-
def self.load(
|
9
|
-
@config
|
13
|
+
def self.load(args)
|
14
|
+
@config = OpenStruct.new
|
15
|
+
|
16
|
+
parser = OptionParser.new do |opts|
|
17
|
+
opts.on_head('--config FILE', 'Config file') do |path|
|
18
|
+
@config[:config_file] = path
|
19
|
+
@config = OpenStruct.new(Hash[YAML::load(open(path)).map { |k, v| [k.to_sym, v] }])
|
20
|
+
end
|
21
|
+
|
22
|
+
# TODO
|
23
|
+
# opts.on('-F', '--foreground', 'Run on foreground') do |v|
|
24
|
+
# @config[:foreground] = v
|
25
|
+
# end
|
26
|
+
|
27
|
+
opts.on('-l', '--log FILE', 'Log output') do |v|
|
28
|
+
@config[:log] = v
|
29
|
+
end
|
30
|
+
|
31
|
+
# TODO
|
32
|
+
# opts.on('-f', '--flags x,y,z', Array, 'Systemcalls to watch') do |v|
|
33
|
+
# @config[:config_file] = v
|
34
|
+
# end
|
35
|
+
|
36
|
+
opts.on('-f', '--files FILE', 'Files list to watch') do |v|
|
37
|
+
@config[:files_list] = v
|
38
|
+
end
|
39
|
+
|
40
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
41
|
+
puts opts
|
42
|
+
exit
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on_tail("--version", "Show version") do
|
46
|
+
puts Pristine::VERSION
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
end
|
50
|
+
parser.parse(args)
|
51
|
+
parser.load(config.config_file) unless config.config_file.nil?
|
52
|
+
|
53
|
+
set_defaults
|
10
54
|
end
|
11
55
|
|
12
56
|
def self.config
|
13
57
|
@config
|
14
58
|
end
|
15
59
|
|
16
|
-
|
17
|
-
:modify #Lets watch IN_MODIFY events for now
|
18
|
-
end
|
19
|
-
|
60
|
+
# Specific for Puppet's resource.txt file
|
20
61
|
def self.files_list
|
21
62
|
list = []
|
22
|
-
File.open(config.
|
63
|
+
File.open(@config.files_list, 'r') do |f|
|
23
64
|
f.each_line do |line|
|
24
65
|
if line.match(/^file/)
|
25
66
|
list << line.split('[')[1].split(']').first
|
@@ -33,6 +74,12 @@ module Pristine
|
|
33
74
|
@config.send method
|
34
75
|
end
|
35
76
|
|
77
|
+
private
|
78
|
+
def self.set_defaults
|
79
|
+
@config.log ||= DEFAULT_LOG
|
80
|
+
@config.flags ||= DEFAULT_FLAGS
|
81
|
+
@config.files_list ||= DEFAULT_FILES_LIST
|
82
|
+
end
|
36
83
|
|
37
84
|
end
|
38
85
|
end
|
data/lib/pristine/daemon.rb
CHANGED
data/lib/pristine/log.rb
CHANGED
data/lib/pristine/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pristine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carla Souza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rb-inotify
|
@@ -24,26 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.9.7
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: parseconfig
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.0'
|
34
|
-
- - ">="
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 1.0.8
|
37
|
-
type: :runtime
|
38
|
-
prerelease: false
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - "~>"
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '1.0'
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 1.0.8
|
47
27
|
description: Watches if any file managed by Puppet was modified.
|
48
28
|
email:
|
49
29
|
- contact@carlasouza.com
|
@@ -56,6 +36,7 @@ files:
|
|
56
36
|
- README.md
|
57
37
|
- bin/pristine
|
58
38
|
- lib/pristine.rb
|
39
|
+
- lib/pristine/cli.rb
|
59
40
|
- lib/pristine/collector.rb
|
60
41
|
- lib/pristine/config.rb
|
61
42
|
- lib/pristine/daemon.rb
|