rehai 0.0.1
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.
- data/.gitignore +1 -0
- data/README.md +9 -0
- data/bin/rehai +93 -0
- data/rehai.gemspec +13 -0
- metadata +51 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rehai-*.gem
|
data/README.md
ADDED
data/bin/rehai
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'chef'
|
4
|
+
require 'chef/application'
|
5
|
+
begin
|
6
|
+
# Had to add this because there is a bug in chef where the chef/application uses it but doesn't require it (11.8.2)
|
7
|
+
require 'chef/config_fetcher'
|
8
|
+
rescue LoadError
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
class Chef::Application::Rehai < Chef::Application
|
13
|
+
|
14
|
+
# config options nicked from Chef::Application::Client
|
15
|
+
option :config_file,
|
16
|
+
:short => "-c CONFIG",
|
17
|
+
:long => "--config CONFIG",
|
18
|
+
:default => "/etc/chef/client.rb",
|
19
|
+
:description => "The configuration file to use"
|
20
|
+
option :log_level,
|
21
|
+
:short => "-l LEVEL",
|
22
|
+
:long => "--log_level LEVEL",
|
23
|
+
:description => "Set the log level (debug, info, warn, error, fatal)",
|
24
|
+
:proc => lambda { |l| l.to_sym }
|
25
|
+
option :log_location,
|
26
|
+
:short => "-L LOGLOCATION",
|
27
|
+
:long => "--logfile LOGLOCATION",
|
28
|
+
:description => "Set the log file location, defaults to STDOUT - recommended for daemonizing",
|
29
|
+
:proc => nil
|
30
|
+
option :help,
|
31
|
+
:short => "-h",
|
32
|
+
:long => "--help",
|
33
|
+
:description => "Show this message",
|
34
|
+
:on => :tail,
|
35
|
+
:boolean => true,
|
36
|
+
:show_options => true,
|
37
|
+
:exit => 0
|
38
|
+
option :node_name,
|
39
|
+
:short => "-N NODE_NAME",
|
40
|
+
:long => "--node-name NODE_NAME",
|
41
|
+
:description => "The node name for this client",
|
42
|
+
:proc => nil
|
43
|
+
option :chef_server_url,
|
44
|
+
:short => "-S CHEFSERVERURL",
|
45
|
+
:long => "--server CHEFSERVERURL",
|
46
|
+
:description => "The chef server URL",
|
47
|
+
:proc => nil
|
48
|
+
option :client_key,
|
49
|
+
:short => "-k KEY_FILE",
|
50
|
+
:long => "--client_key KEY_FILE",
|
51
|
+
:description => "Set the client key file location",
|
52
|
+
:proc => nil
|
53
|
+
attr_reader :chef_client_json
|
54
|
+
|
55
|
+
# pull configuration settings from the config file(s), most
|
56
|
+
# likely in /etc/chef/client.rb
|
57
|
+
def setup_application
|
58
|
+
parse_options
|
59
|
+
::File::open(config[:config_file]) { |f|
|
60
|
+
Chef::Config.from_file(f.path)
|
61
|
+
Chef::Config.merge!(config)
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
# The meat of our task, do an ohai run and update the
|
66
|
+
# nodes attributes then post back to
|
67
|
+
def run_application
|
68
|
+
|
69
|
+
# Do an ohai run to find the current system state
|
70
|
+
ohai = Ohai::System.new
|
71
|
+
ohai.all_plugins
|
72
|
+
|
73
|
+
# Create a reference to the node
|
74
|
+
node_name = Chef::Config[:node_name] || ohai[:fqdn] || ohai[:hostname]
|
75
|
+
Chef::Config[:node_name] = node_name
|
76
|
+
node = Chef::Node.find_or_create(node_name)
|
77
|
+
|
78
|
+
# Clear out existing attributes, some of these may have been deleted
|
79
|
+
node.reset_defaults_and_overrides
|
80
|
+
|
81
|
+
# Set the new attributes, the second argument here is the list of user
|
82
|
+
# supplied attributes from the command line or possibly a config file
|
83
|
+
node.consume_external_attrs(ohai.data, {})
|
84
|
+
|
85
|
+
# Write back to the server
|
86
|
+
node.save
|
87
|
+
# puts Chef::JSONCompat.to_json(node)
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
rehai = Chef::Application::Rehai.new()
|
93
|
+
rehai.run()
|
data/rehai.gemspec
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'rehai'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
s.date = '2014-07-06'
|
5
|
+
s.summary = "Rehai - a chef tool which reloads ohai information without a full chef run!"
|
6
|
+
s.description = s.summary
|
7
|
+
s.authors = ["John Goulah"]
|
8
|
+
s.email = 'jgoulah@gmail.com'
|
9
|
+
s.files = `git ls-files`.split("\n")
|
10
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
11
|
+
s.homepage = 'https://github.com/jgoulah/rehai'
|
12
|
+
s.license = 'MIT'
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rehai
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- John Goulah
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-07-06 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Rehai - a chef tool which reloads ohai information without a full chef
|
15
|
+
run!
|
16
|
+
email: jgoulah@gmail.com
|
17
|
+
executables:
|
18
|
+
- rehai
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- README.md
|
24
|
+
- bin/rehai
|
25
|
+
- rehai.gemspec
|
26
|
+
homepage: https://github.com/jgoulah/rehai
|
27
|
+
licenses:
|
28
|
+
- MIT
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
requirements: []
|
46
|
+
rubyforge_project:
|
47
|
+
rubygems_version: 1.8.24
|
48
|
+
signing_key:
|
49
|
+
specification_version: 3
|
50
|
+
summary: Rehai - a chef tool which reloads ohai information without a full chef run!
|
51
|
+
test_files: []
|