foreman_acd 0.0.6 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +107 -56
- data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +124 -0
- data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +72 -0
- data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +2 -2
- data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +62 -0
- data/app/controllers/foreman_acd/app_definitions_controller.rb +46 -9
- data/app/controllers/foreman_acd/app_instances_controller.rb +96 -90
- data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +23 -0
- data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
- data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
- data/app/controllers/foreman_acd/remote_execution_controller.rb +46 -0
- data/app/controllers/ui_acd_controller.rb +20 -4
- data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +42 -0
- data/app/lib/actions/foreman_acd/run_configurator.rb +41 -0
- data/app/models/concerns/foreman_acd/host_managed_extensions.rb +51 -0
- data/app/models/foreman_acd/acd_provider.rb +30 -0
- data/app/models/foreman_acd/ansible_playbook.rb +67 -0
- data/app/models/foreman_acd/app_definition.rb +25 -1
- data/app/models/foreman_acd/app_instance.rb +42 -0
- data/app/models/foreman_acd/foreman_host.rb +23 -0
- data/app/models/foreman_acd/taxonomy_extensions.rb +17 -0
- data/app/services/foreman_acd/app_configurator.rb +54 -0
- data/app/services/foreman_acd/app_deployer.rb +151 -0
- data/app/services/foreman_acd/inventory_creator.rb +54 -0
- data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +30 -0
- data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +11 -0
- data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
- data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +9 -0
- data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +9 -0
- data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +5 -0
- data/app/views/foreman_acd/app_definitions/_form.html.erb +34 -20
- data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -0
- data/app/views/foreman_acd/app_definitions/import.html.erb +18 -0
- data/app/views/foreman_acd/app_definitions/index.html.erb +10 -6
- data/app/views/foreman_acd/app_instances/_form.html.erb +12 -10
- data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
- data/app/views/foreman_acd/app_instances/index.html.erb +87 -9
- data/app/views/foreman_acd/app_instances/report.html.erb +22 -0
- data/app/views/templates/job/run_acd_ansible_playbook.erb +62 -0
- data/app/views/ui_acd/ansible_data.json.rabl +6 -0
- data/app/views/ui_acd/app.json.rabl +6 -2
- data/app/views/ui_acd/app_definition.json.rabl +1 -1
- data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
- data/config/routes.rb +35 -1
- data/db/migrate/20190610202252_create_app_definitions.rb +1 -3
- data/db/migrate/20190625140305_create_app_instances.rb +1 -1
- data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
- data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
- data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +8 -0
- data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +8 -0
- data/db/migrate/20210112111548_add_organization_to_app_instance.rb +22 -0
- data/db/migrate/20210112113853_add_location_to_app_instance.rb +8 -0
- data/db/migrate/20210202141658_create_foreman_hosts.rb +24 -0
- data/db/migrate/20210204111306_remove_hosts_from_app_instances.rb +8 -0
- data/db/migrate/20210209091014_rename_acd_tables.rb +16 -0
- data/db/migrate/20210216083522_add_last_progress_report.rb +8 -0
- data/db/migrate/20210216091529_add_last_deploy_task.rb +8 -0
- data/db/seeds.d/62_acd_proxy_feature.rb +4 -0
- data/db/seeds.d/75-job_templates.rb +13 -0
- data/lib/foreman_acd/engine.rb +21 -3
- data/lib/foreman_acd/plugin.rb +112 -20
- data/lib/foreman_acd/version.rb +1 -1
- data/locale/en/foreman_acd.edit.po +326 -0
- data/locale/en/foreman_acd.po +232 -2
- data/locale/en/foreman_acd.po.time_stamp +0 -0
- data/locale/foreman_acd.pot +343 -8
- data/package.json +1 -1
- data/test/controllers/ansible_playbooks_controller_test.rb +27 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +391 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.scss +1 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +303 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +15 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +269 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +9 -0
- data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +49 -0
- data/webpack/components/ApplicationDefinition/index.js +35 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +451 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.scss +11 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +247 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +15 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +309 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +10 -0
- data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +49 -0
- data/webpack/components/ApplicationInstance/components/Service.js +30 -0
- data/webpack/components/ApplicationInstance/components/ServiceCounter.js +37 -0
- data/webpack/components/ApplicationInstance/index.js +37 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +148 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +44 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +42 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +2 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +38 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +4 -0
- data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +26 -0
- data/webpack/components/ApplicationInstanceReport/index.js +25 -0
- data/webpack/components/ParameterSelection/ParameterSelection.js +131 -192
- data/webpack/components/ParameterSelection/ParameterSelection.scss +9 -0
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +87 -110
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +15 -19
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +3 -35
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +116 -84
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +3 -7
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +12 -21
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +1 -1
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +3 -45
- data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +20 -0
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +22 -46
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +40 -265
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +11 -96
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +3 -9
- data/webpack/components/ParameterSelection/index.js +6 -8
- data/webpack/components/common/AddTableEntry.js +30 -0
- data/webpack/components/common/DeleteTableEntry.js +39 -0
- data/webpack/components/common/EasyHeaderFormatter.js +18 -0
- data/webpack/components/common/EditTableEntry.js +50 -0
- data/webpack/components/common/ExtSelect.js +43 -0
- data/webpack/components/common/LockTableEntry.js +60 -0
- data/webpack/components/common/RailsData.js +27 -0
- data/webpack/components/common/__tests__/AddTableEntry.test.js +26 -0
- data/webpack/components/common/__tests__/DeleteTableEntry.test.js +29 -0
- data/webpack/components/common/__tests__/ExtSelect.test.js +38 -0
- data/webpack/components/common/__tests__/RailsData.test.js +16 -0
- data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +35 -0
- data/webpack/components/common/__tests__/__snapshots__/AddTableEntry.test.js.snap +35 -0
- data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +41 -0
- data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +41 -0
- data/webpack/components/common/__tests__/__snapshots__/ExtSelect.test.js.snap +18 -0
- data/webpack/components/common/__tests__/__snapshots__/RailsData.test.js.snap +10 -0
- data/webpack/helper.js +20 -0
- data/webpack/index.js +6 -0
- data/webpack/reducer.js +43 -3
- metadata +114 -20
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ForemanAcd
|
4
|
+
# inventory creator for application instances
|
5
|
+
class InventoryCreator
|
6
|
+
delegate :logger, :to => :Rails
|
7
|
+
|
8
|
+
def initialize(app_instance, foreman_hosts)
|
9
|
+
@app_instance = app_instance
|
10
|
+
@foreman_hosts = foreman_hosts
|
11
|
+
end
|
12
|
+
|
13
|
+
# TODO: this might be part of the smart proxy plugin.
|
14
|
+
def create_inventory
|
15
|
+
inventory = {}
|
16
|
+
inventory['all'] = {}
|
17
|
+
|
18
|
+
inventory['all'] = { 'vars' => inventory_all_vars } if @app_instance.ansible_vars_all.present?
|
19
|
+
|
20
|
+
services = JSON.parse(@app_instance.app_definition.services)
|
21
|
+
|
22
|
+
children = {}
|
23
|
+
@foreman_hosts.each do |foreman_host|
|
24
|
+
if foreman_host.host_id.nil?
|
25
|
+
logger.warn "Ignore host #{foreman_h.hostname} because no foreman host id could be found. Is the host not provisioned yet?"
|
26
|
+
next
|
27
|
+
end
|
28
|
+
|
29
|
+
service_id = foreman_host.service.to_i
|
30
|
+
host_service = services.select { |s| s['id'] == service_id }.first
|
31
|
+
ansible_group = host_service['ansibleGroup']
|
32
|
+
|
33
|
+
children[ansible_group] = { 'hosts' => {} } unless children.key?(host_service['ansibleGroup'])
|
34
|
+
|
35
|
+
ansible_vars = JSON.parse(foreman_host.ansibleParameters).map { |v| { v['name'] => v['value'] } }.reduce({}, :merge!)
|
36
|
+
|
37
|
+
# in case there is no ansible_user defined, set "root" as default.
|
38
|
+
ansible_vars['ansible_user'] = 'root' unless ansible_vars.key?('ansible_user')
|
39
|
+
|
40
|
+
children[ansible_group]['hosts'][foreman_host.host.name] = ansible_vars
|
41
|
+
end
|
42
|
+
inventory['all']['children'] = children
|
43
|
+
inventory
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def inventory_all_vars
|
49
|
+
JSON.parse(@app_instance.ansible_vars_all).map do |a|
|
50
|
+
{ a['name'] => a['value'] }
|
51
|
+
end.reduce({}, :merge!)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<%= form_for @ansible_playbook, :url => (@ansible_playbook.new_record? ? ansible_playbooks_path : ansible_playbook_path(:id => @ansible_playbook.id)) do |f| %>
|
2
|
+
<%= base_errors_for @ansible_playbook %>
|
3
|
+
|
4
|
+
<ul class="nav nav-tabs" data-tabs="tabs">
|
5
|
+
<li class="active"><a href="#primary" data-toggle="tab"><%= _('Ansible playbooks') %></a></li>
|
6
|
+
<% if show_location_tab? %>
|
7
|
+
<li><a href="#locations" data-toggle="tab"><%= _("Locations") %></a></li>
|
8
|
+
<% end %>
|
9
|
+
<% if show_organization_tab? %>
|
10
|
+
<li><a href="#organizations" data-toggle="tab"><%= _("Organizations") %></a></li>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
13
|
+
|
14
|
+
<div class="tab-content">
|
15
|
+
<div class="tab-pane active" id="primary">
|
16
|
+
<%= text_f f, :name %>
|
17
|
+
<%= text_f f, :description %>
|
18
|
+
<%= f.hidden_field :scm_type, :value => 'directory' %>
|
19
|
+
<% # TODO:
|
20
|
+
# select_f(f, :scm_type, %w[Directory GIT], :downcase, :to_s)
|
21
|
+
%>
|
22
|
+
<%= text_f f, :path, :required => true %>
|
23
|
+
<%= text_f f, :playfile, :required => true %>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<%= render 'taxonomies/loc_org_tabs', :f => f, :obj => @ansible_playbook %>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<%= submit_or_cancel f %>
|
30
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%=
|
2
|
+
breadcrumbs(:resource_url => "/acd/api/v2/ansible_playbooks",
|
3
|
+
:items => [
|
4
|
+
{ :caption => _('Ansible Playbooks'),
|
5
|
+
:url => url_for(ansible_playbooks_path) },
|
6
|
+
{ :caption => "Edit #{@ansible_playbook.name}",
|
7
|
+
:url => (edit_ansible_playbook_path(@ansible_playbook) if authorized_for(hash_for_edit_ansible_playbook_path(@ansible_playbook))) }
|
8
|
+
])
|
9
|
+
%>
|
10
|
+
<% title(_('Edit Ansible Playbook %s') % @ansible_playbook) %>
|
11
|
+
<%= render :partial => 'form' %>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<% title _('Ansible Playbooks') %>
|
2
|
+
|
3
|
+
<% title_actions button_group(
|
4
|
+
new_link(_('New Ansible Playbook')),
|
5
|
+
) %>
|
6
|
+
|
7
|
+
<table class="table table-bordered table-striped">
|
8
|
+
<tr>
|
9
|
+
<th><%= sort :name, :as => s_('AnsiblePlaybook|Name') %></th>
|
10
|
+
<th><%= _('Description') %></th>
|
11
|
+
<th></th>
|
12
|
+
</tr>
|
13
|
+
<% for ansible_playbook in @ansible_playbooks %>
|
14
|
+
<tr>
|
15
|
+
<td><%=link_to_if_authorized h(ansible_playbook.name), hash_for_edit_ansible_playbook_path(:id => ansible_playbook) %></td>
|
16
|
+
<td><%= ansible_playbook.description %></td>
|
17
|
+
<td>
|
18
|
+
<%= action_buttons(
|
19
|
+
display_link_if_authorized(_("Import groups"), hash_for_import_vars_ansible_playbook_path(:id => ansible_playbook)),
|
20
|
+
display_delete_if_authorized(hash_for_ansible_playbook_path(:id => ansible_playbook),
|
21
|
+
:data => { 'confirm': _('Delete %s?') % ansible_playbook.name })
|
22
|
+
) %>
|
23
|
+
</td>
|
24
|
+
</tr>
|
25
|
+
<% end %>
|
26
|
+
</table>
|
27
|
+
|
28
|
+
<%= page_entries_info @ansible_playbooks %>
|
29
|
+
<%= will_paginate @ansible_playbooks %>
|
30
|
+
|
@@ -1,29 +1,41 @@
|
|
1
1
|
<%
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
else
|
12
|
-
json["mode"] = "editDefinition"
|
13
|
-
json["appDefinition"] = {
|
14
|
-
"id": @app_definition.id,
|
15
|
-
"name": @app_definition.name,
|
16
|
-
"hostgroup_id": @app_definition.hostgroup_id,
|
17
|
-
}
|
18
|
-
json["parameters"] = JSON.parse(@app_definition.parameters)
|
19
|
-
end
|
2
|
+
json = {
|
3
|
+
"organization": current_organization,
|
4
|
+
"location": current_location,
|
5
|
+
"hostgroups": @hostgroups,
|
6
|
+
"foremanDataUrl": ui_acd_foreman_data_path("__id__"),
|
7
|
+
"ansibleDataUrl": ui_acd_ansible_data_path("__id__"),
|
8
|
+
"services": [],
|
9
|
+
"ansibleVarsAll": [],
|
10
|
+
}
|
20
11
|
|
12
|
+
if @app_definition.new_record?
|
13
|
+
json["mode"] = "newDefinition"
|
14
|
+
json["ansiblePlaybooks"] = @ansible_playbooks
|
15
|
+
else
|
16
|
+
json["mode"] = "editDefinition"
|
17
|
+
json["ansiblePlaybook"] = @app_definition.ansible_playbook.as_unified_structobj
|
18
|
+
end
|
19
|
+
|
20
|
+
if @app_definition.services.present?
|
21
|
+
json["services"] = JSON.parse(@app_definition.services)
|
22
|
+
end
|
23
|
+
|
24
|
+
if @app_definition.ansible_vars_all.present?
|
25
|
+
json["ansibleVarsAll"] = JSON.parse(@app_definition.ansible_vars_all)
|
26
|
+
end
|
21
27
|
%>
|
22
28
|
|
23
29
|
<%= form_for @app_definition, :url => (@app_definition.new_record? ? app_definitions_path : app_definition_path(:id => @app_definition.id)) do |f| %>
|
24
30
|
<%= base_errors_for @app_definition %>
|
25
31
|
<ul class="nav nav-tabs" data-tabs="tabs">
|
26
32
|
<li class="active"><a href="#primary" data-toggle="tab"><%= _('Application Definitions') %></a></li>
|
33
|
+
<% if show_location_tab? %>
|
34
|
+
<li><a href="#locations" data-toggle="tab"><%= _("Locations") %></a></li>
|
35
|
+
<% end %>
|
36
|
+
<% if show_organization_tab? %>
|
37
|
+
<li><a href="#organizations" data-toggle="tab"><%= _("Organizations") %></a></li>
|
38
|
+
<% end %>
|
27
39
|
</ul>
|
28
40
|
|
29
41
|
<div class="tab-content">
|
@@ -31,9 +43,11 @@
|
|
31
43
|
<%= text_f f, :name %>
|
32
44
|
<%= text_f f, :description %>
|
33
45
|
|
34
|
-
<div id='
|
35
|
-
<%= mount_react_component('
|
46
|
+
<div id='app_definition'></div>
|
47
|
+
<%= mount_react_component('ApplicationDefinition', "#app_definition", json.to_json) %>
|
36
48
|
</div>
|
49
|
+
|
50
|
+
<%= render 'taxonomies/loc_org_tabs', :f => f, :obj => @app_definition %>
|
37
51
|
</div>
|
38
52
|
|
39
53
|
<%= submit_or_cancel f %>
|
@@ -1,3 +1,13 @@
|
|
1
|
+
<%=
|
2
|
+
breadcrumbs(:resource_url => "/acd/api/v2/app_definitions",
|
3
|
+
:items => [
|
4
|
+
{ :caption => _('App Definitions'),
|
5
|
+
:url => url_for(app_definitions_path) },
|
6
|
+
{ :caption => "Edit #{@app_definition.name}",
|
7
|
+
:url => (edit_app_definition_path(@app_definition) if authorized_for(hash_for_edit_app_definition_path(@app_definition))) }
|
8
|
+
])
|
9
|
+
%>
|
10
|
+
|
1
11
|
<% title(_('Edit Application Definition %s') % @app_definition) %>
|
2
12
|
|
3
13
|
<% content_for(:javascripts) do %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<% title _('Import Application Definition') %>
|
2
|
+
|
3
|
+
<%= form_for @app_definition, :url => (app_definitions_path), :html => { :multipart => true } do |f| %>
|
4
|
+
<%= base_errors_for @app_definition %>
|
5
|
+
<ul class="nav nav-tabs" data-tabs="tabs">
|
6
|
+
<li class="active"><a href="#primary" data-toggle="tab"><%= _('Application Definitions') %></a></li>
|
7
|
+
</ul>
|
8
|
+
|
9
|
+
<div class="tab-content">
|
10
|
+
<div class="tab-pane active" id="primary">
|
11
|
+
<%= text_f f, :name %>
|
12
|
+
<%= text_f f, :description %>
|
13
|
+
<%= file_field_f f, :app_definition_file, :label_help => _("Application Definition file") %>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<%= submit_or_cancel f %>
|
18
|
+
<% end %>
|
@@ -1,22 +1,26 @@
|
|
1
1
|
<% title _('Application Definitions') %>
|
2
2
|
|
3
|
-
<% title_actions button_group(
|
3
|
+
<% title_actions button_group(
|
4
|
+
new_link(_('New Application Definition')),
|
5
|
+
display_link_if_authorized(_("Import"), hash_for_import_app_definitions_path, :class => 'btn btn-default', :style => "display: none;")
|
6
|
+
) %>
|
4
7
|
|
5
8
|
<table class="table table-bordered table-striped">
|
6
9
|
<tr>
|
7
10
|
<th><%= sort :name, :as => s_('AppDefinition|Name') %></th>
|
8
11
|
<th><%= _('Description') %></th>
|
9
|
-
<th><%= sort :hostgroup, :as => _('Host groups'), :default => 'DESC' %></th>
|
10
12
|
<th></th>
|
11
13
|
</tr>
|
12
14
|
<% for app_definition in @app_definitions %>
|
13
15
|
<tr>
|
14
|
-
<td><%=link_to_if_authorized h(app_definition.name), hash_for_edit_app_definition_path(:id => app_definition)
|
16
|
+
<td><%=link_to_if_authorized h(app_definition.name), hash_for_edit_app_definition_path(:id => app_definition) %></td>
|
15
17
|
<td><%= app_definition.description %></td>
|
16
|
-
<td><%= app_definition.hostgroup %></td>
|
17
18
|
<td>
|
18
|
-
|
19
|
-
|
19
|
+
<%= action_buttons(
|
20
|
+
display_delete_if_authorized(hash_for_app_definition_path(:id => app_definition),
|
21
|
+
:data => { 'confirm': _('Delete %s?') % app_definition.name }),
|
22
|
+
# TODO: add export feature again if app-def + ansible playbook can be exported together display_link_if_authorized(_("Export"), hash_for_export_app_definition_path(:id => app_definition))
|
23
|
+
) %>
|
20
24
|
</td>
|
21
25
|
</tr>
|
22
26
|
<% end %>
|
@@ -1,25 +1,27 @@
|
|
1
1
|
<%
|
2
|
-
if @app_instance.
|
2
|
+
if @app_instance.new_record?
|
3
3
|
json = {
|
4
4
|
"mode": "newInstance",
|
5
5
|
"organization": current_organization,
|
6
6
|
"location": current_location,
|
7
7
|
"applications": @applications,
|
8
|
-
"
|
9
|
-
"
|
8
|
+
"appDefinitionUrl": ui_acd_app_path("__id__"),
|
9
|
+
"foremanDataUrl": ui_acd_foreman_data_path("__id__"),
|
10
|
+
"ansibleVarsAll": [],
|
10
11
|
}
|
11
12
|
else
|
12
13
|
json = {
|
13
14
|
"mode": "editInstance",
|
14
15
|
"organization": current_organization,
|
15
16
|
"location": current_location,
|
16
|
-
"
|
17
|
+
"appDefinitionUrl": ui_acd_app_path("__id__"),
|
18
|
+
"foremanDataUrl": ui_acd_foreman_data_path("__id__"),
|
17
19
|
"appDefinition": {
|
18
20
|
"id": @app_instance.app_definition.id,
|
19
21
|
"name": @app_instance.app_definition.name,
|
20
|
-
"hostgroup_id": @app_instance.app_definition.hostgroup_id,
|
21
22
|
},
|
22
|
-
"
|
23
|
+
"hosts": collect_hosts_data,
|
24
|
+
"ansibleVarsAll": @app_instance.ansible_vars_all.blank? ? [] : JSON.parse(@app_instance.ansible_vars_all),
|
23
25
|
}
|
24
26
|
end
|
25
27
|
%>
|
@@ -35,12 +37,12 @@
|
|
35
37
|
<%= text_f f, :name %>
|
36
38
|
<%= text_f f, :description %>
|
37
39
|
|
38
|
-
<div id='
|
39
|
-
<%= mount_react_component('
|
40
|
+
<div id='app_instance'></div>
|
41
|
+
<%= mount_react_component('ApplicationInstance', "#app_instance", json.to_json) %>
|
40
42
|
</div>
|
41
43
|
</div>
|
42
44
|
</div>
|
43
|
-
|
45
|
+
<%= f.hidden_field :organization_id %>
|
46
|
+
<%= f.hidden_field :location_id %>
|
44
47
|
<%= submit_or_cancel f %>
|
45
48
|
<% end %>
|
46
|
-
|
@@ -1,3 +1,13 @@
|
|
1
|
+
<%=
|
2
|
+
breadcrumbs(:resource_url => "/acd/api/v2/app_instances?location_id=#{@location.id}&organization_id=#{@organization.id}",
|
3
|
+
:items => [
|
4
|
+
{ :caption => _('App Instances'),
|
5
|
+
:url => url_for(app_instances_path) },
|
6
|
+
{ :caption => "Edit #{@app_instance.name}",
|
7
|
+
:url => (edit_app_instance_path(@app_instance) if authorized_for(hash_for_edit_app_instance_path(@app_instance))) }
|
8
|
+
])
|
9
|
+
%>
|
10
|
+
|
1
11
|
<% title(_('Edit Application Instance %s') % @app_instance) %>
|
2
12
|
|
3
13
|
<% content_for(:javascripts) do %>
|
@@ -7,24 +7,102 @@
|
|
7
7
|
<th><%= sort :name, :as => s_('AppInstance|Name') %></th>
|
8
8
|
<th><%= sort :application, :as => _('Application'), :default => 'DESC' %></th>
|
9
9
|
<th><%= _('Description') %></th>
|
10
|
+
<th><%= _('Report') %></th>
|
10
11
|
<th></th>
|
11
12
|
</tr>
|
12
13
|
<% for app_instance in @app_instances %>
|
13
14
|
<tr>
|
14
|
-
<td><%=link_to_if_authorized h(app_instance.name), hash_for_edit_app_instance_path(:id => app_instance)
|
15
|
+
<td><%=link_to_if_authorized h(app_instance.name), hash_for_edit_app_instance_path(:id => app_instance) %></td>
|
15
16
|
<td><%= app_instance.app_definition %></td>
|
16
17
|
<td><%= app_instance.description %></td>
|
18
|
+
<td><%= link_to_if((authorized_for(:auth_object => app_instance, :authorizer => authorizer, :permission => :report_app_instances) &&
|
19
|
+
!app_instance.last_deploy_task.nil? && app_instance.last_deploy_task.ended_at?),
|
20
|
+
_("Show Report"),
|
21
|
+
hash_for_report_app_instance_path(:id => app_instance),
|
22
|
+
:method => :get, :title => _("Show last deployment report for application #{app_instance}")) %></td>
|
17
23
|
<td>
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
<%= action_buttons(
|
25
|
+
display_link_if_authorized(_("Deploy"), { :use_route=>"#",
|
26
|
+
:id => app_instance.id,
|
27
|
+
:action => :deploy,
|
28
|
+
:auth_object => app_instance,
|
29
|
+
:controller => :app_instances },
|
30
|
+
:remote => true, 'data-toggle': "modal", 'data-target': "#deploy#{app_instance.id}",
|
31
|
+
:title => _("Deploy application #{app_instance}")),
|
32
|
+
display_link_if_authorized(_("Run Playbook"),
|
33
|
+
hash_for_remote_execution_path(:id => app_instance.id),
|
34
|
+
:method => :post,
|
35
|
+
:title => _("Run ansible playbook for application #{app_instance}")),
|
36
|
+
display_link_if_authorized(_("Run Playbook - customize first"),
|
37
|
+
hash_for_remote_execution_path(:id => app_instance.id, :customize => true),
|
38
|
+
:method => :post,
|
39
|
+
:title => _("Prepare job to run ansible playbook for application #{app_instance}")),
|
40
|
+
display_link_if_authorized(_("Delete"), { :use_route=>"#",
|
41
|
+
:id => app_instance.id,
|
42
|
+
:action => :destroy,
|
43
|
+
:auth_object => app_instance,
|
44
|
+
:controller => :app_instances },
|
45
|
+
:remote => true, 'data-toggle': "modal", 'data-target': "#delete#{app_instance.id}",
|
46
|
+
:title => _("Delete application #{app_instance}"))
|
47
|
+
) %>
|
48
|
+
</td>
|
24
49
|
</tr>
|
50
|
+
<!-- Delete Modal -->
|
51
|
+
<div class="modal fade" id="delete<%=app_instance.id%>" tabindex="-1" role="dialog" aria-labelledby="deleteLabel" aria-hidden="true">
|
52
|
+
<div class="modal-dialog">
|
53
|
+
<div class="modal-content">
|
54
|
+
<div class="modal-header">
|
55
|
+
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
56
|
+
<h4 class="modal-title"><%= _('Confirmation Box')%></h4>
|
57
|
+
</div>
|
58
|
+
<div class="modal-body">
|
59
|
+
<p> <%= _("Confirm to delete ") %> <%= app_instance %></p>
|
60
|
+
<%= form_tag destroy_with_hosts_app_instance_path(:id => app_instance.id), :method => :delete do %>
|
61
|
+
<% if app_instance.foreman_hosts.where.not(:host_id => [nil, false]).any? %>
|
62
|
+
<p><%= _("Select the hosts to delete along with ") %> <%= app_instance %>: </p>
|
63
|
+
<% end %>
|
64
|
+
<% app_instance.foreman_hosts.each do |foreman_host|%>
|
65
|
+
<% if foreman_host.host_id? %>
|
66
|
+
<%= check_box_tag 'foreman_host_ids[]', foreman_host.host_id -%>
|
67
|
+
<%= h foreman_host.host.name -%>
|
68
|
+
</br>
|
69
|
+
<% end %>
|
70
|
+
<% end %>
|
71
|
+
</div>
|
72
|
+
<div class="modal-footer">
|
73
|
+
<button type="button" class="btn btn-primary" data-dismiss="modal"><%= _('Cancel') %></button>
|
74
|
+
<%= submit_tag _("Delete"), name: nil, class: "btn btn-danger" %>
|
75
|
+
<% end %>
|
76
|
+
</div>
|
77
|
+
</div><!-- /.modal-content -->
|
78
|
+
</div><!-- /.modal-dialog -->
|
79
|
+
</div><!-- /.modal -->
|
80
|
+
|
81
|
+
<!-- Deploy Modal -->
|
82
|
+
<div class="modal fade" id="deploy<%=app_instance.id%>" tabindex="-1" role="dialog" aria-labelledby="deployLabel" aria-hidden="true">
|
83
|
+
<div class="modal-dialog">
|
84
|
+
<div class="modal-content">
|
85
|
+
<div class="modal-header">
|
86
|
+
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
87
|
+
<h4 class="modal-title"><%= _('Confirmation Box') %></h4>
|
88
|
+
</div>
|
89
|
+
<div class="modal-body">
|
90
|
+
<p><%= _('Confirm to deploy ') %><%= app_instance%></p>
|
91
|
+
<%= form_tag deploy_app_instance_path(:id => app_instance.id), :method => :post do %>
|
92
|
+
<!-- TODO: Add safe-deploy method with delete all hosts option
|
93
|
+
<% if app_instance.foreman_hosts.where.not(:host_id => [nil, false]).any? %>
|
94
|
+
<%= check_box_tag 'delete_hosts'-%><%= _('Delete all hosts before deploying ') %><%= app_instance%>
|
95
|
+
<% end %> -->
|
96
|
+
</div>
|
97
|
+
<div class="modal-footer">
|
98
|
+
<button type="button" class="btn btn-danger" data-dismiss="modal"><%= _('Cancel') %></button>
|
99
|
+
<%= submit_tag _("Submit"), name: nil, class: "btn btn-success" %>
|
100
|
+
<% end %>
|
101
|
+
</div>
|
102
|
+
</div><!-- /.modal-content -->
|
103
|
+
</div><!-- /.modal-dialog -->
|
104
|
+
</div><!-- /.modal -->
|
25
105
|
<% end %>
|
26
106
|
</table>
|
27
|
-
|
28
107
|
<%= page_entries_info @app_instances %>
|
29
108
|
<%= will_paginate @app_instances %>
|
30
|
-
|