hieracles 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/Gemfile +2 -0
  4. data/README.md +54 -8
  5. data/bin/hc +12 -6
  6. data/bin/ppdb +42 -0
  7. data/hc.1 +50 -8
  8. data/lib/hieracles.rb +2 -2
  9. data/lib/hieracles/config.rb +31 -19
  10. data/lib/hieracles/format.rb +4 -0
  11. data/lib/hieracles/formats/console.rb +49 -16
  12. data/lib/hieracles/formats/csv.rb +12 -8
  13. data/lib/hieracles/formats/json.rb +19 -6
  14. data/lib/hieracles/formats/plain.rb +24 -3
  15. data/lib/hieracles/formats/rawyaml.rb +4 -0
  16. data/lib/hieracles/formats/yaml.rb +4 -0
  17. data/lib/hieracles/node.rb +55 -10
  18. data/lib/hieracles/notification.rb +31 -0
  19. data/lib/hieracles/options/hc.rb +109 -0
  20. data/lib/hieracles/options/ppdb.rb +32 -0
  21. data/lib/hieracles/optparse.rb +4 -43
  22. data/lib/hieracles/puppetdb.rb +12 -0
  23. data/lib/hieracles/puppetdb/apierror.rb +10 -0
  24. data/lib/hieracles/puppetdb/client.rb +63 -0
  25. data/lib/hieracles/puppetdb/filter.rb +15 -0
  26. data/lib/hieracles/puppetdb/fixsslconnectionadapter.rb +25 -0
  27. data/lib/hieracles/puppetdb/query.rb +79 -0
  28. data/lib/hieracles/puppetdb/request.rb +44 -0
  29. data/lib/hieracles/puppetdb/response.rb +14 -0
  30. data/ppdb.1 +158 -0
  31. data/spec/files/config.yml +2 -0
  32. data/spec/files/config_withdb.yml +9 -0
  33. data/spec/files/facts.json +110 -0
  34. data/spec/files/facts.yaml +103 -0
  35. data/spec/files/hiera_columns.yaml +16 -0
  36. data/spec/files/hiera_deep.yaml +17 -0
  37. data/spec/files/hiera_deeper.yaml +17 -0
  38. data/spec/files/ssl/bad-ca.crt +1 -0
  39. data/spec/files/ssl/bad-cert.crt +1 -0
  40. data/spec/files/ssl/bad-key.pem +1 -0
  41. data/spec/files/ssl/ca.crt +16 -0
  42. data/spec/files/ssl/cert.crt +16 -0
  43. data/spec/files/ssl/key-pass.pem +18 -0
  44. data/spec/files/ssl/key.pem +15 -0
  45. data/spec/lib/config_spec.rb +51 -11
  46. data/spec/lib/format_spec.rb +5 -0
  47. data/spec/lib/formats/console_spec.rb +24 -3
  48. data/spec/lib/formats/csv_spec.rb +15 -0
  49. data/spec/lib/formats/json_spec.rb +22 -2
  50. data/spec/lib/formats/plain_spec.rb +23 -3
  51. data/spec/lib/formats/rawyaml_spec.rb +13 -0
  52. data/spec/lib/formats/yaml_spec.rb +138 -48
  53. data/spec/lib/hiera_spec.rb +0 -1
  54. data/spec/lib/hieracles_spec.rb +8 -0
  55. data/spec/lib/interpolate_spec.rb +49 -0
  56. data/spec/lib/node_spec.rb +50 -9
  57. data/spec/lib/notification_spec.rb +29 -0
  58. data/spec/lib/options/hc_spec.rb +82 -0
  59. data/spec/lib/optparse_spec.rb +7 -7
  60. data/spec/lib/puppetdb/apierror_spec.rb +11 -0
  61. data/spec/lib/puppetdb/client_spec.rb +64 -0
  62. data/spec/lib/puppetdb/fixsslconnectionadapter_spec.rb +107 -0
  63. data/spec/lib/puppetdb/query_spec.rb +39 -0
  64. data/spec/lib/puppetdb/request_spec.rb +61 -0
  65. data/spec/lib/puppetdb/response_spec.rb +13 -0
  66. data/spec/spec_helper.rb +4 -4
  67. metadata +133 -30
  68. data/Rakefile +0 -14
  69. data/hieracles.gemspec +0 -90
  70. data/lib/hieracles/help.rb +0 -38
  71. data/spec/lib/help_spec.rb +0 -8
@@ -1,5 +1,7 @@
1
1
  ---
2
+ basepath: spec/files
2
3
  classpath: farm_modules/%s.pp
3
4
  modulepath: modules
4
5
  hierafile: hiera.yaml
5
6
  paramspath: params
7
+ usedb: false
@@ -0,0 +1,9 @@
1
+ ---
2
+ basepath: spec/files
3
+ classpath: farm_modules/%s.pp
4
+ modulepath: modules
5
+ hierafile: hiera.yaml
6
+ paramspath: params
7
+ usedb: true
8
+ puppetdb:
9
+ host: localhost
@@ -0,0 +1,110 @@
1
+ {
2
+ "uptime_days": 103,
3
+ "hardwaremodel": "x86_64",
4
+ "kernelmajversion": "3.12",
5
+ "lsbminordistrelease": "1",
6
+ "filesystems": "ext2,ext3,ext4",
7
+ "path": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
8
+ "fqdn": "dev.example.com",
9
+ "kernel": "Linux",
10
+ "blockdevice_sda_size": 3221225472,
11
+ "blockdevice_sda_vendor": "vendor",
12
+ "blockdevice_sda_model": "QEMU HARDDISK",
13
+ "blockdevice_sdb_size": 536870912,
14
+ "blockdevice_sdb_vendor": "vendor",
15
+ "blockdevice_sdb_model": "QEMU HARDDISK",
16
+ "blockdevices": "sda,sdb",
17
+ "lsbdistrelease": "8.1",
18
+ "selinux": "false",
19
+ "operatingsystemmajrelease": "8",
20
+ "operatingsystem": "Debian",
21
+ "ps": "ps -ef",
22
+ "kernelrelease": "3.12.36-guest-27-c9b6624-x86_64",
23
+ "netmask": "255.255.254.0",
24
+ "virtual": "kvm",
25
+ "is_virtual": "true",
26
+ "uniqueid": "960a0508",
27
+ "network_eth0": "10.0.0.0",
28
+ "network_lo": "127.0.0.0",
29
+ "uptime": "103 days",
30
+ "processors": {
31
+ "models": [
32
+ "Intel(R) Xeon(R) CPU E5-2650L 0 @ 1.80GHz"
33
+ ],
34
+ "count": 1,
35
+ "physicalcount": 1
36
+ },
37
+ "lsbdistcodename": "jessie",
38
+ "interfaces": "eth0,lo",
39
+ "ipaddress_eth0": "10.0.0.42",
40
+ "macaddress_eth0": "00:11:22:33:44:55",
41
+ "netmask_eth0": "255.255.254.0",
42
+ "mtu_eth0": "1500",
43
+ "ipaddress_lo": "127.0.0.1",
44
+ "netmask_lo": "255.0.0.0",
45
+ "mtu_lo": "65536",
46
+ "lsbmajdistrelease": "8",
47
+ "memorysize": "891.80 MB",
48
+ "memoryfree": "745.47 MB",
49
+ "swapsize": "512.00 MB",
50
+ "swapfree": "511.82 MB",
51
+ "swapsize_mb": "512.00",
52
+ "swapfree_mb": "511.82",
53
+ "memorysize_mb": "891.80",
54
+ "memoryfree_mb": "745.47",
55
+ "macaddress": "00:11:22:33:44:55",
56
+ "kernelversion": "3.12.36",
57
+ "lsbdistid": "Debian",
58
+ "id": "root",
59
+ "lsbdistdescription": "Debian GNU/Linux 8.1 (jessie)",
60
+ "physicalprocessorcount": "1",
61
+ "domain": "example.com",
62
+ "architecture": "amd64",
63
+ "os": {
64
+ "name": "Debian",
65
+ "family": "Debian",
66
+ "release": {
67
+ "major": "8",
68
+ "minor": "1",
69
+ "full": "8.1"
70
+ },
71
+ "lsb": {
72
+ "distcodename": "jessie",
73
+ "distid": "Debian",
74
+ "distdescription": "Debian GNU/Linux 8.1 (jessie)",
75
+ "distrelease": "8.1",
76
+ "majdistrelease": "8",
77
+ "minordistrelease": "1"
78
+ }
79
+ },
80
+ "gid": "root",
81
+ "system_uptime": {
82
+ "seconds": 8982844,
83
+ "hours": 2495,
84
+ "days": 103,
85
+ "uptime": "103 days"
86
+ },
87
+ "uptime_seconds": 8982844,
88
+ "hardwareisa": "unknown",
89
+ "rubysitedir": "/usr/local/lib/site_ruby/2.1.0",
90
+ "facterversion": "2.2.0",
91
+ "augeasversion": "1.2.0",
92
+ "operatingsystemrelease": "8.1",
93
+ "uptime_hours": 2495,
94
+ "puppetversion": "3.7.2",
95
+ "bios_vendor": "SeaBIOS",
96
+ "bios_version": "rel-1.7.5.1-0-g8936dbb-20141113_115728-nilsson.home.kraxel.org",
97
+ "bios_release_date": "04/01/2014",
98
+ "manufacturer": "QEMU",
99
+ "productname": "Standard PC (i440FX + PIIX, 1996)",
100
+ "serialnumber": "Not Specified",
101
+ "uuid": "Not Settable",
102
+ "type": "Other",
103
+ "processor0": "Intel(R) Xeon(R) CPU E5-2650L 0 @ 1.80GHz",
104
+ "processorcount": "1",
105
+ "rubyversion": "2.1.5",
106
+ "osfamily": "Debian",
107
+ "ipaddress": "10.0.0.42",
108
+ "hostname": "dev",
109
+ "timezone": "CET"
110
+ }
@@ -0,0 +1,103 @@
1
+ ---
2
+ uptime_days: 103
3
+ hardwaremodel: x86_64
4
+ kernelmajversion: "3.12"
5
+ lsbminordistrelease: "1"
6
+ filesystems: "ext2,ext3,ext4"
7
+ path: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
8
+ fqdn: dev.example.com
9
+ kernel: Linux
10
+ blockdevice_sda_size: 3221225472
11
+ blockdevice_sda_vendor: vendor
12
+ blockdevice_sda_model: "QEMU HARDDISK"
13
+ blockdevice_sdb_size: 536870912
14
+ blockdevice_sdb_vendor: vendor
15
+ blockdevice_sdb_model: "QEMU HARDDISK"
16
+ blockdevices: "sda,sdb"
17
+ lsbdistrelease: "8.1"
18
+ selinux: "false"
19
+ operatingsystemmajrelease: "8"
20
+ operatingsystem: Debian
21
+ ps: "ps -ef"
22
+ kernelrelease: "3.12.36-guest-27-c9b6624-x86_64"
23
+ netmask: "255.255.254.0"
24
+ virtual: kvm
25
+ is_virtual: "true"
26
+ uniqueid: "960a0508"
27
+ network_eth0: "10.0.0.0"
28
+ network_lo: "127.0.0.0"
29
+ uptime: "103 days"
30
+ processors:
31
+ models:
32
+ - "Intel(R) Xeon(R) CPU E5-2650L 0 @ 1.80GHz"
33
+ count: 1
34
+ physicalcount: 1
35
+ lsbdistcodename: jessie
36
+ interfaces: "eth0,lo"
37
+ ipaddress_eth0: "10.0.0.42"
38
+ macaddress_eth0: "00:11:22:33:44:55"
39
+ netmask_eth0: "255.255.254.0"
40
+ mtu_eth0: "1500"
41
+ ipaddress_lo: "127.0.0.1"
42
+ netmask_lo: "255.0.0.0"
43
+ mtu_lo: "65536"
44
+ lsbmajdistrelease: "8"
45
+ memorysize: "891.80 MB"
46
+ memoryfree: "745.68 MB"
47
+ swapsize: "512.00 MB"
48
+ swapfree: "511.82 MB"
49
+ swapsize_mb: "512.00"
50
+ swapfree_mb: "511.82"
51
+ memorysize_mb: "891.80"
52
+ memoryfree_mb: "745.68"
53
+ macaddress: "00:11:22:33:44:55"
54
+ kernelversion: "3.12.36"
55
+ lsbdistid: Debian
56
+ id: root
57
+ lsbdistdescription: "Debian GNU/Linux 8.1 (jessie)"
58
+ physicalprocessorcount: "1"
59
+ domain: example.com
60
+ architecture: amd64
61
+ os:
62
+ name: Debian
63
+ family: Debian
64
+ release:
65
+ major: "8"
66
+ minor: "1"
67
+ full: "8.1"
68
+ lsb:
69
+ distcodename: jessie
70
+ distid: Debian
71
+ distdescription: "Debian GNU/Linux 8.1 (jessie)"
72
+ distrelease: "8.1"
73
+ majdistrelease: "8"
74
+ minordistrelease: "1"
75
+ gid: root
76
+ system_uptime:
77
+ seconds: 8982629
78
+ hours: 2495
79
+ days: 103
80
+ uptime: "103 days"
81
+ uptime_seconds: 8982629
82
+ hardwareisa: unknown
83
+ rubysitedir: /usr/local/lib/site_ruby/2.1.0
84
+ facterversion: "2.2.0"
85
+ augeasversion: "1.2.0"
86
+ operatingsystemrelease: "8.1"
87
+ uptime_hours: 2495
88
+ puppetversion: "3.7.2"
89
+ bios_vendor: SeaBIOS
90
+ bios_version: rel-1.7.5.1-0-g8936dbb-20141113_115728-nilsson.home.kraxel.org
91
+ bios_release_date: "04/01/2014"
92
+ manufacturer: QEMU
93
+ productname: "Standard PC (i440FX + PIIX, 1996)"
94
+ serialnumber: "Not Specified"
95
+ uuid: "Not Settable"
96
+ type: Other
97
+ processor0: "Intel(R) Xeon(R) CPU E5-2650L 0 @ 1.80GHz"
98
+ processorcount: "1"
99
+ rubyversion: "2.1.5"
100
+ osfamily: Debian
101
+ ipaddress: "10.0.0.42"
102
+ hostname: dev
103
+ timezone: CET
@@ -0,0 +1,16 @@
1
+ ---
2
+ :backends:
3
+ - yaml
4
+ :hierarchy:
5
+ - "nodes/%{::fqdn}"
6
+ - "farm_datacenter/%{farm}_%{datacenter}"
7
+ - "farm/%{farm}"
8
+ - "room/%{room}"
9
+ - "datacenter/%{datacenter}"
10
+ - "country/%{country}"
11
+ - "os/%{operatingsystem}-%{lsbdistcodename}"
12
+ - "common/common"
13
+ :yaml:
14
+ :datadir: "params/"
15
+ :puppet:
16
+ :datasource: data
@@ -0,0 +1,17 @@
1
+ ---
2
+ :backends:
3
+ - yaml
4
+ :hierarchy:
5
+ - "nodes/%{fqdn}"
6
+ - "farm_datacenter/%{farm}_%{datacenter}"
7
+ - "farm/%{farm}"
8
+ - "room/%{room}"
9
+ - "datacenter/%{datacenter}"
10
+ - "country/%{country}"
11
+ - "os/%{operatingsystem}-%{lsbdistcodename}"
12
+ - "common/common"
13
+ :yaml:
14
+ :datadir: "params/"
15
+ :puppet:
16
+ :datasource: data
17
+ :merge_behavior: deep
@@ -0,0 +1,17 @@
1
+ ---
2
+ :backends:
3
+ - yaml
4
+ :hierarchy:
5
+ - "nodes/%{fqdn}"
6
+ - "farm_datacenter/%{farm}_%{datacenter}"
7
+ - "farm/%{farm}"
8
+ - "room/%{room}"
9
+ - "datacenter/%{datacenter}"
10
+ - "country/%{country}"
11
+ - "os/%{operatingsystem}-%{lsbdistcodename}"
12
+ - "common/common"
13
+ :yaml:
14
+ :datadir: "params/"
15
+ :puppet:
16
+ :datasource: data
17
+ :merge_behavior: deeper
@@ -0,0 +1 @@
1
+ hoho
@@ -0,0 +1 @@
1
+ blah
@@ -0,0 +1 @@
1
+ haha
@@ -0,0 +1,16 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIICbzCCAdgCCQD7Pot5tsdUFTANBgkqhkiG9w0BAQsFADB8MQswCQYDVQQGEwJG
3
+ UjETMBEGA1UECAwKU29tZS1TdGF0ZTEOMAwGA1UEBwwFUGFyaXMxDjAMBgNVBAoM
4
+ BUdhbmRpMRkwFwYDVQQDDBBwdXBwZXQuZ2FuZGkubmV0MR0wGwYJKoZIhvcNAQkB
5
+ Fg5tb3NlQGdhbmRpLm5ldDAeFw0xNTExMjgwNDE3MjZaFw0xNjExMjcwNDE3MjZa
6
+ M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WnsHjd
10
+ Ml5zUR01W6JMlFfpP0QOrNV4cf3TarqU4wJBANFRUuNmV95pU0xD/bNcyUeTp2tM
11
+ 7fUrVEj6YVcbihcIjzGl+jAfdXhg/rIN6bGpjF99itYR1Zejwcss3SD6FVUCQHey
12
+ JtERcKdy1CBDn64po53Pcun2AIMJ8c9OIMmktzZynHxUn5QaA9NfATjgX1JLg2J8
13
+ cVfqsxRi03YVIRUC++sCQEjGe20GtL1XWluF52lYFKAXpI+vfwvnht0ehaGiqvxg
14
+ /maZAbJnHbPvgMWLyVifzFidlK9pUGTyg3j+M6lw/LA=
15
+ -----END RSA PRIVATE KEY-----
@@ -3,12 +3,7 @@ require 'spec_helper'
3
3
  describe Hieracles::Config do
4
4
  describe '.load' do
5
5
  context 'with an existing file' do
6
- let(:options) do
7
- {
8
- config: 'spec/files/config.yml',
9
- basepath: 'spec/files'
10
- }
11
- end
6
+ let(:options) { { config: 'spec/files/config.yml' } }
12
7
  let(:expected) do
13
8
  {
14
9
  classpath: File.expand_path('spec/files/farm_modules/%s.pp'),
@@ -31,7 +26,6 @@ describe Hieracles::Config do
31
26
  let(:options) do
32
27
  {
33
28
  config: 'spec/files/config.yml',
34
- basepath: 'spec/files',
35
29
  hierafile: hierapath
36
30
  }
37
31
  end
@@ -52,11 +46,47 @@ describe Hieracles::Config do
52
46
  end
53
47
  end
54
48
 
49
+ context 'with db set' do
50
+ context 'when no param is provided' do
51
+ let(:options) do
52
+ {
53
+ config: 'spec/files/config_withdb.yml'
54
+ }
55
+ end
56
+ before { Hieracles::Config.load options }
57
+ it { expect(Hieracles::Config.usedb).to be_truthy }
58
+ end
59
+ context 'with nodb passed as param' do
60
+ let(:options) do
61
+ {
62
+ config: 'spec/files/config_withdb.yml',
63
+ nodb: true
64
+ }
65
+ end
66
+ before { Hieracles::Config.load options }
67
+ it { expect(Hieracles::Config.usedb).to be_falsey }
68
+ end
69
+ end
70
+
71
+ context 'with no-db set' do
72
+ context 'and db passed as param' do
73
+ let(:options) do
74
+ {
75
+ config: 'spec/files/config.yml',
76
+ db: true
77
+ }
78
+ end
79
+ before { Hieracles::Config.load options }
80
+ it { expect(Hieracles::Config.usedb).to be_truthy }
81
+ end
82
+ end
83
+
84
+
55
85
  context 'without an existing config file' do
56
86
  let(:options) do
57
87
  {
58
- basepath: 'spec/files',
59
- config: 'spec/files/config_no.yml'
88
+ config: 'spec/files/config_no.yml',
89
+ basepath: 'spec/files'
60
90
  }
61
91
  end
62
92
  before do
@@ -90,7 +120,6 @@ describe Hieracles::Config do
90
120
  let(:options) do
91
121
  {
92
122
  config: 'spec/files/config.yml',
93
- basepath: 'spec/files',
94
123
  yaml_facts: 'spec/files/facts.yaml'
95
124
  }
96
125
  end
@@ -103,7 +132,6 @@ describe Hieracles::Config do
103
132
  let(:options) do
104
133
  {
105
134
  config: 'spec/files/config.yml',
106
- basepath: 'spec/files',
107
135
  json_facts: 'spec/files/facts.json'
108
136
  }
109
137
  end
@@ -114,4 +142,16 @@ describe Hieracles::Config do
114
142
  end
115
143
  end
116
144
 
145
+ describe '.resolve_path' do
146
+ context "when path is found" do
147
+ let(:path) { 'README.md' }
148
+ let(:expected) { File.expand_path('README.md') }
149
+ it { expect(Hieracles::Config.resolve_path(path)).to eq expected }
150
+ end
151
+ context "when path is not found anywhere" do
152
+ let(:path) { 'README-NOT.md' }
153
+ it { expect { Hieracles::Config.resolve_path(path) }.to raise_error(IOError) }
154
+ end
155
+ end
156
+
117
157
  end