foreman_acd 0.0.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +79 -26
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +122 -0
  4. data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +54 -0
  5. data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -2
  6. data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +54 -0
  7. data/app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb +0 -0
  8. data/app/controllers/foreman_acd/app_definitions_controller.rb +36 -4
  9. data/app/controllers/foreman_acd/app_instances_controller.rb +24 -90
  10. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +23 -0
  11. data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
  12. data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
  13. data/app/controllers/foreman_acd/remote_execution_controller.rb +49 -0
  14. data/app/controllers/ui_acd_controller.rb +11 -4
  15. data/app/models/foreman_acd/ansible_playbook.rb +50 -0
  16. data/app/models/foreman_acd/app_definition.rb +2 -1
  17. data/app/models/foreman_acd/app_instance.rb +7 -0
  18. data/app/services/foreman_acd/app_configurator.rb +70 -0
  19. data/app/services/foreman_acd/app_deployer.rb +139 -0
  20. data/app/services/foreman_acd/inventory_creator.rb +67 -0
  21. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +21 -0
  22. data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +3 -0
  23. data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
  24. data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
  25. data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +3 -0
  26. data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +3 -0
  27. data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +3 -0
  28. data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +3 -0
  29. data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +3 -0
  30. data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +3 -0
  31. data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -0
  32. data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +3 -0
  33. data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +3 -0
  34. data/app/views/foreman_acd/app_definitions/_form.html.erb +25 -19
  35. data/app/views/foreman_acd/app_definitions/edit.html.erb +5 -0
  36. data/app/views/foreman_acd/app_definitions/import.html.erb +18 -0
  37. data/app/views/foreman_acd/app_definitions/index.html.erb +9 -5
  38. data/app/views/foreman_acd/app_instances/_form.html.erb +10 -8
  39. data/app/views/foreman_acd/app_instances/deploy.html.erb +19 -0
  40. data/app/views/foreman_acd/app_instances/index.html.erb +10 -5
  41. data/app/views/foreman_acd/app_instances/report.html.erb +19 -0
  42. data/app/views/templates/job/run_acd_ansible_playbook.erb +49 -0
  43. data/app/views/ui_acd/ansible_data.json.rabl +6 -0
  44. data/app/views/ui_acd/app.json.rabl +6 -2
  45. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  46. data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
  47. data/config/routes.rb +32 -1
  48. data/db/migrate/20190610202252_create_app_definitions.rb +1 -3
  49. data/db/migrate/20190625140305_create_app_instances.rb +1 -1
  50. data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
  51. data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
  52. data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +5 -0
  53. data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +5 -0
  54. data/db/seeds.d/75-job_templates.rb +8 -0
  55. data/lib/foreman_acd/engine.rb +3 -0
  56. data/lib/foreman_acd/plugin.rb +72 -4
  57. data/lib/foreman_acd/version.rb +1 -1
  58. data/package.json +1 -2
  59. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +376 -0
  60. data/webpack/components/ApplicationDefinition/ApplicationDefinition.scss +1 -0
  61. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +295 -0
  62. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +14 -0
  63. data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
  64. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +243 -0
  65. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +8 -0
  66. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +49 -0
  67. data/webpack/components/ApplicationDefinition/index.js +33 -0
  68. data/webpack/components/ApplicationInstance/ApplicationInstance.js +412 -0
  69. data/webpack/components/ApplicationInstance/ApplicationInstance.scss +11 -0
  70. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +239 -0
  71. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +14 -0
  72. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +295 -0
  73. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +9 -0
  74. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +49 -0
  75. data/webpack/components/ApplicationInstance/components/Service.js +30 -0
  76. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +37 -0
  77. data/webpack/components/ApplicationInstance/index.js +35 -0
  78. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +155 -0
  79. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +27 -0
  80. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +86 -0
  81. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +4 -0
  82. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +52 -0
  83. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +5 -0
  84. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +26 -0
  85. data/webpack/components/ApplicationInstanceReport/index.js +27 -0
  86. data/webpack/components/ParameterSelection/ParameterSelection.js +96 -183
  87. data/webpack/components/ParameterSelection/ParameterSelection.scss +9 -2
  88. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +72 -104
  89. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +14 -19
  90. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +3 -35
  91. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +100 -83
  92. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +3 -7
  93. data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +12 -21
  94. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +1 -1
  95. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +3 -45
  96. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +20 -0
  97. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +22 -46
  98. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
  99. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +40 -265
  100. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +11 -96
  101. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +3 -9
  102. data/webpack/components/ParameterSelection/index.js +6 -8
  103. data/webpack/components/common/AddTableEntry.js +30 -0
  104. data/webpack/components/common/DeleteTableEntry.js +39 -0
  105. data/webpack/components/common/EasyHeaderFormatter.js +18 -0
  106. data/webpack/components/common/ExtSelect.js +43 -0
  107. data/webpack/components/common/RailsData.js +27 -0
  108. data/webpack/components/common/__tests__/AddTableEntry.test.js +26 -0
  109. data/webpack/components/common/__tests__/DeleteTableEntry.test.js +29 -0
  110. data/webpack/components/common/__tests__/ExtSelect.test.js +38 -0
  111. data/webpack/components/common/__tests__/RailsData.test.js +16 -0
  112. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +35 -0
  113. data/webpack/components/common/__tests__/__snapshots__/AddTableEntry.test.js.snap +35 -0
  114. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +41 -0
  115. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +41 -0
  116. data/webpack/components/common/__tests__/__snapshots__/ExtSelect.test.js.snap +18 -0
  117. data/webpack/components/common/__tests__/__snapshots__/RailsData.test.js.snap +10 -0
  118. data/webpack/helper.js +20 -0
  119. data/webpack/index.js +6 -0
  120. data/webpack/reducer.js +43 -3
  121. metadata +87 -39
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanAcd
4
+ # inventory creator for application instances
5
+ class InventoryCreator
6
+
7
+ delegate :logger, :to => :Rails
8
+
9
+ def initialize(app_instance, host_ids)
10
+ @app_instance = app_instance
11
+ @host_ids = host_ids
12
+ end
13
+
14
+ # TODO: this might be part of the smart proxy plugin.
15
+ def create_inventory
16
+ inventory = {}
17
+ inventory['all'] = {}
18
+
19
+ inventory['all'] = { 'vars' => inventory_all_vars } unless @app_instance.ansible_vars_all.nil? || @app_instance.ansible_vars_all.empty?
20
+
21
+ services = JSON.parse(@app_instance.app_definition.services)
22
+ app_hosts = filtered_hosts
23
+
24
+ children = {}
25
+ app_hosts.each do |host_data|
26
+ if host_data['foreman_host_id'].nil?
27
+ logger.warn "Ignore host #{host_data['hostname']} because no foreman host id could be found. Is the host not provisioned yet?"
28
+ next
29
+ end
30
+
31
+ service_id = host_data['service'].to_i
32
+ host_service = services.select { |s| s['id'] == service_id }.first
33
+ ansible_group = host_service['ansibleGroup']
34
+
35
+ unless children.has_key?(host_service['ansibleGroup'])
36
+ children[ansible_group] = { 'hosts' => {} }
37
+ end
38
+
39
+ ansible_vars = host_data['ansibleParameters'].map { |v| { v['name'] => v['value'] } }.reduce({}, :merge!)
40
+
41
+ # in case there is no ansible_user defined, set "root" as default.
42
+ unless ansible_vars.has_key?('ansible_user')
43
+ ansible_vars['ansible_user'] = 'root'
44
+ end
45
+
46
+ children[ansible_group]['hosts'][get_fqdn(host_data['foreman_host_id'])] = ansible_vars
47
+ end
48
+ inventory['all']['children'] = children
49
+ inventory
50
+ end
51
+
52
+ private
53
+ def inventory_all_vars
54
+ JSON.parse(@app_instance.ansible_vars_all).map do |a|
55
+ { a['name'] => a['value'] }
56
+ end.reduce({}, :merge!)
57
+ end
58
+
59
+ def get_fqdn(host_id)
60
+ Host.find(host_id)&.name
61
+ end
62
+
63
+ def filtered_hosts
64
+ JSON.parse(@app_instance.hosts).select{ |h| h&.key?('foreman_host_id') && @host_ids.include?(h['foreman_host_id']) }
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,21 @@
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
+ </ul>
7
+
8
+ <div class="tab-content">
9
+ <div class="tab-pane active" id="primary">
10
+ <%= text_f f, :name %>
11
+ <%= text_f f, :description %>
12
+ <%= f.hidden_field :scm_type, :value => 'directory' %>
13
+ <% # TODO:
14
+ # select_f(f, :scm_type, %w[Directory GIT], :downcase, :to_s)
15
+ %>
16
+ <%= text_f f, :path %>
17
+ <%= text_f f, :playfile %>
18
+ </div>
19
+
20
+ <%= submit_or_cancel f %>
21
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <% title(_('Edit Ansible Playbook %s') % @ansible_playbook) %>
2
+
3
+ <%= 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).merge(:auth_object => ansible_playbook, :authorizer => authorizer) %></td>
16
+ <td><%= ansible_playbook.description %></td>
17
+ <td>
18
+ <%= action_buttons(
19
+ display_link_if_authorized(_("Import group variables"), hash_for_import_vars_ansible_playbook_path(:id => ansible_playbook).merge(:auth_object => ansible_playbook, :authorizer => authorizer)),
20
+ display_delete_if_authorized(hash_for_ansible_playbook_path(:id => ansible_playbook).merge(:auth_object => ansible_playbook, :authorizer => authorizer),
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
+
@@ -0,0 +1,3 @@
1
+ <% title _('New Ansible Playbook') %>
2
+
3
+ <%= render :partial => 'form' %>
@@ -0,0 +1,3 @@
1
+ object @ansible_playbook
2
+
3
+ attributes :id, :name
@@ -0,0 +1,3 @@
1
+ collection @ansible_playbooks
2
+
3
+ extends 'foreman_acd/api/v2/ansible_playbooks/base'
@@ -0,0 +1,3 @@
1
+ object @ansible_playbook
2
+
3
+ extends 'foreman_acd/api/v2/ansible_playbooks/base'
@@ -0,0 +1,3 @@
1
+ object @app_definition
2
+
3
+ attributes :id, :name
@@ -0,0 +1,3 @@
1
+ collection @app_definitions
2
+
3
+ extends 'foreman_acd/api/v2/app_definitions/base'
@@ -0,0 +1,3 @@
1
+ object @app_definition
2
+
3
+ extends 'foreman_acd/api/v2/app_definitions/base'
@@ -0,0 +1,3 @@
1
+ object @app_instance
2
+
3
+ attributes :id, :name
@@ -0,0 +1,3 @@
1
+ collection @app_instances
2
+
3
+ extends 'foreman_acd/api/v2/app_instances/base'
@@ -0,0 +1,3 @@
1
+ object @app_instance
2
+
3
+ extends 'foreman_acd/api/v2/app_instances/base'
@@ -1,23 +1,29 @@
1
1
  <%
2
- json = {
3
- "organization": current_organization,
4
- "location": current_location,
5
- "hostgroups": @hostgroups,
6
- "loadForemanDataUrl": ui_acd_fdata_path("__id__")
7
- }
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
+ }
8
11
 
9
- if @app_definition.name.empty?
10
- json["mode"] = "newDefinition"
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
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
20
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| %>
@@ -31,8 +37,8 @@
31
37
  <%= text_f f, :name %>
32
38
  <%= text_f f, :description %>
33
39
 
34
- <div id='param-selection'></div>
35
- <%= mount_react_component('ParameterSelection', "#param-selection", json.to_json) %>
40
+ <div id='app_definition'></div>
41
+ <%= mount_react_component('ApplicationDefinition', "#app_definition", json.to_json) %>
36
42
  </div>
37
43
  </div>
38
44
 
@@ -1,5 +1,10 @@
1
1
  <% title(_('Edit Application Definition %s') % @app_definition) %>
2
2
 
3
+ <%= breadcrumbs(
4
+ :resource_url => acd_api_v2_app_definitions_path
5
+ )
6
+ %>
7
+
3
8
  <% content_for(:javascripts) do %>
4
9
  <%= webpacked_plugins_js_for :foreman_acd %>
5
10
  <% end %>
@@ -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(new_link(_('New Application Definition'))) %>
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')
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
16
  <td><%=link_to_if_authorized h(app_definition.name), hash_for_edit_app_definition_path(:id => app_definition).merge(:auth_object => app_definition, :authorizer => authorizer) %></td>
15
17
  <td><%= app_definition.description %></td>
16
- <td><%= app_definition.hostgroup %></td>
17
18
  <td>
18
- <%= action_buttons(display_delete_if_authorized(hash_for_app_definition_path(:id => app_definition).merge(:auth_object => app_definition, :authorizer => authorizer),
19
- :data => { 'confirm': _('Delete %s?') % app_definition.name })) %>
19
+ <%= action_buttons(
20
+ display_delete_if_authorized(hash_for_app_definition_path(:id => app_definition).merge(:auth_object => app_definition, :authorizer => authorizer),
21
+ :data => { 'confirm': _('Delete %s?') % app_definition.name }),
22
+ display_link_if_authorized(_("Export"), hash_for_export_app_definition_path(:id => app_definition).merge(:auth_object => app_definition, :authorizer => authorizer))
23
+ ) %>
20
24
  </td>
21
25
  </tr>
22
26
  <% end %>
@@ -1,25 +1,27 @@
1
1
  <%
2
- if @app_instance.app_definition_id.blank?
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
- "loadParameterSelectionUrl": ui_acd_app_path("__id__"),
9
- "loadForemanDataUrl": ui_acd_fdata_path("__id__"),
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
- "loadForemanDataUrl": ui_acd_fdata_path("__id__"),
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
- "parameters": JSON.parse(@app_instance.parameters),
23
+ "hosts": JSON.parse(@app_instance.hosts),
24
+ "ansibleVarsAll": @app_instance.ansible_vars_all.blank? ? [] : JSON.parse(@app_instance.ansible_vars_all),
23
25
  }
24
26
  end
25
27
  %>
@@ -35,8 +37,8 @@
35
37
  <%= text_f f, :name %>
36
38
  <%= text_f f, :description %>
37
39
 
38
- <div id='param-selection'></div>
39
- <%= mount_react_component('ParameterSelection', "#param-selection", json.to_json) %>
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>
@@ -0,0 +1,19 @@
1
+ <% title _("Deploy Application Instance #{@app_instance}") %>
2
+
3
+ <% content_for(:javascripts) do %>
4
+ <%= webpacked_plugins_js_for :foreman_acd %>
5
+ <% end %>
6
+ <% content_for(:stylesheets) do %>
7
+ <%= webpacked_plugins_css_for :foreman_acd %>
8
+ <% end %>
9
+
10
+ <%
11
+ json = {
12
+ "mode": 'liveReport',
13
+ "hosts": @deploy_hosts
14
+ }
15
+ %>
16
+
17
+ <div id='deploy'></div>
18
+ <%= mount_react_component('ApplicationInstanceReport', "#deploy", json.to_json) %>
19
+ </div
@@ -15,11 +15,16 @@
15
15
  <td><%= app_instance.app_definition %></td>
16
16
  <td><%= app_instance.description %></td>
17
17
  <td>
18
- <%= action_buttons(display_delete_if_authorized(hash_for_app_instance_path(:id => app_instance).merge(:auth_object => app_instance, :authorizer => authorizer),
19
- :data => { 'confirm': _('Delete %s?') % app_instance.name }),
20
- display_link_if_authorized(_("Deploy"), hash_for_deploy_app_instance_path(:id => app_instance), :method => :post,
21
- :title => _("Deploy the application #{app_instance}"))
22
- ) %>
18
+ <%= action_buttons(display_link_if_authorized(_("Deploy"), hash_for_deploy_app_instance_path(:id => app_instance), :method => :post,
19
+ :title => _("Deploy application #{app_instance}")),
20
+ display_link_if_authorized(_("Run Playbook"), hash_for_remote_execution_path(:id => app_instance), :method => :post,
21
+ :title => _("Run ansible playbook for application #{app_instance}")),
22
+ display_link_if_authorized(_("Run Playbook - customize first"), hash_for_remote_execution_path(:id => app_instance, :customize => true), :method => :post,
23
+ :title => _("Prepare job to run ansible playbook for application #{app_instance}")),
24
+ display_link_if_authorized(_("Report"), hash_for_report_app_instance_path(:id => app_instance), :method => :get,
25
+ :title => _("Show last deployment report for application #{app_instance}")),
26
+ display_delete_if_authorized(hash_for_app_instance_path(:id => app_instance).merge(:auth_object => app_instance, :authorizer => authorizer),
27
+ :data => { 'confirm': _('Delete %s?') % app_instance.name })) %>
23
28
  </td>
24
29
  </tr>
25
30
  <% end %>
@@ -0,0 +1,19 @@
1
+ <% title _("Deployment Report for Application Instance #{@app_instance}") %>
2
+
3
+ <% content_for(:javascripts) do %>
4
+ <%= webpacked_plugins_js_for :foreman_acd %>
5
+ <% end %>
6
+ <% content_for(:stylesheets) do %>
7
+ <%= webpacked_plugins_css_for :foreman_acd %>
8
+ <% end %>
9
+
10
+ <%
11
+ json = {
12
+ "mode": 'lastReport',
13
+ "hosts": @report_hosts
14
+ }
15
+ %>
16
+
17
+ <div id='report'></div>
18
+ <%= mount_react_component('ApplicationInstanceReport', "#report", json.to_json) %>
19
+ </div
@@ -0,0 +1,49 @@
1
+ <%#
2
+ kind: job_template
3
+ name: Run ACD Ansible Playbook - SSH Default
4
+ model: JobTemplate
5
+ job_category: Application Centric Deployment
6
+ description_format: "Run Ansible playbook %{playbook_name} for ACD application %{application_name}"
7
+ provider_type: SSH
8
+ feature: run_acd_ansible_playbook
9
+ template_inputs:
10
+ - name: application_name
11
+ description: The name of the ACD application instance to run
12
+ input_type: user
13
+ required: true
14
+ advanced: false
15
+ - name: playbook_name
16
+ description: The name of the Ansible playbook to run
17
+ input_type: user
18
+ required: true
19
+ advanced: false
20
+ - name: playbook_path
21
+ description: The full path to the Ansible playbook
22
+ input_type: user
23
+ required: true
24
+ advanced: false
25
+ - name: inventory
26
+ description: The Ansible inventory
27
+ input_type: user
28
+ required: true
29
+ advanced: false
30
+ - name: extra_vars
31
+ description: Set ansible-playbook extra vars
32
+ input_type: user
33
+ required: false
34
+ advanced: true
35
+ - name: verbose
36
+ description: Whether to run the ansible-playbook in verbose mode or not.
37
+ input_type: user
38
+ options: "false\ntrue"
39
+ required: false
40
+ advanced: true
41
+ %>
42
+
43
+ INVENTORY_FILE=$(mktemp --suffix ".yaml")
44
+ cat << EOF >$INVENTORY_FILE
45
+ <%= input('inventory') %>
46
+ EOF
47
+
48
+ echo "Run ansible-playbook <%= input('playbook_name') %> to configure ACD app <%= input('application_name') %>"
49
+ ansible-playbook -i $INVENTORY_FILE <%= "-v" if input('verbose').present? && input('verbose') == 'true' %> <%= "--extra-vars \"#{input('extra_vars')}\"" unless input('extra_vars').blank? %> <%= input('playbook_path') %>