hieracles 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +24 -5
- data/lib/hieracles/config.rb +4 -2
- data/lib/hieracles/help.rb +2 -0
- data/lib/hieracles/hiera.rb +0 -1
- data/lib/hieracles/node.rb +6 -1
- data/spec/lib/config_spec.rb +3 -3
- 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: 4db8ec53dcd991137c7b1f4348de57cb175c7ced
|
4
|
+
data.tar.gz: 4a127e0e7c5b4f5e10aea37991cf82b9a48b888f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf8bfbe6606861d66931e0d3e065b1f3aff29eb25d7ec5dce8cbb6d5072e00de0c19bfac6f2f23b24dbd504f711461938ad2e3a375087af10fef54e0a58fba34
|
7
|
+
data.tar.gz: edd1d70376daac1a0a458da5348e271ea89257c4140db2b6fe83607e2f6199b23683590290cfd76246ad8aff34bfbcbea2146f0719ec1607139a8222e8d01223
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
Hieracles Changelog
|
2
2
|
=======================
|
3
3
|
|
4
|
+
### 0.1.3 - 2015-11-12
|
5
|
+
- added scope (facts) interpretation for the hiera file
|
6
|
+
(very basic interpolation, not yet hiera-lib level)
|
7
|
+
|
4
8
|
### 0.1.2 - 2015-11-12
|
5
9
|
- fix yaml more for case of nilclass in params
|
6
10
|
- fix the case when a params file is empty
|
data/README.md
CHANGED
@@ -48,6 +48,7 @@ Configuration variables are:
|
|
48
48
|
- encpath
|
49
49
|
- hierafile
|
50
50
|
- format
|
51
|
+
- defaultscope
|
51
52
|
|
52
53
|
For an example setup you can check in `spec/files`.
|
53
54
|
|
@@ -84,8 +85,8 @@ Usage
|
|
84
85
|
-j <fact_file> - facts in json format
|
85
86
|
|
86
87
|
|
87
|
-
About facts
|
88
|
-
|
88
|
+
About facts aka. scope
|
89
|
+
------------------------
|
89
90
|
|
90
91
|
_(work in progress)_
|
91
92
|
|
@@ -95,6 +96,24 @@ Like with Hiera CLI you can use hieracles with defined top-scope variables. Thos
|
|
95
96
|
- `-y <fact_file>` which takes the fact file from a yaml source created by `facter -y` on your node for example, but it can be written manually for experimentation purposes.
|
96
97
|
- `-j <fact_file>` same as above, but with output of `facter -j`
|
97
98
|
|
99
|
+
You can define a default scope in your configuration file `defaultscope` in `~/.confg/hieracles/config.yml`. For example:
|
100
|
+
|
101
|
+
---
|
102
|
+
colors: true
|
103
|
+
classpath: farm_modules/%s/manifests/init.pp
|
104
|
+
hierafile: dev/hiera-local.yaml
|
105
|
+
encpath: enc
|
106
|
+
defaultscope:
|
107
|
+
operatingsystem: Debian
|
108
|
+
lsbdistcodename: Jessie
|
109
|
+
|
110
|
+
In order the scope with be built from:
|
111
|
+
|
112
|
+
- the config file
|
113
|
+
- if `-y <file>` option (or `-j`) is present the `defaultscope` in the config file will be totally ignored
|
114
|
+
- the `-p key=value` option with overide variable per variable
|
115
|
+
|
116
|
+
|
98
117
|
Completion
|
99
118
|
-------------
|
100
119
|
There is a simple zsh completion file in `tools/completion`.
|
@@ -128,9 +147,9 @@ and install
|
|
128
147
|
|
129
148
|
Todo
|
130
149
|
--------------
|
131
|
-
- add json format
|
132
|
-
- add override information in yaml format
|
133
|
-
- add a command to search for node according to a filter
|
150
|
+
- add json format (done)
|
151
|
+
- add override information in yaml format (done)
|
152
|
+
- add a command to search for node according to a filter (done)
|
134
153
|
- add a command to find all nodes that use a given module
|
135
154
|
- add a command that finds all nodes for which a params is defined
|
136
155
|
- detect unused params
|
data/lib/hieracles/config.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'json'
|
3
3
|
require 'yaml'
|
4
|
+
require 'hieracles/utils'
|
4
5
|
|
5
6
|
module Hieracles
|
6
7
|
# configuration singleton
|
7
8
|
module Config
|
9
|
+
include Hieracles::Utils
|
8
10
|
extend self
|
9
11
|
|
10
|
-
attr_reader :extraparams, :server, :classpath, :
|
12
|
+
attr_reader :extraparams, :server, :classpath, :scope,
|
11
13
|
:modulepath, :hierafile, :basepath, :encpath, :format
|
12
14
|
|
13
15
|
def load(options)
|
@@ -24,7 +26,7 @@ module Hieracles
|
|
24
26
|
@format = (options[:format] || values['format'] || 'console').capitalize
|
25
27
|
facts_file = options[:yaml_facts] || options[:json_facts]
|
26
28
|
facts_format = options[:json_facts] ? :json : :yaml
|
27
|
-
@
|
29
|
+
@scope = sym_keys((facts_file && load_facts(facts_file, facts_format)) || values['defaultscope'] || {})
|
28
30
|
end
|
29
31
|
|
30
32
|
def initconfig(file)
|
data/lib/hieracles/help.rb
CHANGED
data/lib/hieracles/hiera.rb
CHANGED
data/lib/hieracles/node.rb
CHANGED
@@ -13,6 +13,7 @@ module Hieracles
|
|
13
13
|
@hiera = Hieracles::Hiera.new
|
14
14
|
@hiera_params = { fqdn: fqdn }.
|
15
15
|
merge(get_hiera_params(fqdn)).
|
16
|
+
merge(Config.scope).
|
16
17
|
merge(Config.extraparams)
|
17
18
|
@fqdn = fqdn
|
18
19
|
end
|
@@ -51,6 +52,7 @@ module Hieracles
|
|
51
52
|
s = to_shallow_hash(data)
|
52
53
|
s.each do |k,v|
|
53
54
|
params[k] ||= []
|
55
|
+
# f needs interpolation
|
54
56
|
params[k] << { value: v, file: f}
|
55
57
|
end
|
56
58
|
end
|
@@ -62,7 +64,10 @@ module Hieracles
|
|
62
64
|
params = {}
|
63
65
|
paths(without_common).each do |f|
|
64
66
|
data = YAML.load_file(f)
|
65
|
-
|
67
|
+
if data
|
68
|
+
# data needs interpolation
|
69
|
+
deep_merge!(params, data)
|
70
|
+
end
|
66
71
|
end
|
67
72
|
deep_sort(params)
|
68
73
|
end
|
data/spec/lib/config_spec.rb
CHANGED
@@ -61,7 +61,7 @@ describe Hieracles::Config do
|
|
61
61
|
it { expect(Hieracles::Config.extract_params(str)).to eq expected }
|
62
62
|
end
|
63
63
|
|
64
|
-
describe '.
|
64
|
+
describe '.scope' do
|
65
65
|
context 'with a yaml file' do
|
66
66
|
let(:options) do
|
67
67
|
{
|
@@ -73,7 +73,7 @@ describe Hieracles::Config do
|
|
73
73
|
let(:expected) { 'Debian' }
|
74
74
|
before { Hieracles::Config.load options }
|
75
75
|
|
76
|
-
it { expect(Hieracles::Config.
|
76
|
+
it { expect(Hieracles::Config.scope[:osfamily]).to eq expected }
|
77
77
|
end
|
78
78
|
context 'with a json file' do
|
79
79
|
let(:options) do
|
@@ -86,7 +86,7 @@ describe Hieracles::Config do
|
|
86
86
|
let(:expected) { 'Debian' }
|
87
87
|
before { Hieracles::Config.load options }
|
88
88
|
|
89
|
-
it { expect(Hieracles::Config.
|
89
|
+
it { expect(Hieracles::Config.scope[:osfamily]).to eq expected }
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hieracles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mose
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|