foreman_chef 0.4.2 → 0.5.0
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/app/helpers/foreman_chef/chef_proxy_form.rb +10 -2
- data/app/lib/actions/foreman_chef/client/create.rb +2 -0
- data/app/lib/actions/foreman_chef/client/destroy.rb +1 -1
- data/app/lib/actions/foreman_chef/host/create.rb +1 -1
- data/app/lib/actions/foreman_chef/node/update.rb +2 -0
- data/app/models/foreman_chef/concerns/host_build.rb +14 -0
- data/app/models/foreman_chef/concerns/smart_proxy_extensions.rb +10 -0
- data/app/models/foreman_chef/fact_importer.rb +2 -6
- data/app/models/foreman_chef/fact_parser.rb +12 -2
- data/app/models/setting/foreman_chef.rb +4 -0
- data/app/overrides/add_chef_tab.rb +1 -1
- data/app/services/foreman_chef/host_does_not_have_chef_proxy.rb +4 -0
- data/app/views/foreman/unattended/snippets/_chef_client_bootstrap.erb +4 -0
- data/app/views/foreman_chef/hosts/_chef_tab.html.erb +1 -1
- data/lib/foreman_chef/engine.rb +2 -4
- data/lib/foreman_chef/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57d753bf6cad20e4c8f3f0e42d4cb54c2ea512e2
|
4
|
+
data.tar.gz: 7e475417097bdde646e155490805d0aa7ea3a944
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e320c37bb73d8cbee67781de5ee4eef0d17d21812c5600fb5de76402f6cb891ca906d7c0b1080182d5d848477904689e99dd8149ee5cc00d470072f12abc0f0
|
7
|
+
data.tar.gz: 10665df2e4facabc26657275d43da9c530f8df3d8cc541acba54a639cd02b81bc7147b163f68c7dc3701e0a18607fbfb37fcb40c3456e71ae00f04eeb6a769e2
|
@@ -32,10 +32,14 @@ module ForemanChef
|
|
32
32
|
:data => { :url => environments_for_chef_proxy_foreman_chef_environments_path } })
|
33
33
|
end
|
34
34
|
|
35
|
-
def chef_tab_menu
|
35
|
+
def chef_tab_menu(host)
|
36
36
|
if SmartProxy.with_features("Chef").count > 0
|
37
|
+
warning = ''
|
38
|
+
if chef_run_list_differs?(host)
|
39
|
+
warning = content_tag(:span, ' '.html_safe, :class => "pficon pficon-warning-triangle-o")
|
40
|
+
end
|
37
41
|
content_tag :li do
|
38
|
-
'
|
42
|
+
link_to(warning + _('Chef'), '#chef', :data => { :toggle => 'tab'})
|
39
43
|
end
|
40
44
|
end
|
41
45
|
end
|
@@ -43,5 +47,9 @@ module ForemanChef
|
|
43
47
|
def chef_tab_content(f)
|
44
48
|
render 'foreman_chef/hosts/chef_tab', :f => f
|
45
49
|
end
|
50
|
+
|
51
|
+
def chef_run_list_differs?(host)
|
52
|
+
host.persisted? && host.chef_proxy_id.present? && host.run_list_differs?
|
53
|
+
end
|
46
54
|
end
|
47
55
|
end
|
@@ -4,6 +4,8 @@ module Actions
|
|
4
4
|
class Create < Actions::EntryAction
|
5
5
|
|
6
6
|
def plan(name, proxy)
|
7
|
+
return if proxy.nil?
|
8
|
+
|
7
9
|
client_exists_in_chef = proxy.show_client(name)
|
8
10
|
if client_exists_in_chef
|
9
11
|
raise ::ForemanChef::ObjectExistsException.new(N_('Client with name %s already exist on this Chef proxy' % name))
|
@@ -4,7 +4,7 @@ module Actions
|
|
4
4
|
class Destroy < Actions::EntryAction
|
5
5
|
|
6
6
|
def plan(fqdn, proxy)
|
7
|
-
if ::Setting::ForemanChef.auto_deletion
|
7
|
+
if ::Setting::ForemanChef.auto_deletion && proxy.present?
|
8
8
|
client_exists_in_chef = proxy.show_client(fqdn)
|
9
9
|
if client_exists_in_chef
|
10
10
|
plan_self :chef_proxy_id => proxy.id, :fqdn => fqdn
|
@@ -32,7 +32,7 @@ module Actions
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def finalize
|
35
|
-
if input[:create_action_output][:private_key].present? && Setting.validation_bootstrap_method
|
35
|
+
if input[:create_action_output][:private_key].present? && !Setting.validation_bootstrap_method
|
36
36
|
host = ::Host.find(self.input[:host][:id])
|
37
37
|
host.chef_private_key = input[:create_action_output][:private_key]
|
38
38
|
host.disable_dynflow_hooks { |h| h.save! }
|
@@ -5,6 +5,8 @@ module Actions
|
|
5
5
|
|
6
6
|
def plan(host, proxy)
|
7
7
|
name = host.name
|
8
|
+
raise ::ForemanChef::HostDoesNotHaveChefProxy.new(N_('Host with name %s does not have chef proxy specified but asked to update the node') % name) if proxy.nil?
|
9
|
+
|
8
10
|
node_exists_in_chef = proxy.show_node(name)
|
9
11
|
if node_exists_in_chef
|
10
12
|
# we can't use host.run_list.list_changed? or similar since it's after_save already
|
@@ -6,6 +6,8 @@ module ForemanChef
|
|
6
6
|
include ForemanTasks::Concerns::ActionSubject
|
7
7
|
include ForemanTasks::Concerns::ActionTriggering
|
8
8
|
|
9
|
+
alias_method_chain :setSSHProvisionScript, :chef
|
10
|
+
|
9
11
|
after_build do |host|
|
10
12
|
::ForemanTasks.sync_task ::Actions::ForemanChef::Client::Destroy, host.name, host.chef_proxy
|
11
13
|
# private key is no longer valid
|
@@ -20,6 +22,18 @@ module ForemanChef
|
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
25
|
+
def setSSHProvisionScript_with_chef
|
26
|
+
::ForemanTasks.sync_task ::Actions::ForemanChef::Client::Destroy, self.name, self.chef_proxy
|
27
|
+
# private key is no longer valid
|
28
|
+
self.chef_private_key = nil
|
29
|
+
|
30
|
+
if !::Setting.validation_bootstrap_method
|
31
|
+
new_client = ::ForemanTasks.sync_task ::Actions::ForemanChef::Client::Create, self.name, self.chef_proxy
|
32
|
+
self.chef_private_key = new_client.output[:private_key]
|
33
|
+
end
|
34
|
+
|
35
|
+
self.disable_dynflow_hooks { |h| setSSHProvisionScript_without_chef; h.save! }
|
36
|
+
end
|
23
37
|
end
|
24
38
|
end
|
25
39
|
end
|
@@ -4,9 +4,19 @@ module ForemanChef
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
+
alias_method_chain :taxonomy_foreign_conditions, :chef
|
8
|
+
|
7
9
|
has_many :chef_environments, :class_name => "::ForemanChef::Environment", :foreign_key => 'chef_proxy_id'
|
8
10
|
end
|
9
11
|
|
12
|
+
def taxonomy_foreign_conditions_with_chef
|
13
|
+
conditions = taxonomy_foreign_conditions_without_chef
|
14
|
+
if has_feature?('Chef')
|
15
|
+
conditions[:chef_proxy_id] = id
|
16
|
+
end
|
17
|
+
conditions
|
18
|
+
end
|
19
|
+
|
10
20
|
# create or overwrite instance methods...
|
11
21
|
def show_node(fqdn)
|
12
22
|
reply = ProxyAPI::ForemanChef::ChefProxy.new(:url => url).show_node(fqdn)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module ForemanChef
|
2
|
-
class FactImporter < ::
|
2
|
+
class FactImporter < ::StructuredFactImporter
|
3
3
|
class FactNameImportError < StandardError; end
|
4
4
|
|
5
5
|
def fact_name_class
|
@@ -71,7 +71,7 @@ module ForemanChef
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def facts_to_create
|
74
|
-
@facts_to_create ||= facts.keys - db_facts.
|
74
|
+
@facts_to_create ||= facts.keys - db_facts.pluck('fact_names.name')
|
75
75
|
end
|
76
76
|
|
77
77
|
def fact_names
|
@@ -103,10 +103,6 @@ module ForemanChef
|
|
103
103
|
new_facts
|
104
104
|
end
|
105
105
|
|
106
|
-
def sort_by_key(hash)
|
107
|
-
hash.sort_by { |k, v| k.to_s }
|
108
|
-
end
|
109
|
-
|
110
106
|
class Sparser
|
111
107
|
def sparse(hash, options={})
|
112
108
|
hash.map do |k, v|
|
@@ -17,10 +17,20 @@ module ForemanChef
|
|
17
17
|
release_name = facts['kernel::name']
|
18
18
|
os_name = os_name.capitalize
|
19
19
|
else
|
20
|
-
|
20
|
+
# to keep OS names consistent with other cfgmgt agents we skip description importing
|
21
|
+
# description = facts['lsb::description']
|
21
22
|
release_name = facts['lsb::codename']
|
22
23
|
end
|
23
24
|
|
25
|
+
# So far only CentOS needs exception
|
26
|
+
case os_name
|
27
|
+
when 'CentOS'
|
28
|
+
if major.to_i >= 7
|
29
|
+
# get the minor.build number, e.g. 7.2.1511 -> 2.1511
|
30
|
+
minor = release[2..-1]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
24
34
|
begin
|
25
35
|
klass = os_name.constantize
|
26
36
|
rescue NameError => e
|
@@ -29,7 +39,7 @@ module ForemanChef
|
|
29
39
|
end
|
30
40
|
|
31
41
|
args = { :name => os_name, :major => major.to_s, :minor => minor.to_s }
|
32
|
-
klass.where(args).first || klass.new(args.merge(:
|
42
|
+
klass.where(args).first || klass.new(args.merge(:release_name => release_name)).tap(&:save!)
|
33
43
|
end
|
34
44
|
|
35
45
|
# we don't want to parse puppet environment, foreman_chef already has its own environment
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Deface::Override.new(:virtual_path => "hosts/_form",
|
2
2
|
:name => "add_chef_tab",
|
3
3
|
:insert_before => 'li#network_tab',
|
4
|
-
:text => ("<%= chef_tab_menu %>")
|
4
|
+
:text => ("<%= chef_tab_menu(f.object) %>")
|
5
5
|
)
|
6
6
|
Deface::Override.new(:virtual_path => "hosts/_form",
|
7
7
|
:name => "add_chef_tab_pane",
|
@@ -41,6 +41,7 @@ require 'chef_handler_foreman'
|
|
41
41
|
foreman_server_options :url => "<%= @host.params['chef_handler_foreman_url'] %>"
|
42
42
|
foreman_facts_upload true
|
43
43
|
foreman_reports_upload true
|
44
|
+
foreman_enc true
|
44
45
|
EOF
|
45
46
|
|
46
47
|
# You may set here the default run list for all your nodes
|
@@ -55,5 +56,8 @@ echo "First run of chef-client"
|
|
55
56
|
|
56
57
|
echo "Finished, cleaning"
|
57
58
|
rm -f /tmp/base.json
|
59
|
+
|
60
|
+
<% if validation_bootstrap_method? -%>
|
58
61
|
# you can comment this line to keep validaton.pem (e.g. for debugging purposes)
|
59
62
|
rm -f /etc/chef/validation.pem
|
63
|
+
<% end -%>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<div class="tab-pane" id="chef">
|
4
4
|
|
5
|
-
<% if
|
5
|
+
<% if chef_run_list_differs?(f.object) %>
|
6
6
|
<%= alert(:class => 'alert-warning', :header => 'Warning',
|
7
7
|
:text => _('Run list on chef server differs, by submitting the form, you will override the run list there. ').html_safe +
|
8
8
|
link_to(_('Reset'), '#', :class => 'refresh_run_list', :'data-run-list' => (f.object.fresh_run_list.try(:to_form_json) || '[]')) +
|
data/lib/foreman_chef/engine.rb
CHANGED
@@ -47,7 +47,7 @@ module ForemanChef
|
|
47
47
|
|
48
48
|
initializer 'foreman_chef.register_plugin', :before => :finisher_hook do |app|
|
49
49
|
Foreman::Plugin.register :foreman_chef do
|
50
|
-
requires_foreman '>= 1.
|
50
|
+
requires_foreman '>= 1.14'
|
51
51
|
extend_template_helpers ForemanChef::Concerns::Renderer
|
52
52
|
|
53
53
|
permission :import_chef_environments, { :environments => [:import, :synchronize] }, :resource_type => 'ForemanChef::Environment'
|
@@ -90,10 +90,8 @@ module ForemanChef
|
|
90
90
|
::Host::Managed.send :include, ForemanChef::Concerns::HostActionSubject
|
91
91
|
::Host::Managed.send :include, ForemanChef::Concerns::HostBuild
|
92
92
|
::HostsController.send :include, ForemanChef::Concerns::HostsControllerRescuer
|
93
|
-
end
|
94
93
|
|
95
|
-
|
96
|
-
::Foreman::Renderer.send :include, ForemanChef::Concerns::Renderer
|
94
|
+
::Host::Managed.send :include, ForemanChef::Concerns::Renderer
|
97
95
|
end
|
98
96
|
end
|
99
97
|
|
data/lib/foreman_chef/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marek Hulan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- app/overrides/add_chef_proxy.rb
|
96
96
|
- app/overrides/add_chef_tab.rb
|
97
97
|
- app/services/foreman_chef/chef_server_importer.rb
|
98
|
+
- app/services/foreman_chef/host_does_not_have_chef_proxy.rb
|
98
99
|
- app/services/foreman_chef/object_does_not_exist_exception.rb
|
99
100
|
- app/services/foreman_chef/object_exists_exception.rb
|
100
101
|
- app/services/foreman_chef/proxy_exception.rb
|