ncedit 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/exe/ncedit +8 -0
- data/lib/ncedit/cmd.rb +17 -2
- data/lib/ncedit/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: 10ab95a17f8d56d2402fcaed7806eb747d188ac9
|
4
|
+
data.tar.gz: cd3418a0471e0182176afab8a84b04dc5cb2fa85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 724f3a28bf6580603125026f92b98cc04f110d20485a48c3df1b6e02c8345321b5f2e6cded1599a4777afd069f6333f15cf79ab0608c750ad835f9d5266aaf87
|
7
|
+
data.tar.gz: 8e1aeee6e7c1fd300954540fca8b2ae3eebe7bc9dc7adf5a06206c8d9501d792e46ed7f66d67e46365b839ae41fe23ac8cde70ae000470e41d36f597bac2af87
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ ncedit is a small utility program that lets you edit the Puppet Enterprise Node
|
|
5
5
|
|
6
6
|
Why would you want to do this given that we have the excellent [node_manager](https://forge.puppet.com/WhatsARanjit/node_manager) module already on the forge? Well... lots of reasons. First off, using puppet code to drive the Node Classifier means that you have to have the `node_manager` module alread installed, which means that you must already have your [classification rules](https://docs.puppet.com/pe/latest/console_classes_groups_getting_started.html) in to reference the module through [Code Manager](https://docs.puppet.com/pe/latest/code_mgr.html). You could in-theory use Puppet Enterprise's new idempotent installer (just reinstall puppet over the top of itself) to fix this exact issue but then you still have the problem of how to classify your master in order to activate any other new rules (eg node-ttl) you want to use, which are associated with a new [role](https://docs.puppet.com/pe/latest/r_n_p_intro.html) for the Puppet Master.
|
7
7
|
|
8
|
-
That's where this tool comes in since all you need is root shell on the Puppet Master
|
8
|
+
That's where this tool comes in since all you need is root shell on the Puppet Master.
|
9
9
|
|
10
10
|
## Features
|
11
11
|
You can:
|
@@ -16,7 +16,7 @@ You can:
|
|
16
16
|
|
17
17
|
...All from the convenience of the CLI. This also allows this tool to be called from scripts and other systems in order to setup Puppet Enterprise the way you want and with the minimum of effort.
|
18
18
|
|
19
|
-
|
19
|
+
You have a choice of running `ncedit` for each change you wish to make or collecting all of your edits into either a JSON or YAML file for bulk processing.
|
20
20
|
|
21
21
|
## Installation
|
22
22
|
Install this tool on your Puppet Master (Master-of-Masters)
|
@@ -49,7 +49,7 @@ In each case the file needs to be ordered as follows:
|
|
49
49
|
"OPTIONAL_PARAM_NAME": "VALUE_TO_SET"
|
50
50
|
# Array of classes to delete
|
51
51
|
"delete_classes":
|
52
|
-
|
52
|
+
- "CLASS_TO_DELETE"
|
53
53
|
# Hash classes + Array of parameter names to delete
|
54
54
|
"delete_params":
|
55
55
|
"CLASS_TO_PROCESS":
|
@@ -97,7 +97,7 @@ In each case the file needs to be ordered as follows:
|
|
97
97
|
* [Worked example](doc/example/batch.json)
|
98
98
|
|
99
99
|
#### Ensuring changes
|
100
|
-
* ncedit is idempotent so you may run the command as often as you like
|
100
|
+
* `ncedit` is idempotent so you may run the command as often as you like
|
101
101
|
|
102
102
|
##### YAML
|
103
103
|
```shell
|
data/exe/ncedit
CHANGED
@@ -88,4 +88,12 @@ Escort::App.create do |app|
|
|
88
88
|
NCEdit::Cmd::batch(yaml_file: yaml_file, json_file: json_file)
|
89
89
|
end
|
90
90
|
end
|
91
|
+
|
92
|
+
app.command :update_classes do |command|
|
93
|
+
command.summary "Refresh the classes available in the console"
|
94
|
+
command.description "Invalidate class cache and ask puppet to re-scan classes"
|
95
|
+
command.action do |options, arguments|
|
96
|
+
NCEdit::Cmd::update_classes()
|
97
|
+
end
|
98
|
+
end
|
91
99
|
end
|
data/lib/ncedit/cmd.rb
CHANGED
@@ -2,6 +2,7 @@ require 'puppetclassify'
|
|
2
2
|
require 'yaml'
|
3
3
|
require 'json'
|
4
4
|
require 'escort'
|
5
|
+
require 'puppet_https'
|
5
6
|
|
6
7
|
module NCEdit
|
7
8
|
module Cmd
|
@@ -16,9 +17,12 @@ module NCEdit
|
|
16
17
|
hostname = %x(facter fqdn).strip.downcase
|
17
18
|
port = 4433
|
18
19
|
|
20
|
+
|
19
21
|
# Define the url to the classifier API - we can't just do localhost because
|
20
22
|
# the name has to match the SSL certificate
|
21
|
-
|
23
|
+
base_url = "https://#{hostname}:"
|
24
|
+
@puppet_url = "#{base_url}8140"
|
25
|
+
@rest_api_url = "#{base_url}#{port}/classifier-api"
|
22
26
|
|
23
27
|
# We need to authenticate against the REST API using a certificate
|
24
28
|
# that is whitelisted in /etc/puppetlabs/console-services/rbac-certificate-whitelist.
|
@@ -54,7 +58,10 @@ module NCEdit
|
|
54
58
|
end
|
55
59
|
end
|
56
60
|
|
57
|
-
@puppetclassify = PuppetClassify.new(rest_api_url, auth_info)
|
61
|
+
@puppetclassify = PuppetClassify.new(@rest_api_url, auth_info)
|
62
|
+
|
63
|
+
# borrow the cool HTTPS requester built into puppetclassify
|
64
|
+
@puppet_https = PuppetHttps.new(auth_info)
|
58
65
|
end
|
59
66
|
end
|
60
67
|
|
@@ -486,5 +493,13 @@ module NCEdit
|
|
486
493
|
Escort::Logger.output.puts "Already up-to-date"
|
487
494
|
end
|
488
495
|
end
|
496
|
+
|
497
|
+
def self.update_classes
|
498
|
+
if ! @puppetclassify
|
499
|
+
init
|
500
|
+
end
|
501
|
+
@puppet_https.delete("#{@puppet_url}/puppet-admin-api/v1/environment-cache")
|
502
|
+
@puppet_https.post("#{@rest_api_url}/v1/update-classes")
|
503
|
+
end
|
489
504
|
end
|
490
505
|
end
|
data/lib/ncedit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ncedit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geoff Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|