foreman_chef 0.5.0 → 0.6.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 +19 -6
- data/app/lib/actions/foreman_chef/client/create.rb +2 -3
- data/app/lib/actions/foreman_chef/client/destroy.rb +3 -3
- data/app/lib/actions/foreman_chef/host/destroy.rb +3 -3
- data/app/lib/actions/foreman_chef/host/update.rb +1 -4
- data/app/lib/actions/foreman_chef/node/update.rb +3 -4
- data/app/models/foreman_chef/concerns/host_action_subject.rb +0 -5
- data/app/models/foreman_chef/concerns/host_build.rb +2 -2
- data/app/models/foreman_chef/concerns/renderer.rb +1 -1
- data/app/models/foreman_chef/environment.rb +2 -2
- data/app/views/foreman/unattended/snippets/_chef_client_bootstrap.erb +5 -5
- data/app/views/foreman/unattended/snippets/_chef_client_gem_bootstrap.erb +2 -1
- data/app/views/foreman/unattended/snippets/_chef_client_omnibus_bootstrap.erb +4 -3
- data/app/views/foreman_chef/hosts/_chef_tab.html.erb +12 -1
- data/app/views/job_templates/run_chefclient_once.erb +25 -0
- data/app/views/job_templates/run_chefclient_wrapper.erb +10 -0
- data/db/seeds.rb +17 -1
- data/lib/foreman_chef/engine.rb +10 -1
- data/lib/foreman_chef/version.rb +1 -1
- metadata +5 -4
- data/app/lib/actions/foreman_chef/host/create.rb +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bed7f43a8fda06fdc85e6e6d2e6059dad4a0b3e2
|
4
|
+
data.tar.gz: 01c9bc5cd705a62dc4ec7ce017b40446c5ee5974
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59b5c3e2e49bcf6b1e86902995fc14b5ca152f541c84f4f82e7d2529c6c65a9315fad4a59e1f94717f5eb4dfff68fae4aedde4fb0779a408ab0f0b9adf084f0e
|
7
|
+
data.tar.gz: b3f03e1b028a868bb6ea788b9e59dcf89e592b70632736381da589057242617c3e2cae98c4fde8ba5fe22aaf289fbf96c9d9d186cc98e370bba655de93e657dd
|
@@ -12,11 +12,16 @@ module ForemanChef
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def chef_proxy_form_chef_environment_select(f, environments)
|
15
|
-
|
16
|
-
|
15
|
+
begin
|
16
|
+
if f.object.is_a?(Host::Base) && f.object.persisted? && f.object.chef_environment_differs?
|
17
|
+
help = content_tag(:span, ' ', :class => 'pficon pficon-warning-triangle-o') + ' ' + _('Chef environment is set to %s on Chef server, submitting will override it') % f.object.fresh_chef_environment
|
18
|
+
help = help.html_safe
|
19
|
+
else
|
20
|
+
help = nil
|
21
|
+
end
|
22
|
+
rescue => e # chef server communication issue
|
23
|
+
help = content_tag(:span, ' ', :class => 'pficon pficon-warning-triangle-o') + ' ' + _('Unable to communicate with Chef server - %s.') % e.message
|
17
24
|
help = help.html_safe
|
18
|
-
else
|
19
|
-
help = nil
|
20
25
|
end
|
21
26
|
|
22
27
|
select_f(f, :chef_environment_id, environments, :id, :name,
|
@@ -35,8 +40,12 @@ module ForemanChef
|
|
35
40
|
def chef_tab_menu(host)
|
36
41
|
if SmartProxy.with_features("Chef").count > 0
|
37
42
|
warning = ''
|
38
|
-
|
39
|
-
|
43
|
+
begin
|
44
|
+
if chef_run_list_differs?(host)
|
45
|
+
warning = chef_warning_icon
|
46
|
+
end
|
47
|
+
rescue => e
|
48
|
+
warning = chef_warning_icon
|
40
49
|
end
|
41
50
|
content_tag :li do
|
42
51
|
link_to(warning + _('Chef'), '#chef', :data => { :toggle => 'tab'})
|
@@ -44,6 +53,10 @@ module ForemanChef
|
|
44
53
|
end
|
45
54
|
end
|
46
55
|
|
56
|
+
def chef_warning_icon
|
57
|
+
content_tag(:span, ' '.html_safe, :class => "pficon pficon-warning-triangle-o")
|
58
|
+
end
|
59
|
+
|
47
60
|
def chef_tab_content(f)
|
48
61
|
render 'foreman_chef/hosts/chef_tab', :f => f
|
49
62
|
end
|
@@ -13,13 +13,12 @@ module Actions
|
|
13
13
|
plan_self :chef_proxy_id => proxy.id, :name => name
|
14
14
|
end
|
15
15
|
rescue => e
|
16
|
-
|
17
|
-
Rails.logger.debug e.backtrace.join("\n")
|
16
|
+
::Foreman::Logging.exception("Unable to communicate with Chef proxy", e)
|
18
17
|
raise ::ForemanChef::ProxyException.new(N_('CLIENT Unable to communicate with Chef proxy, %s' % e.message))
|
19
18
|
end
|
20
19
|
|
21
20
|
def run
|
22
|
-
proxy = ::SmartProxy.find_by_id(input[:chef_proxy_id])
|
21
|
+
proxy = ::SmartProxy.unscoped.find_by_id(input[:chef_proxy_id])
|
23
22
|
action_logger.debug "Creating client #{input[:name]} on proxy #{proxy.name} at #{proxy.url}"
|
24
23
|
self.output = proxy.create_client(input[:name])
|
25
24
|
end
|
@@ -4,19 +4,19 @@ module Actions
|
|
4
4
|
class Destroy < Actions::EntryAction
|
5
5
|
|
6
6
|
def plan(fqdn, proxy)
|
7
|
-
if ::Setting
|
7
|
+
if ::Setting[: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
|
11
11
|
end
|
12
12
|
end
|
13
13
|
rescue => e
|
14
|
-
::Foreman::Logging.exception('Unable to communicate with Chef proxy', e
|
14
|
+
::Foreman::Logging.exception('Unable to communicate with Chef proxy', e)
|
15
15
|
raise ::ForemanChef::ProxyException.new(N_('Unable to communicate with Chef proxy, %s' % e.message))
|
16
16
|
end
|
17
17
|
|
18
18
|
def run
|
19
|
-
proxy = ::SmartProxy.find_by_id(input[:chef_proxy_id])
|
19
|
+
proxy = ::SmartProxy.unscoped.find_by_id(input[:chef_proxy_id])
|
20
20
|
action_logger.debug "Deleting client #{input[:fqdn]} on proxy #{proxy.name} at #{proxy.url}"
|
21
21
|
self.output = proxy.delete_client(input[:fqdn])
|
22
22
|
end
|
@@ -11,7 +11,7 @@ module Actions
|
|
11
11
|
|
12
12
|
def plan(host)
|
13
13
|
action_subject(host)
|
14
|
-
if (::Setting
|
14
|
+
if (::Setting[:auto_deletion] && proxy = host.chef_proxy)
|
15
15
|
node_exists_in_chef = proxy.show_node(host.name)
|
16
16
|
if node_exists_in_chef
|
17
17
|
plan_self :chef_proxy_id => host.chef_proxy_id
|
@@ -20,12 +20,12 @@ module Actions
|
|
20
20
|
plan_action Actions::ForemanChef::Client::Destroy, host.name, proxy
|
21
21
|
end
|
22
22
|
rescue => e
|
23
|
-
::Foreman::Logging.exception('Unable to communicate with Chef proxy', e
|
23
|
+
::Foreman::Logging.exception('Unable to communicate with Chef proxy', e)
|
24
24
|
raise ::ForemanChef::ProxyException.new(N_('Unable to communicate with Chef proxy, %s' % e.message))
|
25
25
|
end
|
26
26
|
|
27
27
|
def run
|
28
|
-
proxy = ::SmartProxy.find_by_id(input[:chef_proxy_id])
|
28
|
+
proxy = ::SmartProxy.unscoped.find_by_id(input[:chef_proxy_id])
|
29
29
|
action_logger.debug "Deleting #{input[:host][:name]} on proxy #{proxy.name} at #{proxy.url}"
|
30
30
|
self.output = proxy.delete_node(input[:host][:name])
|
31
31
|
end
|
@@ -18,10 +18,7 @@ module Actions
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
rescue => e
|
21
|
-
|
22
|
-
Rails.logger.debug e.backtrace.join("\n")
|
23
|
-
raise ::ForemanChef::ProxyException.new(N_('Unable to communicate with Chef proxy, %s' % e.message))
|
24
|
-
# TODO these errors causing form not to display anything and double traces, we need reraise
|
21
|
+
::Foreman::Logging.exception("Unable to communicate with Chef proxy", e)
|
25
22
|
end
|
26
23
|
|
27
24
|
def humanized_name
|
@@ -19,14 +19,13 @@ module Actions
|
|
19
19
|
raise ::ForemanChef::ObjectDoesNotExistException.new(N_('Node with name %s does not exist on this Chef proxy' % name))
|
20
20
|
end
|
21
21
|
rescue => e
|
22
|
-
|
23
|
-
Rails.logger.debug e.backtrace.join("\n")
|
22
|
+
::Foreman::Logging.exception("Unable to communicate with Chef proxy", e)
|
24
23
|
raise ::ForemanChef::ProxyException.new(N_('Unable to communicate with Chef proxy, %s' % e.message))
|
25
24
|
end
|
26
25
|
|
27
26
|
def run
|
28
|
-
proxy = ::SmartProxy.find_by_id(input[:chef_proxy_id])
|
29
|
-
host = ::Host.find(input[:host_id])
|
27
|
+
proxy = ::SmartProxy.unscoped.find_by_id(input[:chef_proxy_id])
|
28
|
+
host = ::Host.unscoped.find(input[:host_id])
|
30
29
|
action_logger.debug "Updating node #{input[:name]} on proxy #{proxy.name} at #{proxy.url}"
|
31
30
|
proxy.update_node(host.name, host.run_list.as_chef_json.merge(:chef_environment => host.chef_environment.name))
|
32
31
|
end
|
@@ -5,11 +5,6 @@ module ForemanChef
|
|
5
5
|
include ForemanTasks::Concerns::ActionSubject
|
6
6
|
include ForemanTasks::Concerns::ActionTriggering
|
7
7
|
|
8
|
-
def create_action
|
9
|
-
sync_action!
|
10
|
-
::Actions::ForemanChef::Host::Create
|
11
|
-
end
|
12
|
-
|
13
8
|
def update_action
|
14
9
|
sync_action!
|
15
10
|
::Actions::ForemanChef::Host::Update
|
@@ -13,7 +13,7 @@ module ForemanChef
|
|
13
13
|
# private key is no longer valid
|
14
14
|
host.chef_private_key = nil
|
15
15
|
|
16
|
-
if !::Setting
|
16
|
+
if !::Setting[:validation_bootstrap_method]
|
17
17
|
new_client = ::ForemanTasks.sync_task ::Actions::ForemanChef::Client::Create, host.name, host.chef_proxy
|
18
18
|
host.chef_private_key = new_client.output[:private_key]
|
19
19
|
end
|
@@ -27,7 +27,7 @@ module ForemanChef
|
|
27
27
|
# private key is no longer valid
|
28
28
|
self.chef_private_key = nil
|
29
29
|
|
30
|
-
if !::Setting
|
30
|
+
if !::Setting[:validation_bootstrap_method]
|
31
31
|
new_client = ::ForemanTasks.sync_task ::Actions::ForemanChef::Client::Create, self.name, self.chef_proxy
|
32
32
|
self.chef_private_key = new_client.output[:private_key]
|
33
33
|
end
|
@@ -7,9 +7,9 @@ module ForemanChef
|
|
7
7
|
|
8
8
|
has_many :hosts, :class_name => '::Host::Managed'
|
9
9
|
has_many :hostgroups, :class_name => '::Hostgroup'
|
10
|
-
belongs_to :chef_proxy, :class_name => '::SmartProxy'
|
10
|
+
belongs_to :chef_proxy, -> { unscope(:where) }, :class_name => '::SmartProxy'
|
11
11
|
|
12
|
-
validates :name, :uniqueness => true, :presence => true, :format => { :with => /\A[\w\d
|
12
|
+
validates :name, :uniqueness => true, :presence => true, :format => { :with => /\A[-_\w\d]+\Z/, :message => N_('must be alphanumeric with dashes and hyphens and cannot contain spaces') }
|
13
13
|
|
14
14
|
scoped_search :on => :name, :complete_value => true
|
15
15
|
scoped_search :in => :hostgroups, :on => :name, :complete_value => true, :rename => :hostgroup
|
@@ -5,7 +5,7 @@ mkdir /etc/chef
|
|
5
5
|
chmod 600 /etc/chef/validation.pem
|
6
6
|
|
7
7
|
cat << 'EOF' > /etc/chef/validation.pem
|
8
|
-
<%=
|
8
|
+
<%= host_param('chef_validation_private_key') %>
|
9
9
|
EOF
|
10
10
|
<% else -%>
|
11
11
|
echo "Creating client.pem"
|
@@ -18,7 +18,7 @@ EOF
|
|
18
18
|
<% end -%>
|
19
19
|
|
20
20
|
## If chef_server_certificate is present, install it into /etc/chef/trusted_certs
|
21
|
-
<% chef_server_certificate =
|
21
|
+
<% chef_server_certificate = host_param('chef_server_certificate') -%>
|
22
22
|
<% if !chef_server_certificate.nil? && !chef_server_certificate.empty? -%>
|
23
23
|
mkdir -p /etc/chef/trusted_certs
|
24
24
|
chmod 0755 /etc/chef/trusted_certs
|
@@ -31,14 +31,14 @@ echo "Configuring chef client.rb"
|
|
31
31
|
cat << 'EOF' > /etc/chef/client.rb
|
32
32
|
log_level :info
|
33
33
|
log_location STDOUT
|
34
|
-
chef_server_url "<%=
|
35
|
-
validation_client_name "<%=
|
34
|
+
chef_server_url "<%= host_param('chef_server_url') %>"
|
35
|
+
validation_client_name "<%= host_param('chef_validator_name') -%>"
|
36
36
|
file_backup_path "/var/lib/chef"
|
37
37
|
file_cache_path "/var/cache/chef"
|
38
38
|
pid_file "/var/run/chef/client.pid"
|
39
39
|
|
40
40
|
require 'chef_handler_foreman'
|
41
|
-
foreman_server_options :url => "<%=
|
41
|
+
foreman_server_options :url => "<%= host_param('chef_handler_foreman_url') %>"
|
42
42
|
foreman_facts_upload true
|
43
43
|
foreman_reports_upload true
|
44
44
|
foreman_enc true
|
@@ -1,4 +1,5 @@
|
|
1
1
|
echo "Installing chef and chef_handler_foreman"
|
2
|
-
gem install chef
|
2
|
+
gem install chef <%= host_param('chef_bootstrap_version') ? '-v ' + host_param('chef_bootstrap_version') : '' %>
|
3
|
+
gem install chef_handler_foreman
|
3
4
|
|
4
5
|
<%= snippet 'chef-client bootstrap' %>
|
@@ -3,11 +3,12 @@
|
|
3
3
|
apt-get -y install ca-certificates
|
4
4
|
<% end -%>
|
5
5
|
|
6
|
-
# install.sh
|
6
|
+
# run install.sh with specific version if set
|
7
|
+
<% version = host_param('chef_bootstrap_version') ? '-v ' + host_param('chef_bootstrap_version') : '' -%>
|
7
8
|
if [ -f /usr/bin/curl ]; then
|
8
|
-
curl -L https://www.chef.io/chef/install.sh | bash
|
9
|
+
curl -L https://www.chef.io/chef/install.sh | bash -s -- <%= version %>
|
9
10
|
else
|
10
|
-
wget https://www.chef.io/chef/install.sh -O- | bash
|
11
|
+
wget https://www.chef.io/chef/install.sh -O- | bash -s -- <%= version %>
|
11
12
|
fi
|
12
13
|
|
13
14
|
# if you want specific version you can use something like this instead of install.sh
|
@@ -2,13 +2,24 @@
|
|
2
2
|
|
3
3
|
<div class="tab-pane" id="chef">
|
4
4
|
|
5
|
-
<%
|
5
|
+
<% communication_error = nil
|
6
|
+
begin
|
7
|
+
differs = chef_run_list_differs?(f.object)
|
8
|
+
rescue => e
|
9
|
+
communication_problem = e
|
10
|
+
end -%>
|
11
|
+
<% if differs %>
|
6
12
|
<%= alert(:class => 'alert-warning', :header => 'Warning',
|
7
13
|
:text => _('Run list on chef server differs, by submitting the form, you will override the run list there. ').html_safe +
|
8
14
|
link_to(_('Reset'), '#', :class => 'refresh_run_list', :'data-run-list' => (f.object.fresh_run_list.try(:to_form_json) || '[]')) +
|
9
15
|
_(' to run list from chef-server').html_safe) %>
|
10
16
|
<% end %>
|
11
17
|
|
18
|
+
<% if communication_problem %>
|
19
|
+
<%= alert(:class => 'alert-warning', :header => 'Warning',
|
20
|
+
:text => (_('Unable to fetch data from Chef server - %s. Any changes to environment or runlist will not be persisted in Chef server. To fix it, save the host again when communication with Chef server is restored.') % e.message).html_safe) %>
|
21
|
+
<% end %>
|
22
|
+
|
12
23
|
<div id="runlist-editor" data-default="<%= f.object.run_list.to_form_json %>">
|
13
24
|
|
14
25
|
</div>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%#
|
2
|
+
name: Run chef-client once
|
3
|
+
job_category: Chef
|
4
|
+
description_format: "%{template_name}"
|
5
|
+
snippet: false
|
6
|
+
template_inputs:
|
7
|
+
- name: log-level
|
8
|
+
required: true
|
9
|
+
input_type: user
|
10
|
+
description: Set the log level (auto, debug, info, warn, error, fatal)
|
11
|
+
options: "auto\r\ndebug\r\ninfo\r\nwarn\r\nerror\r\nfatal"
|
12
|
+
advanced: true
|
13
|
+
- name: why-run
|
14
|
+
required: true
|
15
|
+
input_type: user
|
16
|
+
description: Enable whyrun mode
|
17
|
+
options: "no\r\nyes"
|
18
|
+
advanced: true
|
19
|
+
provider_type: SSH
|
20
|
+
kind: job_template
|
21
|
+
%>
|
22
|
+
|
23
|
+
chef-client --once \
|
24
|
+
<%= ' --why-run' if input('why-run') == 'yes' -%>
|
25
|
+
<%= " --log_level #{input('log-level')}" if input('log-level') && input('log-level') != 'auto' -%>
|
data/db/seeds.rb
CHANGED
@@ -14,9 +14,25 @@ templates.each do |template|
|
|
14
14
|
ProvisioningTemplate.where(:name => template[:name]).first_or_create.update_attributes(defaults.merge(template))
|
15
15
|
end
|
16
16
|
|
17
|
+
if ForemanChef.with_remote_execution?
|
18
|
+
User.as_anonymous_admin do
|
19
|
+
JobTemplate.without_auditing do
|
20
|
+
Dir[File.join("#{ForemanChef::Engine.root}/app/views/job_templates/**/*.erb")].each do |template|
|
21
|
+
sync = !Rails.env.test? && Setting[:remote_execution_sync_templates]
|
22
|
+
# import! was renamed to import_raw! around 1.3.1
|
23
|
+
if JobTemplate.respond_to?('import_raw!')
|
24
|
+
JobTemplate.import_raw!(File.read(template), :default => true, :locked => true, :update => sync)
|
25
|
+
else
|
26
|
+
JobTemplate.import!(File.read(template), :default => true, :locked => true, :update => sync)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
17
33
|
# Global parameters used in configuration snippets
|
18
34
|
parameters = [
|
19
|
-
{ :name => 'chef_handler_foreman_url', :value => SmartProxy.with_features('Chef').first.try(:url) || Setting
|
35
|
+
{ :name => 'chef_handler_foreman_url', :value => SmartProxy.with_features('Chef').first.try(:url) || Setting[:foreman_url] },
|
20
36
|
{ :name => 'chef_server_url', :value => "https://#{Socket.gethostbyname(Socket.gethostname).first}" },
|
21
37
|
{ :name => 'chef_validation_private_key', :value => 'UNSPECIFIED, you must upload your validation key here' },
|
22
38
|
{ :name => 'chef_bootstrap_template', :value => 'chef-client omnibus bootstrap' },
|
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.15'
|
51
51
|
extend_template_helpers ForemanChef::Concerns::Renderer
|
52
52
|
|
53
53
|
permission :import_chef_environments, { :environments => [:import, :synchronize] }, :resource_type => 'ForemanChef::Environment'
|
@@ -65,6 +65,10 @@ module ForemanChef
|
|
65
65
|
parameter_filter ForemanChef::CachedRunList, :type, :name
|
66
66
|
parameter_filter Host::Managed, :chef_private_key, :chef_proxy_id, :override_chef_attributes, :chef_environment_id, :run_list => [ parameter_filters(ForemanChef::CachedRunList) ]
|
67
67
|
parameter_filter Hostgroup, :chef_proxy_id, :chef_environment_id
|
68
|
+
|
69
|
+
if ForemanChef.with_remote_execution? && Gem::Version.new(ForemanRemoteExecution::VERSION) >= Gem::Version.new('1.2.3')
|
70
|
+
RemoteExecutionFeature.register(:foreman_chef_run_chef_client, N_("Run chef-client Once"), :description => N_("Run chef-client once"), :host_action_button => true)
|
71
|
+
end
|
68
72
|
end
|
69
73
|
end
|
70
74
|
|
@@ -102,4 +106,9 @@ module ForemanChef
|
|
102
106
|
def use_relative_model_naming
|
103
107
|
true
|
104
108
|
end
|
109
|
+
|
110
|
+
# check whether foreman_remote_execution to integrate is available in the system
|
111
|
+
def self.with_remote_execution?
|
112
|
+
(RemoteExecutionFeature rescue false) ? true : false
|
113
|
+
end
|
105
114
|
end
|
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.6.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-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
@@ -74,7 +74,6 @@ files:
|
|
74
74
|
- app/helpers/foreman_chef/chef_proxy_form.rb
|
75
75
|
- app/lib/actions/foreman_chef/client/create.rb
|
76
76
|
- app/lib/actions/foreman_chef/client/destroy.rb
|
77
|
-
- app/lib/actions/foreman_chef/host/create.rb
|
78
77
|
- app/lib/actions/foreman_chef/host/destroy.rb
|
79
78
|
- app/lib/actions/foreman_chef/host/update.rb
|
80
79
|
- app/lib/actions/foreman_chef/node/update.rb
|
@@ -109,6 +108,8 @@ files:
|
|
109
108
|
- app/views/foreman_chef/environments/index.html.erb
|
110
109
|
- app/views/foreman_chef/environments/new.html.erb
|
111
110
|
- app/views/foreman_chef/hosts/_chef_tab.html.erb
|
111
|
+
- app/views/job_templates/run_chefclient_once.erb
|
112
|
+
- app/views/job_templates/run_chefclient_wrapper.erb
|
112
113
|
- config/routes.rb
|
113
114
|
- db/migrate/20140220145827_add_chef_proxy_id_to_host.rb
|
114
115
|
- db/migrate/20140513144804_add_chef_proxy_id_to_hostgroup.rb
|
@@ -139,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
140
|
version: '0'
|
140
141
|
requirements: []
|
141
142
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
143
|
+
rubygems_version: 2.6.8
|
143
144
|
signing_key:
|
144
145
|
specification_version: 4
|
145
146
|
summary: Plugin for Chef integration with Foreman
|
@@ -1,53 +0,0 @@
|
|
1
|
-
module Actions
|
2
|
-
module ForemanChef
|
3
|
-
module Host
|
4
|
-
class Create < Actions::EntryAction
|
5
|
-
|
6
|
-
def resource_locks
|
7
|
-
:link
|
8
|
-
end
|
9
|
-
|
10
|
-
def plan(host)
|
11
|
-
action_subject(host)
|
12
|
-
|
13
|
-
if host.chef_proxy
|
14
|
-
client_exists_in_chef = host.chef_proxy.show_client(host.name)
|
15
|
-
|
16
|
-
sequence do
|
17
|
-
if client_exists_in_chef
|
18
|
-
plan_action Actions::ForemanChef::Client::Destroy, host.name, host.chef_proxy
|
19
|
-
end
|
20
|
-
|
21
|
-
unless ::Setting::ForemanChef.validate_bootstrap_method
|
22
|
-
client_creation = plan_action Actions::ForemanChef::Client::Create, host.name, host.chef_proxy
|
23
|
-
end
|
24
|
-
|
25
|
-
plan_self(:create_action_output => client_creation.output)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
rescue => e
|
29
|
-
Rails.logger.debug "Unable to communicate with Chef proxy, #{e.message}"
|
30
|
-
Rails.logger.debug e.backtrace.join("\n")
|
31
|
-
raise ::ForemanChef::ProxyException.new(N_('Unable to communicate with Chef proxy, %s' % e.message))
|
32
|
-
end
|
33
|
-
|
34
|
-
def finalize
|
35
|
-
if input[:create_action_output][:private_key].present? && !Setting.validation_bootstrap_method
|
36
|
-
host = ::Host.find(self.input[:host][:id])
|
37
|
-
host.chef_private_key = input[:create_action_output][:private_key]
|
38
|
-
host.disable_dynflow_hooks { |h| h.save! }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def humanized_name
|
43
|
-
_("Create host")
|
44
|
-
end
|
45
|
-
|
46
|
-
def humanized_input
|
47
|
-
input[:host][:name]
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|