hieracles 0.0.1 → 0.0.2
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 +88 -1
- data/lib/hieracles/formats/rawyaml.rb +36 -0
- data/lib/hieracles/formats/yaml.rb +35 -2
- data/lib/hieracles/help.rb +8 -0
- data/lib/hieracles/node.rb +16 -12
- data/lib/hieracles.rb +1 -0
- data/spec/files/enc/server.example.com.yaml +1 -1
- data/spec/files/enc/server2.example.com.yaml +1 -1
- data/spec/files/enc/server3.example.com.yaml +1 -1
- data/spec/files/enc/server4.example.com.yaml +8 -0
- data/spec/files/farm_modules/dev4.pp +4 -0
- data/spec/files/modules/faux_module1/manifests/init.pp +3 -0
- data/spec/files/modules/faux_module2/manifests/init.pp +3 -0
- data/spec/lib/formats/rawyaml_spec.rb +79 -0
- data/spec/lib/formats/yaml_spec.rb +150 -4
- data/spec/lib/node_spec.rb +17 -0
- data/tools/completion/_hc +13 -0
- metadata +15 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9456a3fe61cef7f54210ecd5d1c0db375afce266
|
4
|
+
data.tar.gz: 4d7563bd18c44b03267bf19bfecf6c8f90d5c7c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dafdb9eb00ae8883c9a365724e86af97e819bcb70ea774a00342fb0d7cb2e6231eb1b9df1be562ef3bf88cd444524deebfb50e80c59d77335f8f0aa8935dfb16
|
7
|
+
data.tar.gz: faf09ad63a05cd373e8fd7a1a2f13f772580dca3f1a3b34efe599b9d20d6f5493c268236c6c945798bd131bf040c60dbeea83deed892806d7ffbebfa9d2e6d3c
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
Hieracles Changelog
|
2
2
|
=======================
|
3
3
|
|
4
|
+
### 0.0.2 - 2016-09-16
|
5
|
+
- added `yaml` format including comments about where the params is defined
|
6
|
+
- the uncommented yaml is now the format `rawyaml`
|
7
|
+
|
4
8
|
### 0.0.1 - 2015-09-12
|
5
9
|
- first alpha release
|
6
10
|
- added extensive testing using rspec
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
Hieracles
|
2
2
|
================
|
3
3
|
|
4
|
+
[![Gem Version](https://img.shields.io/gem/v/hieracles.svg)](http://rubygems.org/gems/hieracles)
|
5
|
+
[![Downloads](http://img.shields.io/gem/dt/hieracles.svg)](https://rubygems.org/gems/hieracles)
|
4
6
|
[![Build Status](https://img.shields.io/travis/Gandi/hieracles.svg)](https://travis-ci.org/Gandi/hieracles)
|
5
7
|
[![Coverage Status](https://img.shields.io/coveralls/Gandi/hieracles.svg)](https://coveralls.io/r/Gandi/hieracles?branch=master)
|
6
8
|
[![Dependency Status](https://img.shields.io/gemnasium/Gandi/hieracles.svg)](https://gemnasium.com/Gandi/hieracles)
|
@@ -8,9 +10,92 @@ Hieracles
|
|
8
10
|
|
9
11
|
Hieracles is a command-line tool for analysis and deep examination of [Hiera][hiera] paramaters in a [Puppet][puppet] setup. It's used internally at [Gandi][gandi] and its first incarnation is strongly tied to Gandi puppet architecture. But Hieracles tends to become, in time, a generic Hiera overlay visualisation tool.
|
10
12
|
|
13
|
+
Prerequisite
|
14
|
+
---------------
|
15
|
+
|
16
|
+
There are many ways to setup puppet and use hiera. This tool is designed to match a certain kind of setup, including:
|
17
|
+
|
18
|
+
- an [external node classifier (ENC)][enc]
|
19
|
+
- a yaml hiera datastore
|
20
|
+
- classes that only contains includes and no code
|
21
|
+
- local availability of a hierafile
|
22
|
+
|
23
|
+
As the development is going on, more generic options will be provided, but for now, we mainly make it robust to fit the context we have.
|
24
|
+
|
25
|
+
|
11
26
|
Install
|
12
27
|
-----------
|
13
|
-
At this stage, it's to early to even think about installing anything. The internal code from Gandi is still in progress of transition towards total freedom.
|
28
|
+
At this stage, it's to early to even think about installing anything. The internal code from Gandi is still in progress of transition towards total freedom and generic usage.
|
29
|
+
|
30
|
+
Despite this warning, you can
|
31
|
+
|
32
|
+
gem install hieracles
|
33
|
+
|
34
|
+
or add in your Gemfile:
|
35
|
+
|
36
|
+
gem 'hieracles'
|
37
|
+
|
38
|
+
|
39
|
+
Configuration
|
40
|
+
----------------
|
41
|
+
At first launch it will create a configuration file in `~/.config/hieracles/config.yml`
|
42
|
+
|
43
|
+
Configuration variables are:
|
44
|
+
|
45
|
+
- classpath
|
46
|
+
- modulepath
|
47
|
+
- basepath
|
48
|
+
- encpath
|
49
|
+
- hierafile
|
50
|
+
- format
|
51
|
+
|
52
|
+
For an example setup you can check in `spec/files`.
|
53
|
+
|
54
|
+
Usage
|
55
|
+
-------------
|
56
|
+
|
57
|
+
|
58
|
+
Usage: hc <fqdn> <command> [extra_args]
|
59
|
+
|
60
|
+
Available commands:
|
61
|
+
info provides the farm, datacenter, country
|
62
|
+
associated to the given fqdn
|
63
|
+
files list all files containing params affecting this fqdn
|
64
|
+
(in more than commons)
|
65
|
+
paths list all file paths for files with params
|
66
|
+
modules list modules included in the farm where the node is
|
67
|
+
params list params for the node matching the fqdn
|
68
|
+
An extra filter string can be added to limit the list
|
69
|
+
use ruby regexp without the enclosing slashes
|
70
|
+
eg. hc <fqdn> params postfix.*version
|
71
|
+
eg. hc <fqdn> params '^postfix'
|
72
|
+
eg. hc <fqdn> params 'version$'
|
73
|
+
allparams same as params but including the common.yaml params (huge)
|
74
|
+
Also accepts a search string
|
75
|
+
|
76
|
+
Extra args:
|
77
|
+
-f <plain|console|csv|yaml|rawyaml> default console
|
78
|
+
-p extraparam=what;anotherparam=this
|
79
|
+
-c <configfile>
|
80
|
+
-h <hierafile>
|
81
|
+
-b <basepath> default ./
|
82
|
+
-e <encdir>
|
83
|
+
|
84
|
+
Completion
|
85
|
+
-------------
|
86
|
+
There is a simple zsh completion file in `tools/completion`.
|
87
|
+
|
88
|
+
If you use [oh-my-zsh][omz] put it in `~/.oh-my-zsh/completions`
|
89
|
+
|
90
|
+
wget -O ~/.oh-my-zsh/completions/_hc https://raw.githubusercontent.com/Gandi/hieracles/master/tools/completion/_hc
|
91
|
+
echo 'compdef _hc hc "bundle exec hc"' >> ~/.zshrc
|
92
|
+
|
93
|
+
Otherwise
|
94
|
+
|
95
|
+
mkdir ~/.zsh-completions
|
96
|
+
wget -O ~/.zsh-completions/_hc https://raw.githubusercontent.com/Gandi/hieracles/master/tools/completion/_hc
|
97
|
+
echo 'fpath=(~/.zsh-completions $fpath)' >> ~/.zshrc
|
98
|
+
echo 'compdef _hc hc "bundle exec hc"' >> ~/.zshrc
|
14
99
|
|
15
100
|
Authors
|
16
101
|
-----------
|
@@ -28,3 +113,5 @@ copyright (c) 2015 Gandi http://gandi.net
|
|
28
113
|
[puppet]: https://github.com/puppetlabs/puppet
|
29
114
|
[hiera]: https://github.com/puppetlabs/hiera
|
30
115
|
[gandi]: https://gandi.net
|
116
|
+
[enc]: https://docs.puppetlabs.com/guides/external_nodes.html
|
117
|
+
[omz]: https://github.com/robbyrussell/oh-my-zsh
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Hieracles
|
2
|
+
module Formats
|
3
|
+
# format mostly useful for re-integration in param files
|
4
|
+
class Rawyaml < Hieracles::Format
|
5
|
+
|
6
|
+
def info(_)
|
7
|
+
@node.info.to_yaml
|
8
|
+
end
|
9
|
+
|
10
|
+
def files(_)
|
11
|
+
@node.files.to_yaml
|
12
|
+
end
|
13
|
+
|
14
|
+
def paths(_)
|
15
|
+
@node.paths.to_yaml
|
16
|
+
end
|
17
|
+
|
18
|
+
def modules(_)
|
19
|
+
@node.modules.to_yaml
|
20
|
+
end
|
21
|
+
|
22
|
+
def params(args)
|
23
|
+
@node.params_tree(true).to_yaml
|
24
|
+
end
|
25
|
+
|
26
|
+
def allparams(args)
|
27
|
+
@node.params_tree(false).to_yaml
|
28
|
+
end
|
29
|
+
|
30
|
+
def modules(args)
|
31
|
+
@node.modules.to_yaml
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -20,17 +20,50 @@ module Hieracles
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def params(args)
|
23
|
-
|
23
|
+
commented_yaml_tree(true)
|
24
24
|
end
|
25
25
|
|
26
26
|
def allparams(args)
|
27
|
-
|
27
|
+
commented_yaml_tree(false)
|
28
28
|
end
|
29
29
|
|
30
30
|
def modules(args)
|
31
31
|
@node.modules.to_yaml
|
32
32
|
end
|
33
33
|
|
34
|
+
|
35
|
+
def commented_yaml_tree(without_common = true)
|
36
|
+
tree = @node.params_tree(without_common)
|
37
|
+
params = Hash[@node.params(without_common)]
|
38
|
+
mergetree('---', [], tree, params)
|
39
|
+
end
|
40
|
+
|
41
|
+
def mergetree(output, key, leaf, params)
|
42
|
+
indent = ' ' * key.count
|
43
|
+
case leaf.class.name
|
44
|
+
when 'Hash'
|
45
|
+
leaf.each do |k, v|
|
46
|
+
output += "\n" + indent + k + ': '
|
47
|
+
output = mergetree(output, key + [k], v, params)
|
48
|
+
end
|
49
|
+
when 'Array'
|
50
|
+
yaml = leaf.to_yaml[4..-1]
|
51
|
+
aryaml = yaml.each_line.map do |l|
|
52
|
+
indent + l
|
53
|
+
end
|
54
|
+
output += "\n" + indent + "# " + params[key.join('.')][0][:file]
|
55
|
+
output += "\n" + aryaml.join().chomp
|
56
|
+
when 'String'
|
57
|
+
output += leaf
|
58
|
+
if params["#{key.join('.')}"]
|
59
|
+
output += " # " + params[key.join('.')][0][:file]
|
60
|
+
else
|
61
|
+
raise "#{key}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
output
|
65
|
+
end
|
66
|
+
|
34
67
|
end
|
35
68
|
end
|
36
69
|
end
|
data/lib/hieracles/help.rb
CHANGED
@@ -21,6 +21,14 @@ module Hieracles
|
|
21
21
|
eg. hc <fqdn> params 'version$'
|
22
22
|
allparams same as params but including the common.yaml params (huge)
|
23
23
|
Also accepts a search string
|
24
|
+
|
25
|
+
Extra args:
|
26
|
+
-f <plain|console|csv|yaml|rawyaml> default console
|
27
|
+
-p extraparam=what;anotherparam=this
|
28
|
+
-c <configfile>
|
29
|
+
-h <hierafile>
|
30
|
+
-b <basepath> default ./
|
31
|
+
-e <encdir>
|
24
32
|
END
|
25
33
|
end
|
26
34
|
end
|
data/lib/hieracles/node.rb
CHANGED
@@ -20,7 +20,7 @@ module Hieracles
|
|
20
20
|
def get_hiera_params(fqdn)
|
21
21
|
if File.exist?(File.join(Config.path('encpath'), "#{fqdn}.yaml"))
|
22
22
|
load = YAML.load_file(File.join(Config.path('encpath'), "#{fqdn}.yaml"))
|
23
|
-
sym_keys(load['parameters'])
|
23
|
+
sym_keys(load['parameters']).merge({ classes: load['classes']})
|
24
24
|
else
|
25
25
|
raise "Node not found"
|
26
26
|
end
|
@@ -66,25 +66,29 @@ module Hieracles
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def modules
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
modules = {}
|
70
|
+
classfiles.each do |c|
|
71
|
+
if File.exist?(c)
|
72
|
+
f = File.open(c, "r")
|
73
|
+
f.each_line do |line|
|
74
|
+
modules = add_modules(line, modules)
|
75
|
+
end
|
76
|
+
f.close
|
77
|
+
else
|
78
|
+
raise "Class file #{c} not found."
|
74
79
|
end
|
75
|
-
f.close
|
76
|
-
modules
|
77
|
-
else
|
78
|
-
raise "Class file #{classfile} not found."
|
79
80
|
end
|
81
|
+
modules
|
80
82
|
end
|
81
83
|
|
82
84
|
def info
|
83
85
|
@hiera_params
|
84
86
|
end
|
85
87
|
|
86
|
-
def
|
87
|
-
|
88
|
+
def classfiles
|
89
|
+
@hiera_params[:classes].map do |cl|
|
90
|
+
format(Config.path('classpath'), cl)
|
91
|
+
end
|
88
92
|
end
|
89
93
|
|
90
94
|
def modulepath(path)
|
data/lib/hieracles.rb
CHANGED
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hieracles::Formats::Rawyaml do
|
4
|
+
let(:node) { double("node") }
|
5
|
+
let(:yaml_format) { Hieracles::Formats::Rawyaml.new node }
|
6
|
+
|
7
|
+
describe ".info" do
|
8
|
+
let(:expected) {"---\nNode: fqdn\nFarm: farm\n"}
|
9
|
+
before {
|
10
|
+
allow(node).to receive(:info).and_return(
|
11
|
+
{
|
12
|
+
'Node' => 'fqdn',
|
13
|
+
'Farm' => 'farm'
|
14
|
+
}
|
15
|
+
)
|
16
|
+
}
|
17
|
+
it "outputs proper text" do
|
18
|
+
expect(yaml_format.info nil).to eq expected
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe ".files" do
|
23
|
+
let(:expected) { "---\n- path1\n- path2\n" }
|
24
|
+
before {
|
25
|
+
allow(node).to receive(:files).and_return(['path1', 'path2'])
|
26
|
+
}
|
27
|
+
it "outputs proper text" do
|
28
|
+
expect(yaml_format.files nil).to eq expected
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe ".paths" do
|
33
|
+
let(:expected) { "---\n- path1\n- path2\n" }
|
34
|
+
before {
|
35
|
+
allow(node).to receive(:paths).and_return(['path1', 'path2'])
|
36
|
+
}
|
37
|
+
it "outputs proper text" do
|
38
|
+
expect(yaml_format.paths nil).to eq expected
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe ".modules" do
|
43
|
+
before {
|
44
|
+
allow(node).to receive(:modules).and_return(
|
45
|
+
{
|
46
|
+
'module1' => "value",
|
47
|
+
'longmodule2' => "not found"
|
48
|
+
}
|
49
|
+
)
|
50
|
+
}
|
51
|
+
let(:expected) { "---\nmodule1: value\nlongmodule2: not found\n" }
|
52
|
+
it "outputs proper text" do
|
53
|
+
expect(yaml_format.modules nil).to eq expected
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe ".params" do
|
58
|
+
let(:expected) {
|
59
|
+
"---\n"+
|
60
|
+
"params:\n" +
|
61
|
+
" this:\n" +
|
62
|
+
" var: value1\n"
|
63
|
+
}
|
64
|
+
before {
|
65
|
+
allow(node).to receive(:params_tree).and_return(
|
66
|
+
{
|
67
|
+
'params' => {
|
68
|
+
'this' => {
|
69
|
+
'var' => 'value1'
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
)
|
74
|
+
}
|
75
|
+
it "outputs proper text" do
|
76
|
+
expect(yaml_format.params nil).to eq expected
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -57,11 +57,19 @@ describe Hieracles::Formats::Yaml do
|
|
57
57
|
describe ".params" do
|
58
58
|
let(:expected) {
|
59
59
|
"---\n"+
|
60
|
-
"params
|
61
|
-
" this
|
62
|
-
" var: value1
|
60
|
+
"params: \n" +
|
61
|
+
" this: \n" +
|
62
|
+
" var: value1 # some/file"
|
63
63
|
}
|
64
64
|
before {
|
65
|
+
allow(node).to receive(:params).and_return(
|
66
|
+
{
|
67
|
+
'params.this.var' => [{
|
68
|
+
file: 'some/file',
|
69
|
+
value: 'value1'
|
70
|
+
}]
|
71
|
+
}
|
72
|
+
)
|
65
73
|
allow(node).to receive(:params_tree).and_return(
|
66
74
|
{
|
67
75
|
'params' => {
|
@@ -76,5 +84,143 @@ describe Hieracles::Formats::Yaml do
|
|
76
84
|
expect(yaml_format.params nil).to eq expected
|
77
85
|
end
|
78
86
|
end
|
79
|
-
|
87
|
+
|
88
|
+
describe '.mergetree' do
|
89
|
+
context "with a simple string key-value" do
|
90
|
+
let(:params) {
|
91
|
+
{
|
92
|
+
'key' => [{
|
93
|
+
file: 'what/file',
|
94
|
+
value: 'value'
|
95
|
+
}]
|
96
|
+
}
|
97
|
+
}
|
98
|
+
let(:input) {
|
99
|
+
{ 'key' => 'value' }
|
100
|
+
}
|
101
|
+
let(:expected) {
|
102
|
+
"\nkey: value # what/file"
|
103
|
+
}
|
104
|
+
it { expect(yaml_format.mergetree('', [], input, params)).to eq expected }
|
105
|
+
end
|
106
|
+
context "with a simple array key-value" do
|
107
|
+
let(:params) {
|
108
|
+
{
|
109
|
+
'key' => [{
|
110
|
+
file: 'what/file',
|
111
|
+
value: ['value1', 'value2']
|
112
|
+
}]
|
113
|
+
}
|
114
|
+
}
|
115
|
+
let(:input) {
|
116
|
+
{ 'key' => ['value1', 'value2'] }
|
117
|
+
}
|
118
|
+
let(:expected) {
|
119
|
+
"\nkey: \n # what/file\n - value1\n - value2"
|
120
|
+
}
|
121
|
+
it { expect(yaml_format.mergetree('', [], input, params)).to eq expected }
|
122
|
+
end
|
123
|
+
context "with a 2-levels string key-value" do
|
124
|
+
let(:params) {
|
125
|
+
{
|
126
|
+
'key.sublevel' => [{
|
127
|
+
file: 'what/file',
|
128
|
+
value: 'value'
|
129
|
+
}]
|
130
|
+
}
|
131
|
+
}
|
132
|
+
let(:input) {
|
133
|
+
{
|
134
|
+
'key' => {
|
135
|
+
'sublevel' => 'value'
|
136
|
+
}
|
137
|
+
}
|
138
|
+
}
|
139
|
+
let(:expected) {
|
140
|
+
"\nkey: \n sublevel: value # what/file"
|
141
|
+
}
|
142
|
+
it { expect(yaml_format.mergetree('', [], input, params)).to eq expected }
|
143
|
+
end
|
144
|
+
context "with 2 2-levels string key-value" do
|
145
|
+
let(:params) {
|
146
|
+
{
|
147
|
+
'key.sublevel' => [{
|
148
|
+
file: 'what/file',
|
149
|
+
value: 'value'
|
150
|
+
}],
|
151
|
+
'key.sublevel2' => [{
|
152
|
+
file: 'what/file2',
|
153
|
+
value: 'value2'
|
154
|
+
}]
|
155
|
+
}
|
156
|
+
}
|
157
|
+
let(:input) {
|
158
|
+
{
|
159
|
+
'key' => {
|
160
|
+
'sublevel' => 'value',
|
161
|
+
'sublevel2' => 'value2'
|
162
|
+
}
|
163
|
+
}
|
164
|
+
}
|
165
|
+
let(:expected) {
|
166
|
+
"\nkey: \n sublevel: value # what/file\n sublevel2: value2 # what/file2"
|
167
|
+
}
|
168
|
+
it { expect(yaml_format.mergetree('', [], input, params)).to eq expected }
|
169
|
+
end
|
170
|
+
context "with a 3-levels string key-value" do
|
171
|
+
let(:params) {
|
172
|
+
{
|
173
|
+
'key.sublevel.subsublevel' => [{
|
174
|
+
file: 'what/file',
|
175
|
+
value: 'value'
|
176
|
+
}]
|
177
|
+
}
|
178
|
+
}
|
179
|
+
let(:input) {
|
180
|
+
{
|
181
|
+
'key' => {
|
182
|
+
'sublevel' => {
|
183
|
+
'subsublevel' => 'value'
|
184
|
+
}
|
185
|
+
}
|
186
|
+
}
|
187
|
+
}
|
188
|
+
let(:expected) {
|
189
|
+
"\nkey: \n sublevel: \n subsublevel: value # what/file"
|
190
|
+
}
|
191
|
+
it { expect(yaml_format.mergetree('', [], input, params)).to eq expected }
|
192
|
+
end
|
193
|
+
context "with a 3-levels double string key-value" do
|
194
|
+
let(:params) {
|
195
|
+
{
|
196
|
+
'key.sublevel.subsublevel' => [{
|
197
|
+
file: 'what/file',
|
198
|
+
value: 'value'
|
199
|
+
}],
|
200
|
+
'key2.sublevel' => [{
|
201
|
+
file: 'what/file2',
|
202
|
+
value: 'value'
|
203
|
+
}]
|
204
|
+
}
|
205
|
+
}
|
206
|
+
let(:input) {
|
207
|
+
{
|
208
|
+
'key' => {
|
209
|
+
'sublevel' => {
|
210
|
+
'subsublevel' => 'value'
|
211
|
+
}
|
212
|
+
},
|
213
|
+
'key2' => {
|
214
|
+
'sublevel' => 'value'
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
218
|
+
let(:expected) {
|
219
|
+
"\nkey: \n sublevel: \n subsublevel: value # what/file" +
|
220
|
+
"\nkey2: \n sublevel: value # what/file2"
|
221
|
+
}
|
222
|
+
it { expect(yaml_format.mergetree('', [], input, params)).to eq expected }
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
80
226
|
end
|
data/spec/lib/node_spec.rb
CHANGED
@@ -18,6 +18,7 @@ describe Hieracles::Node do
|
|
18
18
|
let(:node) { Hieracles::Node.new 'server.example.com', extraoptions }
|
19
19
|
let(:expected) {
|
20
20
|
{
|
21
|
+
classes: ['dev'],
|
21
22
|
fqdn: 'server.example.com',
|
22
23
|
country: 'fr',
|
23
24
|
datacenter: 'equinix',
|
@@ -42,6 +43,7 @@ describe Hieracles::Node do
|
|
42
43
|
describe '.new' do
|
43
44
|
let(:expected) {
|
44
45
|
{
|
46
|
+
classes: ['dev'],
|
45
47
|
fqdn: 'server.example.com',
|
46
48
|
country: 'fr',
|
47
49
|
datacenter: 'equinix',
|
@@ -142,10 +144,24 @@ describe Hieracles::Node do
|
|
142
144
|
let(:node) { Hieracles::Node.new 'server3.example.com', options }
|
143
145
|
it { expect { node.modules }.to raise_error(RuntimeError) }
|
144
146
|
end
|
147
|
+
context "multiple classes included" do
|
148
|
+
let(:node) { Hieracles::Node.new 'server4.example.com', options }
|
149
|
+
let(:expected) {
|
150
|
+
{
|
151
|
+
"fake_module" => "modules/fake_module",
|
152
|
+
"fake_module2" => "modules/fake_module2",
|
153
|
+
"fake_module4" => nil,
|
154
|
+
"faux_module1" => "modules/faux_module1",
|
155
|
+
"faux_module2" => "modules/faux_module2"
|
156
|
+
}
|
157
|
+
}
|
158
|
+
it { expect(node.modules).to eq expected }
|
159
|
+
end
|
145
160
|
end
|
146
161
|
|
147
162
|
describe '.info' do
|
148
163
|
let(:expected) { {
|
164
|
+
classes: ['dev'],
|
149
165
|
fqdn: 'server.example.com',
|
150
166
|
datacenter: 'equinix',
|
151
167
|
country: 'fr',
|
@@ -153,6 +169,7 @@ describe Hieracles::Node do
|
|
153
169
|
} }
|
154
170
|
it { expect(node.info).to eq expected }
|
155
171
|
end
|
172
|
+
|
156
173
|
end
|
157
174
|
|
158
175
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#compdef hc
|
2
|
+
|
3
|
+
_hc() {
|
4
|
+
local cmd
|
5
|
+
if (( CURRENT == 2 ))
|
6
|
+
then
|
7
|
+
_values -C 'fqdn' ${$(find ./enc -print | xargs -- basename -s | sed -e 's~\.yaml~~')}
|
8
|
+
else if (( CURRENT == 3 ))
|
9
|
+
_values -C 'command' info files paths modules params allparams
|
10
|
+
fi
|
11
|
+
}
|
12
|
+
|
13
|
+
_hc
|
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.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mose
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- lib/hieracles/formats/console.rb
|
136
136
|
- lib/hieracles/formats/csv.rb
|
137
137
|
- lib/hieracles/formats/plain.rb
|
138
|
+
- lib/hieracles/formats/rawyaml.rb
|
138
139
|
- lib/hieracles/formats/yaml.rb
|
139
140
|
- lib/hieracles/help.rb
|
140
141
|
- lib/hieracles/hiera.rb
|
@@ -145,14 +146,18 @@ files:
|
|
145
146
|
- spec/files/enc/server.example.com.yaml
|
146
147
|
- spec/files/enc/server2.example.com.yaml
|
147
148
|
- spec/files/enc/server3.example.com.yaml
|
149
|
+
- spec/files/enc/server4.example.com.yaml
|
148
150
|
- spec/files/farm_modules/dev.pp
|
149
151
|
- spec/files/farm_modules/dev2.pp
|
152
|
+
- spec/files/farm_modules/dev4.pp
|
150
153
|
- spec/files/hiera.yaml
|
151
154
|
- spec/files/hiera_no_yamlbackend.yaml
|
152
155
|
- spec/files/hiera_yamlbackend_notfound.yaml
|
153
156
|
- spec/files/modules/fake_module/manifests/init.pp
|
154
157
|
- spec/files/modules/fake_module2/manifests/init.pp
|
155
158
|
- spec/files/modules/fake_module3/manifests/init.pp
|
159
|
+
- spec/files/modules/faux_module1/manifests/init.pp
|
160
|
+
- spec/files/modules/faux_module2/manifests/init.pp
|
156
161
|
- spec/files/params/common/common.yml
|
157
162
|
- spec/files/params/farm/dev.yaml
|
158
163
|
- spec/files/params/nodes/server.example.com.yaml
|
@@ -161,6 +166,7 @@ files:
|
|
161
166
|
- spec/lib/formats/console_spec.rb
|
162
167
|
- spec/lib/formats/csv_spec.rb
|
163
168
|
- spec/lib/formats/plain_spec.rb
|
169
|
+
- spec/lib/formats/rawyaml_spec.rb
|
164
170
|
- spec/lib/formats/yaml_spec.rb
|
165
171
|
- spec/lib/help_spec.rb
|
166
172
|
- spec/lib/hiera_spec.rb
|
@@ -168,6 +174,7 @@ files:
|
|
168
174
|
- spec/lib/optparse_spec.rb
|
169
175
|
- spec/lib/utils_spec.rb
|
170
176
|
- spec/spec_helper.rb
|
177
|
+
- tools/completion/_hc
|
171
178
|
homepage: https://github.com/Gandi/hieracles
|
172
179
|
licenses:
|
173
180
|
- MIT
|
@@ -189,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
196
|
version: '0'
|
190
197
|
requirements: []
|
191
198
|
rubyforge_project:
|
192
|
-
rubygems_version: 2.
|
199
|
+
rubygems_version: 2.4.7
|
193
200
|
signing_key:
|
194
201
|
specification_version: 4
|
195
202
|
summary: CLI tool for Hiera parameters visualisation.
|
@@ -198,14 +205,18 @@ test_files:
|
|
198
205
|
- spec/files/enc/server.example.com.yaml
|
199
206
|
- spec/files/enc/server2.example.com.yaml
|
200
207
|
- spec/files/enc/server3.example.com.yaml
|
208
|
+
- spec/files/enc/server4.example.com.yaml
|
201
209
|
- spec/files/farm_modules/dev.pp
|
202
210
|
- spec/files/farm_modules/dev2.pp
|
211
|
+
- spec/files/farm_modules/dev4.pp
|
203
212
|
- spec/files/hiera.yaml
|
204
213
|
- spec/files/hiera_no_yamlbackend.yaml
|
205
214
|
- spec/files/hiera_yamlbackend_notfound.yaml
|
206
215
|
- spec/files/modules/fake_module/manifests/init.pp
|
207
216
|
- spec/files/modules/fake_module2/manifests/init.pp
|
208
217
|
- spec/files/modules/fake_module3/manifests/init.pp
|
218
|
+
- spec/files/modules/faux_module1/manifests/init.pp
|
219
|
+
- spec/files/modules/faux_module2/manifests/init.pp
|
209
220
|
- spec/files/params/common/common.yml
|
210
221
|
- spec/files/params/farm/dev.yaml
|
211
222
|
- spec/files/params/nodes/server.example.com.yaml
|
@@ -214,6 +225,7 @@ test_files:
|
|
214
225
|
- spec/lib/formats/console_spec.rb
|
215
226
|
- spec/lib/formats/csv_spec.rb
|
216
227
|
- spec/lib/formats/plain_spec.rb
|
228
|
+
- spec/lib/formats/rawyaml_spec.rb
|
217
229
|
- spec/lib/formats/yaml_spec.rb
|
218
230
|
- spec/lib/help_spec.rb
|
219
231
|
- spec/lib/hiera_spec.rb
|