puppetdb_query 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/puppetdb_query/mongodb.rb +20 -0
- data/lib/puppetdb_query/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f41f56f3dfb4007d3fc48794f4d82c2556d00702
|
4
|
+
data.tar.gz: 90a17031909847d23a8accfafc87a83b6b8c7c02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0b7f93f1828759cc77b9b465cb8324f2478267b608bfa1ff24837d8fbbc0f8b3d01b81c8a6ef295867baa1fd432ac2c7a4c93a01c1525f581027cf918609c09
|
7
|
+
data.tar.gz: 710d289824ddc5b85c0a2c426daf111e860450c3119f7c7561f73ff6a86f48d014412debe8b90b1c3b3d09d53d63d2fe95503ec89d151c635627de8050012765
|
@@ -46,6 +46,26 @@ module PuppetDBQuery
|
|
46
46
|
result
|
47
47
|
end
|
48
48
|
|
49
|
+
# get nodes and their facts for a pattern
|
50
|
+
def search_facts(query, pattern, facts, check_names = false)
|
51
|
+
collection = connection[nodes_collection]
|
52
|
+
result = {}
|
53
|
+
collection.find(query).batch_size(999).each do |values|
|
54
|
+
id = values.delete('_id')
|
55
|
+
found = {}
|
56
|
+
values.each do |k, v|
|
57
|
+
if v =~ pattern
|
58
|
+
found[k] = v
|
59
|
+
elsif check_names && k =~ pattern
|
60
|
+
found[k] = v
|
61
|
+
end
|
62
|
+
end
|
63
|
+
facts += found.keys
|
64
|
+
result[id] = found unless found.empty?
|
65
|
+
end
|
66
|
+
result
|
67
|
+
end
|
68
|
+
|
49
69
|
# get all node names
|
50
70
|
def nodes
|
51
71
|
collection = connection[nodes_collection]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppetdb_query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Meyling
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|