foreman_salt 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/app/assets/javascripts/foreman_salt/states.js +33 -0
- data/app/controllers/foreman_salt/api/v2/salt_states_controller.rb +53 -2
- data/app/controllers/foreman_salt/concerns/hostgroups_controller_extensions.rb +23 -2
- data/app/controllers/foreman_salt/concerns/hosts_controller_extensions.rb +7 -3
- data/app/controllers/foreman_salt/minions_controller.rb +33 -1
- data/app/controllers/foreman_salt/salt_modules_controller.rb +45 -1
- data/app/controllers/foreman_salt/state_importer.rb +72 -0
- data/app/helpers/foreman_salt/salt_modules_helper.rb +19 -0
- data/app/lib/proxy_api/salt.rb +18 -0
- data/app/models/foreman_salt/concerns/host_managed_extensions.rb +23 -8
- data/app/models/foreman_salt/concerns/hostgroup_extensions.rb +12 -9
- data/app/models/foreman_salt/host_salt_module.rb +6 -0
- data/app/models/foreman_salt/hostgroup_salt_module.rb +6 -0
- data/app/models/foreman_salt/salt_environment.rb +13 -6
- data/app/models/foreman_salt/salt_module.rb +27 -5
- data/app/models/foreman_salt/salt_module_environment.rb +14 -0
- data/app/overrides/salt_environment_host_selector.rb +9 -0
- data/app/overrides/{salt_environment_selector.rb → salt_environment_hostgroup_selector.rb} +2 -6
- data/app/overrides/salt_modules_selector.rb +4 -4
- data/app/services/foreman_salt/fact_importer.rb +1 -1
- data/app/services/foreman_salt/report_importer.rb +9 -7
- data/app/services/foreman_salt/smart_proxies/salt_keys.rb +1 -1
- data/app/views/foreman_salt/salt_environments/index.html.erb +8 -2
- data/app/views/foreman_salt/salt_modules/_form.html.erb +7 -1
- data/app/{overrides/foreman → views/foreman_salt}/salt_modules/_host_tab.html.erb +0 -0
- data/app/views/foreman_salt/salt_modules/_host_tab_pane.html.erb +33 -0
- data/app/views/foreman_salt/salt_modules/import.html.erb +43 -0
- data/app/views/foreman_salt/salt_modules/index.html.erb +17 -5
- data/config/routes.rb +23 -3
- data/db/migrate/20150411003302_add_environments_to_modules.rb +17 -0
- data/db/migrate/20150509094409_rename_join_tables.rb +11 -0
- data/db/migrate/20150509101505_add_primary_keys.rb +6 -0
- data/lib/foreman_salt/engine.rb +21 -1
- data/lib/foreman_salt/version.rb +1 -1
- data/lib/tasks/foreman_salt_tasks.rake +0 -1
- data/test/unit/host_extensions_test.rb +15 -1
- data/test/unit/hostgroup_extensions_test.rb +2 -2
- metadata +35 -24
- data/app/overrides/foreman/salt_modules/_host_tab_pane.html.erb +0 -22
@@ -1,11 +1,7 @@
|
|
1
1
|
selector_text = "<%= select_f f, :salt_environment_id, ForemanSalt::SaltEnvironment.all, :id, :name,
|
2
2
|
{ :include_blank => blank_or_inherit_f(f, :salt_environment) },
|
3
|
-
{ :label
|
4
|
-
|
5
|
-
Deface::Override.new(:virtual_path => 'hosts/_form',
|
6
|
-
:name => 'add_salt_environment_to_host',
|
7
|
-
:insert_bottom => 'div#primary',
|
8
|
-
:text => selector_text)
|
3
|
+
{ :label => _('Salt Environment'), :onchange => 'update_salt_states(this)', :'data-url' => salt_environment_selected_hostgroups_path,
|
4
|
+
:'data-host-id' => (@host || @hostgroup).id, :help_inline => :indicator} %>"
|
9
5
|
|
10
6
|
Deface::Override.new(:virtual_path => 'hostgroups/_form',
|
11
7
|
:name => 'add_salt_environment_to_hostgroup',
|
@@ -1,19 +1,19 @@
|
|
1
1
|
Deface::Override.new(:virtual_path => 'hosts/_form',
|
2
2
|
:name => 'add_salt_modules_tab_to_host',
|
3
3
|
:insert_after => 'li.active',
|
4
|
-
:partial => '
|
4
|
+
:partial => 'foreman_salt/salt_modules/host_tab')
|
5
5
|
|
6
6
|
Deface::Override.new(:virtual_path => 'hosts/_form',
|
7
7
|
:name => 'add_salt_modules_tab_pane_to_host',
|
8
8
|
:insert_before => 'div#puppet_klasses',
|
9
|
-
:partial => '
|
9
|
+
:partial => 'foreman_salt/salt_modules/host_tab_pane')
|
10
10
|
|
11
11
|
Deface::Override.new(:virtual_path => 'hostgroups/_form',
|
12
12
|
:name => 'add_salt_modules_tab_to_hg',
|
13
13
|
:insert_after => 'li.active',
|
14
|
-
:partial => '
|
14
|
+
:partial => 'foreman_salt/salt_modules/host_tab')
|
15
15
|
|
16
16
|
Deface::Override.new(:virtual_path => 'hostgroups/_form',
|
17
17
|
:name => 'add_salt_modules_tab_pane_to_hg',
|
18
18
|
:insert_before => 'div#puppet_klasses',
|
19
|
-
:partial => '
|
19
|
+
:partial => 'foreman_salt/salt_modules/host_tab_pane')
|
@@ -102,7 +102,7 @@ module ForemanSalt
|
|
102
102
|
sparse(hash).each do |k, v|
|
103
103
|
current = ret
|
104
104
|
key = k.to_s.split(options.fetch(:separator, FactName::SEPARATOR))
|
105
|
-
current = (current[key.shift] ||=
|
105
|
+
current = (current[key.shift] ||= {}) until (key.size <= 1)
|
106
106
|
current[key.first] = v
|
107
107
|
end
|
108
108
|
ret
|
@@ -43,7 +43,7 @@ module ForemanSalt
|
|
43
43
|
private
|
44
44
|
|
45
45
|
def find_or_create_host(host)
|
46
|
-
@host ||= Host::
|
46
|
+
@host ||= Host::Managed.find_by_name(host)
|
47
47
|
|
48
48
|
unless @host
|
49
49
|
new = Host::Managed.new(:name => host)
|
@@ -106,14 +106,16 @@ module ForemanSalt
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
109
|
+
duration = if result['duration'].is_a? String
|
110
|
+
Float(result['duration'].delete(' ms')) rescue nil
|
111
|
+
else
|
112
|
+
result['duration']
|
113
|
+
end
|
114
|
+
|
115
|
+
time[resource] = duration || 0
|
114
116
|
end
|
115
117
|
|
116
|
-
time[:total] = time.values.inject(&:+)
|
118
|
+
time[:total] = time.values.compact.inject(&:+) || 0
|
117
119
|
events = { :total => changed + failed + restarted + restarted_failed, :success => success + restarted, :failure => failed + restarted_failed }
|
118
120
|
|
119
121
|
changes = { :total => changed + restarted }
|
@@ -5,14 +5,20 @@
|
|
5
5
|
<table class="table table-bordered table-striped">
|
6
6
|
<tr>
|
7
7
|
<th><%= sort :name, :as => s_('SaltEnvironment|Name') %></th>
|
8
|
+
<th><%= _('States') %></th>
|
9
|
+
<th><%= sort :host, :as => _('Hosts'), :default => 'DESC' %></th>
|
10
|
+
<th><%= sort :hostgroup, :as => _('Host groups'), :default => 'DESC' %></th>
|
8
11
|
<th></th>
|
9
12
|
</tr>
|
10
13
|
<% for salt_environment in @salt_environments %>
|
11
14
|
<tr>
|
12
15
|
<td><%=link_to_if_authorized h(salt_environment.name), hash_for_edit_salt_environment_path(:id => salt_environment).merge(:auth_object => salt_environment, :authorizer => authorizer) %></td>
|
16
|
+
<td><%= link_to_if_authorized(salt_environment.salt_modules.count, hash_for_salt_modules_path(:search => "environment = #{salt_environment}")) %></td>
|
17
|
+
<td><%= link_to_if_authorized(salt_environment.hosts.count, hash_for_hosts_path(:search => "salt_environment = #{salt_environment}")) %></td>
|
18
|
+
<td><%= link_to_if_authorized(salt_environment.hostgroups.count, hash_for_hostgroups_path(:search => "salt_environment = #{salt_environment}")) %></td>
|
13
19
|
<td>
|
14
|
-
|
15
|
-
:confirm => _('Delete %s?') % salt_environment.name) %>
|
20
|
+
<%= action_buttons(display_delete_if_authorized(hash_for_salt_environment_path(:id => salt_environment).merge(:auth_object => salt_environment, :authorizer => authorizer),
|
21
|
+
:confirm => _('Delete %s?') % salt_environment.name)) %>
|
16
22
|
</td>
|
17
23
|
</tr>
|
18
24
|
<% end %>
|
@@ -2,14 +2,20 @@
|
|
2
2
|
<%= base_errors_for @salt_module %>
|
3
3
|
<ul class="nav nav-tabs" data-tabs="tabs">
|
4
4
|
<li class="active"><a href="#primary" data-toggle="tab"><%= _('Salt States') %></a></li>
|
5
|
+
<li><a href="#environments" data-toggle="tab"><%= _('Environments') %></a></li>
|
5
6
|
</ul>
|
6
7
|
|
7
8
|
<div class="tab-content">
|
8
9
|
<div class="tab-pane active" id="primary">
|
9
10
|
<%= text_f f, :name %>
|
10
11
|
</div>
|
12
|
+
|
13
|
+
<div class="tab-pane" id="environments">
|
14
|
+
<%= multiple_selects f, :salt_environment, ::ForemanSalt::SaltEnvironment, @salt_environments.try(:map, &:id), :label => _("Environments").html_safe %>
|
15
|
+
</div>
|
11
16
|
</div>
|
12
17
|
|
13
|
-
|
18
|
+
<%= submit_or_cancel f %>
|
19
|
+
|
14
20
|
<% end %>
|
15
21
|
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%= javascript "foreman_salt/states" %>
|
2
|
+
|
3
|
+
<%
|
4
|
+
object_name = @obj.kind_of?(Hostgroup) ? 'hostgroup' : 'host'
|
5
|
+
@salt_modules ||= []
|
6
|
+
@selected ||= []
|
7
|
+
%>
|
8
|
+
|
9
|
+
<div class="tab-pane" id="salt_modules">
|
10
|
+
<div id="state_selector" style="<%= @salt_environment.blank? ? 'display: none' : 'visibility: block' %>;">
|
11
|
+
<% @inherited_salt_modules = [] if @inherited_salt_modules.blank? %>
|
12
|
+
<div class="row">
|
13
|
+
<div class="col-md-4">
|
14
|
+
<h3>Inherited States</h3>
|
15
|
+
<ul id="inherited_states">
|
16
|
+
<% @inherited_salt_modules.sort.each do |salt_module| -%>
|
17
|
+
<li title="Inherited from hostgroup"><%= salt_module.name -%></li>
|
18
|
+
<% end -%>
|
19
|
+
</ul>
|
20
|
+
</div>
|
21
|
+
<div class="col-md-8">
|
22
|
+
<h3>Salt States</h3>
|
23
|
+
<%= fields_for "#{object_name}".to_sym do |states| %>
|
24
|
+
<%= states.collection_select(:salt_module_ids, @salt_modules, :id, :to_s, {:selected => @selected.map(&:id), :size => "col-md-10"},
|
25
|
+
:multiple => true) %>
|
26
|
+
<% end %>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
<div id="no_env" style="visibility: <%= @salt_environment.blank? ? 'block' : 'hidden' %>;">
|
31
|
+
<div class="alert alert-block alert-warning"><%= _('Please select a Salt environment first') %></div>
|
32
|
+
</div>
|
33
|
+
</div>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<% title _('Import from %s') % @proxy.name %>
|
2
|
+
|
3
|
+
<%= form_tag apply_changes_salt_modules_path do %>
|
4
|
+
|
5
|
+
<h4><%= _("Select the changes you want to realize in Foreman") %></h4>
|
6
|
+
<br/>
|
7
|
+
<h6>
|
8
|
+
<%= _("Toggle") %>:
|
9
|
+
<%= link_to_function(icon_text("check", _("Added")),
|
10
|
+
"toggleCheckboxesBySelector('.state_check_add')",
|
11
|
+
:title => _("Check/Uncheck Added")) %> |
|
12
|
+
<%= link_to_function(icon_text("check", _("Removed")),
|
13
|
+
"toggleCheckboxesBySelector('.state_check_remove')",
|
14
|
+
:title => _("Check/Uncheck Removed")) %>
|
15
|
+
</h6>
|
16
|
+
|
17
|
+
<table class="table table-bordered table-striped">
|
18
|
+
<tr>
|
19
|
+
<th class="ca"><%= link_to_function(icon_text("check"),
|
20
|
+
"toggleCheckboxesBySelector('.state_check')",
|
21
|
+
:title => _("Check/Uncheck All")) %></th>
|
22
|
+
<th><%= _('Environment') %></th>
|
23
|
+
<th><%= _('Operation') %></th>
|
24
|
+
<th><%= _('States') %></th>
|
25
|
+
</tr>
|
26
|
+
<% @changes.each do |environment, changed| -%>
|
27
|
+
<% [:add, :remove].each do |operation| -%>
|
28
|
+
<% if changed[operation] %>
|
29
|
+
<tr>
|
30
|
+
<td class="ca"><%= check_box_tag "changed[#{environment}][#{operation}]", changed[operation].to_json, false, :class => "state_check state_check_#{operation}" %></td>
|
31
|
+
<td><%= environment %><%= '*' if @deletes.include? environment %></td>
|
32
|
+
<td><%= operation.to_s.titleize %></td>
|
33
|
+
<td><%= changed[operation].to_sentence -%></td>
|
34
|
+
</tr>
|
35
|
+
<% end -%>
|
36
|
+
<% end -%>
|
37
|
+
<% end -%>
|
38
|
+
</table>
|
39
|
+
<%= '<p>* Environment will contain no states, and will be deleted'.html_safe if @deletes.any? %>
|
40
|
+
|
41
|
+
<p><%= link_to _("Cancel"), salt_modules_path, :class => "btn btn-default" %>
|
42
|
+
<%= submit_tag _("Update"), :class => "btn btn-primary" %>
|
43
|
+
<% end -%>
|
@@ -1,18 +1,31 @@
|
|
1
1
|
<% title _('Salt States') %>
|
2
2
|
|
3
|
-
<% title_actions
|
3
|
+
<% title_actions import_from_proxies,
|
4
|
+
button_group(display_link_if_authorized(_('New Salt State'), hash_for_new_salt_module_path)) %>
|
5
|
+
|
4
6
|
|
5
7
|
<table class="table table-bordered table-striped">
|
6
8
|
<tr>
|
7
9
|
<th><%= sort :name, :as => s_('SaltModule|Name') %></th>
|
10
|
+
<th><%= _('Environments') %></th>
|
11
|
+
<th><%= sort :host, :as => _('Hosts'), :default => 'DESC' %></th>
|
12
|
+
<th><%= sort :hostgroup, :as => _('Host groups'), :default => 'DESC' %></th>
|
8
13
|
<th></th>
|
9
14
|
</tr>
|
10
15
|
<% for salt_module in @salt_modules %>
|
11
16
|
<tr>
|
12
|
-
<td><%=link_to_if_authorized
|
17
|
+
<td><%= link_to_if_authorized(colorize(salt_module.name), hash_for_edit_salt_module_path(:id => salt_module)) %></td>
|
18
|
+
<td>
|
19
|
+
<% salt_module.salt_environments.sort.each do |environment| -%>
|
20
|
+
<%= link_to environment.name, :controller => :'foreman_salt/salt_modules', :action => :index, :search => "environment = #{environment.name}" %>
|
21
|
+
<% end -%>
|
22
|
+
</td>
|
23
|
+
<td><%= link_to_if_authorized(salt_module.hosts.count, hash_for_hosts_path(:search => "salt_state = #{salt_module}")) %></td>
|
24
|
+
<td><%= link_to_if_authorized(salt_module.hostgroups.count, hash_for_hostgroups_path(:search => "salt_state = #{salt_module}")) %></td>
|
13
25
|
<td>
|
14
|
-
|
15
|
-
|
26
|
+
<%= action_buttons([display_link_if_authorized(_('Edit'), hash_for_edit_salt_module_path(:id => salt_module).merge(:auth_object => salt_module, :authorizer => authorizer)),
|
27
|
+
display_delete_if_authorized(hash_for_salt_module_path(:id => salt_module).merge(:auth_object => salt_module, :authorizer => authorizer),
|
28
|
+
:confirm => _('Delete %s?') % salt_module.name)]) %>
|
16
29
|
</td>
|
17
30
|
</tr>
|
18
31
|
<% end %>
|
@@ -20,4 +33,3 @@
|
|
20
33
|
|
21
34
|
<%= page_entries_info @salt_modules %>
|
22
35
|
<%= will_paginate @salt_modules %>
|
23
|
-
|
data/config/routes.rb
CHANGED
@@ -5,18 +5,30 @@ Rails.application.routes.draw do
|
|
5
5
|
match '/run/:id' => 'foreman_salt/minions#run'
|
6
6
|
end
|
7
7
|
|
8
|
-
resources :
|
8
|
+
resources :minions, :controller => 'foreman_salt/minions', :only => [] do
|
9
9
|
collection do
|
10
|
-
|
10
|
+
constraints(:id => /[^\/]+/) do
|
11
|
+
post 'salt_environment_selected'
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
|
-
resources :
|
16
|
+
resources :salt_environments, :controller => 'foreman_salt/salt_environments' do
|
15
17
|
collection do
|
16
18
|
get 'auto_complete_search'
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
22
|
+
constraints :id => /[\w\.-]+/ do
|
23
|
+
resources :salt_modules, :controller => 'foreman_salt/salt_modules' do
|
24
|
+
collection do
|
25
|
+
get 'import'
|
26
|
+
get 'auto_complete_search'
|
27
|
+
post 'apply_changes'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
20
32
|
scope :api, :path => '/api', :defaults => { :format => 'json' } do
|
21
33
|
scope '(:apiv)', :defaults => { :apiv => 'v2' },
|
22
34
|
:apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2) do
|
@@ -30,6 +42,8 @@ Rails.application.routes.draw do
|
|
30
42
|
match '/salt_autosign/:smart_proxy_id' => 'foreman_salt/api/v2/salt_autosign#index', :via => :get
|
31
43
|
match '/salt_autosign/:smart_proxy_id' => 'foreman_salt/api/v2/salt_autosign#create', :via => :post
|
32
44
|
match '/salt_autosign/:smart_proxy_id/:record' => 'foreman_salt/api/v2/salt_autosign#destroy', :via => :delete
|
45
|
+
|
46
|
+
match '/salt_states/import/:smart_proxy_id' => 'foreman_salt/api/v2/salt_states#import', :via => :post
|
33
47
|
end
|
34
48
|
|
35
49
|
constraints(:id => /[\w\.-]+/) do
|
@@ -52,4 +66,10 @@ Rails.application.routes.draw do
|
|
52
66
|
end
|
53
67
|
end
|
54
68
|
end
|
69
|
+
|
70
|
+
resources :hostgroups do
|
71
|
+
collection do
|
72
|
+
post 'salt_environment_selected'
|
73
|
+
end
|
74
|
+
end
|
55
75
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class AddEnvironmentsToModules < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
create_table 'salt_module_environments' do |t|
|
4
|
+
t.references :salt_module
|
5
|
+
t.references :salt_environment
|
6
|
+
end
|
7
|
+
|
8
|
+
environments = ForemanSalt::SaltEnvironment.all
|
9
|
+
ForemanSalt::SaltModule.all.each do |state|
|
10
|
+
state.salt_environments << environments
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def down
|
15
|
+
drop_table :salt_module_environments
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class RenameJoinTables < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
rename_table :hosts_salt_modules, :host_salt_modules
|
4
|
+
rename_table :hostgroups_salt_modules, :hostgroup_salt_modules
|
5
|
+
end
|
6
|
+
|
7
|
+
def down
|
8
|
+
rename_table :host_salt_modules, :hosts_salt_modules
|
9
|
+
rename_table :hostgroup_salt_modules, :hostgroups_salt_modules
|
10
|
+
end
|
11
|
+
end
|
data/lib/foreman_salt/engine.rb
CHANGED
@@ -2,6 +2,8 @@ require 'deface'
|
|
2
2
|
|
3
3
|
module ForemanSalt
|
4
4
|
class Engine < ::Rails::Engine
|
5
|
+
engine_name 'foreman_salt'
|
6
|
+
|
5
7
|
config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
|
6
8
|
config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
|
7
9
|
config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
|
@@ -21,6 +23,14 @@ module ForemanSalt
|
|
21
23
|
app.config.paths['db/migrate'] += ForemanSalt::Engine.paths['db/migrate'].existent
|
22
24
|
end
|
23
25
|
|
26
|
+
initializer "foreman_salt.assets.precompile" do |app|
|
27
|
+
app.config.assets.precompile += %w(foreman_salt/states.js)
|
28
|
+
end
|
29
|
+
|
30
|
+
initializer 'foreman_salt.configure_assets', :group => :assets do
|
31
|
+
SETTINGS[:foreman_salt] = {:assets => {:precompile => ['foreman_salt/states.js']}}
|
32
|
+
end
|
33
|
+
|
24
34
|
initializer 'foreman_salt.apipie' do
|
25
35
|
Apipie.configuration.checksum_path += ['/salt/api/']
|
26
36
|
end
|
@@ -93,7 +103,8 @@ module ForemanSalt
|
|
93
103
|
:resource_type => 'Host'
|
94
104
|
|
95
105
|
permission :edit_hosts,
|
96
|
-
{ :'foreman_salt/api/v2/salt_minions' => [:update]
|
106
|
+
{ :'foreman_salt/api/v2/salt_minions' => [:update],
|
107
|
+
:'foreman_salt/minions' => [:salt_environment_selected] },
|
97
108
|
:resource_type => 'Host'
|
98
109
|
|
99
110
|
permission :view_hosts,
|
@@ -101,6 +112,10 @@ module ForemanSalt
|
|
101
112
|
:'foreman_salt/api/v2/salt_minions' => [:index, :show] },
|
102
113
|
:resource_type => 'Host'
|
103
114
|
|
115
|
+
permission :edit_hostgroups,
|
116
|
+
{ :hostgroups => [:salt_environment_selected] },
|
117
|
+
:resource_type => 'Hostgroup'
|
118
|
+
|
104
119
|
permission :view_smart_proxies_salt_keys,
|
105
120
|
{ :'foreman_salt/salt_keys' => [:index],
|
106
121
|
:'foreman_salt/api/v2/salt_keys' => [:index] },
|
@@ -121,6 +136,11 @@ module ForemanSalt
|
|
121
136
|
:'foreman_salt/api/v2/salt_states' => [:create] },
|
122
137
|
:resource_type => 'ForemanSalt::SaltModule'
|
123
138
|
|
139
|
+
permission :import_salt_modules,
|
140
|
+
{ :'foreman_salt/salt_modules' => [:import, :apply_changes],
|
141
|
+
:'foreman_salt/api/v2/salt_states' => [:import] },
|
142
|
+
:resource_type => 'ForemanSalt::SaltModule'
|
143
|
+
|
124
144
|
permission :view_salt_modules,
|
125
145
|
{ :'foreman_salt/salt_modules' => [:index, :show, :auto_complete_search],
|
126
146
|
:'foreman_salt/api/v2/salt_states' => [:index, :show] },
|
data/lib/foreman_salt/version.rb
CHANGED
@@ -8,7 +8,7 @@ module ForemanSalt
|
|
8
8
|
|
9
9
|
test 'host has a salt smart proxy' do
|
10
10
|
host = FactoryGirl.create :host, :with_salt_proxy
|
11
|
-
assert host.salt_proxy.
|
11
|
+
assert host.salt_proxy.has_feature? 'Salt'
|
12
12
|
end
|
13
13
|
|
14
14
|
test 'smart_proxy_ids returns salt smart proxy' do
|
@@ -28,5 +28,19 @@ module ForemanSalt
|
|
28
28
|
host.set_hostgroup_defaults
|
29
29
|
assert_equal host.salt_proxy, hostgroup.salt_proxy
|
30
30
|
end
|
31
|
+
|
32
|
+
test 'host does not accept salt modules outside its environment' do
|
33
|
+
hosts_environment = FactoryGirl.create :salt_environment
|
34
|
+
other_environment = FactoryGirl.create :salt_environment
|
35
|
+
|
36
|
+
state = FactoryGirl.create :salt_module
|
37
|
+
other_environment.salt_modules << state
|
38
|
+
|
39
|
+
host = FactoryGirl.create :host, :with_salt_proxy, :salt_environment => hosts_environment
|
40
|
+
host.salt_modules = [state]
|
41
|
+
|
42
|
+
refute host.save
|
43
|
+
assert host.errors.full_messages.include? 'Salt states must be in the environment of the host'
|
44
|
+
end
|
31
45
|
end
|
32
46
|
end
|
@@ -14,7 +14,7 @@ module ForemanSalt
|
|
14
14
|
test 'nested host group inherits salt modules from parent' do
|
15
15
|
parent = FactoryGirl.create :hostgroup, :with_salt_modules
|
16
16
|
child = FactoryGirl.create :hostgroup, :parent => parent
|
17
|
-
assert_equal [], parent.
|
17
|
+
assert_equal [], parent.all_salt_modules - child.all_salt_modules
|
18
18
|
end
|
19
19
|
|
20
20
|
test 'child host group inherits salt proxy from child parent' do
|
@@ -34,7 +34,7 @@ module ForemanSalt
|
|
34
34
|
parent = FactoryGirl.create :hostgroup, :with_salt_modules
|
35
35
|
child_one = FactoryGirl.create :hostgroup, :parent => parent
|
36
36
|
child_two = FactoryGirl.create :hostgroup, :parent => child_one
|
37
|
-
assert_equal [], parent.
|
37
|
+
assert_equal [], parent.all_salt_modules - child_two.all_salt_modules
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_salt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Benjamin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - <
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.0'
|
20
20
|
type: :runtime
|
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.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: foreman-tasks
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.6.9
|
34
34
|
type: :runtime
|
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.6.9
|
41
41
|
description: Foreman Plug-in for Salt
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- LICENSE
|
49
49
|
- README.md
|
50
50
|
- Rakefile
|
51
|
+
- app/assets/javascripts/foreman_salt/states.js
|
51
52
|
- app/controllers/foreman_salt/api/v2/base_controller.rb
|
52
53
|
- app/controllers/foreman_salt/api/v2/jobs_controller.rb
|
53
54
|
- app/controllers/foreman_salt/api/v2/salt_autosign_controller.rb
|
@@ -64,21 +65,25 @@ files:
|
|
64
65
|
- app/controllers/foreman_salt/salt_environments_controller.rb
|
65
66
|
- app/controllers/foreman_salt/salt_keys_controller.rb
|
66
67
|
- app/controllers/foreman_salt/salt_modules_controller.rb
|
68
|
+
- app/controllers/foreman_salt/state_importer.rb
|
67
69
|
- app/helpers/concerns/foreman_salt/hosts_helper_extensions.rb
|
68
70
|
- app/helpers/concerns/foreman_salt/smart_proxies_helper_extensions.rb
|
69
71
|
- app/helpers/foreman_salt/salt_keys_helper.rb
|
72
|
+
- app/helpers/foreman_salt/salt_modules_helper.rb
|
70
73
|
- app/lib/actions/foreman_salt/report_import.rb
|
71
74
|
- app/lib/proxy_api/salt.rb
|
72
75
|
- app/models/foreman_salt/concerns/host_managed_extensions.rb
|
73
76
|
- app/models/foreman_salt/concerns/hostgroup_extensions.rb
|
74
77
|
- app/models/foreman_salt/concerns/orchestration/salt.rb
|
75
78
|
- app/models/foreman_salt/fact_name.rb
|
79
|
+
- app/models/foreman_salt/host_salt_module.rb
|
80
|
+
- app/models/foreman_salt/hostgroup_salt_module.rb
|
76
81
|
- app/models/foreman_salt/salt_environment.rb
|
77
82
|
- app/models/foreman_salt/salt_module.rb
|
83
|
+
- app/models/foreman_salt/salt_module_environment.rb
|
78
84
|
- app/models/setting/salt.rb
|
79
|
-
- app/overrides/
|
80
|
-
- app/overrides/
|
81
|
-
- app/overrides/salt_environment_selector.rb
|
85
|
+
- app/overrides/salt_environment_host_selector.rb
|
86
|
+
- app/overrides/salt_environment_hostgroup_selector.rb
|
82
87
|
- app/overrides/salt_modules_selector.rb
|
83
88
|
- app/overrides/salt_proxy_selector.rb
|
84
89
|
- app/services/foreman_salt/fact_importer.rb
|
@@ -116,7 +121,10 @@ files:
|
|
116
121
|
- app/views/foreman_salt/salt_environments/new.html.erb
|
117
122
|
- app/views/foreman_salt/salt_keys/index.erb
|
118
123
|
- app/views/foreman_salt/salt_modules/_form.html.erb
|
124
|
+
- app/views/foreman_salt/salt_modules/_host_tab.html.erb
|
125
|
+
- app/views/foreman_salt/salt_modules/_host_tab_pane.html.erb
|
119
126
|
- app/views/foreman_salt/salt_modules/edit.html.erb
|
127
|
+
- app/views/foreman_salt/salt_modules/import.html.erb
|
120
128
|
- app/views/foreman_salt/salt_modules/index.html.erb
|
121
129
|
- app/views/foreman_salt/salt_modules/new.html.erb
|
122
130
|
- config/routes.rb
|
@@ -125,6 +133,9 @@ files:
|
|
125
133
|
- db/migrate/20140829210214_add_salt_modules_to_hostgroups.rb
|
126
134
|
- db/migrate/20140920232200_create_salt_environments.rb
|
127
135
|
- db/migrate/20150220122707_fix_incorrect_report_metrics.rb
|
136
|
+
- db/migrate/20150411003302_add_environments_to_modules.rb
|
137
|
+
- db/migrate/20150509094409_rename_join_tables.rb
|
138
|
+
- db/migrate/20150509101505_add_primary_keys.rb
|
128
139
|
- db/seeds.d/75-salt-seeds.rb
|
129
140
|
- lib/foreman_salt.rb
|
130
141
|
- lib/foreman_salt/engine.rb
|
@@ -159,12 +170,12 @@ require_paths:
|
|
159
170
|
- lib
|
160
171
|
required_ruby_version: !ruby/object:Gem::Requirement
|
161
172
|
requirements:
|
162
|
-
- -
|
173
|
+
- - ! '>='
|
163
174
|
- !ruby/object:Gem::Version
|
164
175
|
version: '0'
|
165
176
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
177
|
requirements:
|
167
|
-
- -
|
178
|
+
- - ! '>='
|
168
179
|
- !ruby/object:Gem::Version
|
169
180
|
version: '0'
|
170
181
|
requirements: []
|
@@ -174,22 +185,22 @@ signing_key:
|
|
174
185
|
specification_version: 4
|
175
186
|
summary: Foreman Plug-in for Salt
|
176
187
|
test_files:
|
177
|
-
- test/
|
178
|
-
- test/
|
179
|
-
- test/
|
180
|
-
- test/
|
188
|
+
- test/functional/minions_controller_test.rb
|
189
|
+
- test/functional/api/v2/salt_states_controller_test.rb
|
190
|
+
- test/functional/api/v2/salt_autosign_controller_test.rb
|
191
|
+
- test/functional/api/v2/salt_keys_controller_test.rb
|
192
|
+
- test/functional/api/v2/salt_environments_controller_test.rb
|
193
|
+
- test/factories/foreman_salt_factories.rb
|
181
194
|
- test/unit/salt_keys_test.rb
|
182
|
-
- test/unit/grains_centos.json
|
183
195
|
- test/unit/host_extensions_test.rb
|
184
|
-
- test/unit/
|
185
|
-
- test/unit/highstate.json
|
196
|
+
- test/unit/grains_centos.json
|
186
197
|
- test/unit/grains_importer_test.rb
|
187
198
|
- test/unit/hostgroup_extensions_test.rb
|
188
199
|
- test/unit/report_importer_test.rb
|
200
|
+
- test/unit/salt_modules_test.rb
|
201
|
+
- test/unit/highstate.json
|
189
202
|
- test/test_plugin_helper.rb
|
190
|
-
- test/
|
191
|
-
- test/
|
192
|
-
- test/
|
193
|
-
- test/
|
194
|
-
- test/functional/api/v2/salt_states_controller_test.rb
|
195
|
-
- test/functional/api/v2/salt_keys_controller_test.rb
|
203
|
+
- test/integration/salt_keys_test.rb
|
204
|
+
- test/integration/salt_environment_test.rb
|
205
|
+
- test/integration/salt_autosign_test.rb
|
206
|
+
- test/integration/salt_module_test.rb
|