chef_handler_foreman 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/README.md +34 -0
- data/lib/chef_handler_foreman/foreman_facts.rb +5 -5
- data/lib/chef_handler_foreman/foreman_hooks.rb +9 -2
- data/lib/chef_handler_foreman/foreman_reporting.rb +1 -1
- data/lib/chef_handler_foreman/foreman_resource_reporter.rb +23 -7
- data/lib/chef_handler_foreman/version.rb +1 -1
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21fab85d6ff9110b08cc8e2ee0282c3a3115bee1
|
4
|
+
data.tar.gz: c0e49b5679ef653d329936ac1e5d5084221af978
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cdb697d5e51963f999af809a768d3552b2efabd92ce39b4527ac05ffdb174541cc09693fbf64e3ae24b095826413024f0f1296df5038d9449a0b67618ddeba1
|
7
|
+
data.tar.gz: 999b4f8cd62099bf400e4274e34f7dc2a6ea79324ded6d072ce1dcc17f22bdd9b9c1fecbd45d53daa94ce7541e27961deeee2e28fb7f79b987c66b8dcda3a963
|
data/README.md
CHANGED
@@ -20,6 +20,8 @@ In /etc/chef/client.rb:
|
|
20
20
|
require 'chef_handler_foreman'
|
21
21
|
# here you can specify your connection options
|
22
22
|
foreman_server_options :url => 'http://your.server/foreman'
|
23
|
+
# Or another option to set URL if using chef-client cookbook config option
|
24
|
+
foreman_server_url 'http://foreman.domain.com'
|
23
25
|
# add following line if you want to upload node attributes (facts in Foreman language)
|
24
26
|
foreman_facts_upload true
|
25
27
|
## Facts whitelist / blacklisting
|
@@ -35,6 +37,34 @@ foreman_reports_upload true
|
|
35
37
|
reports_log_level "notice"
|
36
38
|
```
|
37
39
|
|
40
|
+
### Using Chef-Client Cookbook
|
41
|
+
|
42
|
+
You can utilize the [Chef-Client](https://github.com/chef-cookbooks/chef-client) Cookbook to setup your client.rb
|
43
|
+
|
44
|
+
With a Role
|
45
|
+
|
46
|
+
```json
|
47
|
+
"chef_client": {
|
48
|
+
"chef_server_url": "https://chef.domain.com",
|
49
|
+
"config": {
|
50
|
+
"foreman_server_url": "https://foreman.domain.com",
|
51
|
+
"foreman_facts_upload": true,
|
52
|
+
"foreman_reports_upload": true,
|
53
|
+
"reports_log_level": "notice"
|
54
|
+
}
|
55
|
+
}
|
56
|
+
```
|
57
|
+
|
58
|
+
With attributes
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
node['chef_client']['config']['foreman_server_url'] = 'https://foreman.domain.com'
|
62
|
+
node['chef_client']['config']['foreman_facts_upload'] = true
|
63
|
+
node['chef_client']['config']['foreman_reports_upload'] = true
|
64
|
+
node['chef_client']['config']['reports_log_level'] = 'notice'
|
65
|
+
```
|
66
|
+
|
67
|
+
|
38
68
|
You can also specify a second argument to foreman_reports_upload which is a number:
|
39
69
|
- 1 (default) for reporter based on more detailed ResourceReporter
|
40
70
|
- 2 not so verbose based just on run_status, actually just counts applied resources
|
@@ -61,3 +91,7 @@ Cherry picking which facts to upload, coupled with caching, allows to scale the
|
|
61
91
|
thousands of nodes. Note, however, that some attributes are expected by Foreman to exist, and thus
|
62
92
|
should not be blacklisted. The whitelist and blacklist examples above include a minimal set of
|
63
93
|
attributes known to work in a large scale production environment.
|
94
|
+
|
95
|
+
Note that the order of config options matter. Blacklist/whitelist must be below foreman_facts_upload
|
96
|
+
line.
|
97
|
+
|
@@ -34,11 +34,11 @@ module ChefHandlerForeman
|
|
34
34
|
|
35
35
|
os, release = nil
|
36
36
|
if node.respond_to?(:lsb)
|
37
|
-
os = node
|
38
|
-
release = node
|
37
|
+
os = node['lsb']['id']
|
38
|
+
release = node['lsb']['release']
|
39
39
|
end
|
40
|
-
os ||= node
|
41
|
-
release ||= node
|
40
|
+
os ||= node['platform']
|
41
|
+
release ||= node['platform_version']
|
42
42
|
|
43
43
|
# operatingsystem and operatingsystemrelase are not needed since foreman_chef 0.1.3
|
44
44
|
{ :name => node.name.downcase,
|
@@ -53,7 +53,7 @@ module ChefHandlerForeman
|
|
53
53
|
}
|
54
54
|
end
|
55
55
|
|
56
|
-
# if node
|
56
|
+
# if node['lsb']['id'] fails and we use platform instead, normalize os names
|
57
57
|
def normalize(os)
|
58
58
|
case os
|
59
59
|
when 'redhat'
|
@@ -10,9 +10,16 @@ require "#{File.dirname(__FILE__)}/foreman_uploader"
|
|
10
10
|
|
11
11
|
module ChefHandlerForeman
|
12
12
|
module ForemanHooks
|
13
|
+
|
14
|
+
# Provide a chef-client cookbook friendly option
|
15
|
+
def foreman_server_url(url)
|
16
|
+
foreman_server_options(:url => url)
|
17
|
+
end
|
18
|
+
|
13
19
|
# {:url => '', ...}
|
14
|
-
def foreman_server_options(options)
|
15
|
-
options
|
20
|
+
def foreman_server_options(options={})
|
21
|
+
options[:client_key] = client_key || '/etc/chef/client.pem' unless options[:client_key]
|
22
|
+
raise "No Foreman URL! Please provide a URL" unless options[:url]
|
16
23
|
@foreman_uploader = ForemanUploader.new(options)
|
17
24
|
# set uploader if handlers are already created
|
18
25
|
@foreman_facts_handler.uploader = @foreman_uploader if @foreman_facts_handler
|
@@ -18,7 +18,7 @@ module ChefHandlerForeman
|
|
18
18
|
attr_accessor :uploader
|
19
19
|
|
20
20
|
def report
|
21
|
-
report = { 'host' => node
|
21
|
+
report = { 'host' => node['fqdn'].downcase, 'reported_at' => Time.now.utc.to_s }
|
22
22
|
report_status = Hash.new(0)
|
23
23
|
|
24
24
|
|
@@ -68,6 +68,10 @@ module ChefHandlerForeman
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
def resource_bypassed(*args)
|
72
|
+
@why_run = true
|
73
|
+
end
|
74
|
+
|
71
75
|
def post_reporting_data
|
72
76
|
if reporting_enabled?
|
73
77
|
run_data = prepare_run_data
|
@@ -105,13 +109,25 @@ module ChefHandlerForeman
|
|
105
109
|
end
|
106
110
|
|
107
111
|
def resources_per_status
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
112
|
+
if @why_run
|
113
|
+
{
|
114
|
+
"applied" => @total_updated,
|
115
|
+
"restarted" => @total_restarted,
|
116
|
+
"failed" => @total_failed,
|
117
|
+
"failed_restarts" => @total_failed_restart,
|
118
|
+
"skipped" => @total_skipped,
|
119
|
+
"pending" => 0
|
120
|
+
}
|
121
|
+
else
|
122
|
+
{
|
123
|
+
"applied" => 0,
|
124
|
+
"restarted" => 0,
|
125
|
+
"failed" => 0,
|
126
|
+
"failed_restarts" => 0,
|
127
|
+
"skipped" => @total_skipped,
|
128
|
+
"pending" => @total_updated + @total_restarted + @total_failed + @total_failed_restart
|
129
|
+
}
|
130
|
+
end
|
115
131
|
end
|
116
132
|
|
117
133
|
def resources_per_time
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef_handler_foreman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marek Hulan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: Chef handlers to integrate with foreman
|
@@ -65,20 +65,19 @@ require_paths:
|
|
65
65
|
- lib
|
66
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.4.
|
78
|
+
rubygems_version: 2.4.5
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: This gem adds chef handlers so your chef-client can upload attributes (facts)
|
82
82
|
and reports to Foreman
|
83
83
|
test_files: []
|
84
|
-
has_rdoc:
|