foreman_acd 0.2.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +107 -56
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +199 -0
  4. data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +72 -0
  5. data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -0
  6. data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +62 -0
  7. data/app/controllers/foreman_acd/app_definitions_controller.rb +19 -10
  8. data/app/controllers/foreman_acd/app_instances_controller.rb +111 -137
  9. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +23 -0
  10. data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
  11. data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
  12. data/app/controllers/foreman_acd/remote_execution_controller.rb +62 -0
  13. data/app/controllers/ui_acd_controller.rb +20 -3
  14. data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +47 -0
  15. data/app/lib/actions/foreman_acd/run_configurator.rb +44 -0
  16. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +51 -0
  17. data/app/models/foreman_acd/acd_provider.rb +36 -0
  18. data/app/models/foreman_acd/ansible_playbook.rb +68 -0
  19. data/app/models/foreman_acd/app_definition.rb +25 -0
  20. data/app/models/foreman_acd/app_instance.rb +42 -0
  21. data/app/models/foreman_acd/foreman_host.rb +23 -0
  22. data/app/models/foreman_acd/taxonomy_extensions.rb +17 -0
  23. data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
  24. data/app/services/foreman_acd/app_configurator.rb +98 -0
  25. data/app/services/foreman_acd/app_deployer.rb +157 -0
  26. data/app/services/foreman_acd/inventory_creator.rb +68 -0
  27. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +64 -0
  28. data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +11 -0
  29. data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
  30. data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
  31. data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +5 -0
  32. data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +5 -0
  33. data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +9 -0
  34. data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +5 -0
  35. data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +5 -0
  36. data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +9 -0
  37. data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +5 -0
  38. data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +5 -0
  39. data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +5 -0
  40. data/app/views/foreman_acd/app_definitions/_form.html.erb +34 -12
  41. data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -0
  42. data/app/views/foreman_acd/app_definitions/index.html.erb +4 -4
  43. data/app/views/foreman_acd/app_instances/_form.html.erb +11 -9
  44. data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
  45. data/app/views/foreman_acd/app_instances/index.html.erb +89 -10
  46. data/app/views/foreman_acd/app_instances/report.html.erb +6 -3
  47. data/app/views/templates/job/run_acd_ansible_playbook.erb +62 -0
  48. data/app/views/ui_acd/ansible_data.json.rabl +6 -0
  49. data/app/views/ui_acd/app.json.rabl +6 -2
  50. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  51. data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
  52. data/config/routes.rb +32 -2
  53. data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
  54. data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
  55. data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +8 -0
  56. data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +8 -0
  57. data/db/migrate/20210112111548_add_organization_to_app_instance.rb +22 -0
  58. data/db/migrate/20210112113853_add_location_to_app_instance.rb +8 -0
  59. data/db/migrate/20210202141658_create_foreman_hosts.rb +24 -0
  60. data/db/migrate/20210204111306_remove_hosts_from_app_instances.rb +8 -0
  61. data/db/migrate/20210209091014_rename_acd_tables.rb +16 -0
  62. data/db/migrate/20210216083522_add_last_progress_report.rb +8 -0
  63. data/db/migrate/20210216091529_add_last_deploy_task.rb +8 -0
  64. data/db/migrate/20210316151145_add_git_commit_to_ansible_playbooks.rb +8 -0
  65. data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +8 -0
  66. data/db/seeds.d/62_acd_proxy_feature.rb +4 -0
  67. data/db/seeds.d/75-job_templates.rb +13 -0
  68. data/lib/foreman_acd.rb +12 -0
  69. data/lib/foreman_acd/engine.rb +43 -3
  70. data/lib/foreman_acd/plugin.rb +88 -22
  71. data/lib/foreman_acd/version.rb +1 -1
  72. data/lib/tasks/foreman_acd_tasks.rake +0 -12
  73. data/locale/en/foreman_acd.edit.po +326 -0
  74. data/locale/en/foreman_acd.po +232 -2
  75. data/locale/en/foreman_acd.po.time_stamp +0 -0
  76. data/locale/foreman_acd.pot +343 -8
  77. data/package.json +9 -9
  78. data/test/controllers/ansible_playbooks_controller_test.rb +27 -0
  79. data/test/controllers/app_instances_controller_test.rb +8 -3
  80. data/test/controllers/ui_acd_controller_test.rb +22 -6
  81. data/test/factories/foreman_acd_factories.rb +18 -4
  82. data/test/models/acd_provider_test.rb +37 -0
  83. data/test/models/ansible_playbook_test.rb +11 -0
  84. data/test/models/app_definition_test.rb +1 -1
  85. data/test/models/app_instance_test.rb +2 -0
  86. data/test/models/concerns/host_extensions_test.rb +26 -0
  87. data/test/models/foreman_host_test.rb +12 -0
  88. data/webpack/__mocks__/foremanReact/API.js +2 -0
  89. data/webpack/__mocks__/foremanReact/common/I18n.js +3 -0
  90. data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
  91. data/webpack/__mocks__/foremanReact/components/ForemanModal.js +7 -0
  92. data/webpack/__mocks__/foremanReact/components/common/forms/CommonForm.js +2 -0
  93. data/webpack/__mocks__/foremanReact/components/common/forms/TextInput.js +2 -0
  94. data/webpack/__mocks__/foremanReact/components/hosts/powerStatus.js +1 -0
  95. data/webpack/__snapshots__/helper.test.js.snap +14 -0
  96. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +159 -29
  97. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +106 -14
  98. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +8 -2
  99. data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
  100. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +143 -21
  101. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +3 -0
  102. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionConfData_1.fixtures.js +288 -0
  103. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +79 -0
  104. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +25 -0
  105. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +119 -0
  106. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +41 -0
  107. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +200 -0
  108. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +3033 -0
  109. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +299 -0
  110. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +50 -0
  111. data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +41 -0
  112. data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +121 -0
  113. data/webpack/components/ApplicationDefinition/index.js +6 -0
  114. data/webpack/components/ApplicationInstance/ApplicationInstance.js +151 -44
  115. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +47 -10
  116. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +5 -2
  117. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +114 -28
  118. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +3 -1
  119. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
  120. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +78 -0
  121. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +23 -0
  122. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +119 -0
  123. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +44 -0
  124. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +209 -0
  125. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2719 -0
  126. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +276 -0
  127. data/webpack/components/ApplicationInstance/components/Service.js +1 -1
  128. data/webpack/components/ApplicationInstance/index.js +4 -0
  129. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +53 -60
  130. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +17 -0
  131. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +7 -51
  132. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +2 -4
  133. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +4 -18
  134. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +0 -1
  135. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportData_1.fixtures.js +349 -0
  136. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +20 -0
  137. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +47 -0
  138. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportReducer.test.js +41 -0
  139. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +26 -0
  140. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +130 -0
  141. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +718 -0
  142. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +347 -0
  143. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +1 -1
  144. data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +24 -0
  145. data/webpack/components/ApplicationInstanceReport/components/__tests__/__snapshots__/ReportViewer.test.js.snap +24 -0
  146. data/webpack/components/ApplicationInstanceReport/index.js +0 -2
  147. data/webpack/components/ParameterSelection/ParameterSelection.js +85 -50
  148. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +68 -62
  149. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +6 -3
  150. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +0 -32
  151. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +47 -35
  152. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -2
  153. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +116 -84
  154. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +10 -4
  155. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +36 -46
  156. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +31 -25
  157. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
  158. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +2 -126
  159. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1483 -872
  160. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +117 -79
  161. data/webpack/components/ParameterSelection/index.js +4 -4
  162. data/webpack/components/SyncGitRepo/SyncGitRepo.js +210 -0
  163. data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
  164. data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +124 -0
  165. data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +9 -0
  166. data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +80 -0
  167. data/webpack/components/SyncGitRepo/SyncGitRepoSelectors.js +6 -0
  168. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +7 -0
  169. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +44 -0
  170. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +27 -0
  171. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoReducer.test.js +95 -0
  172. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +32 -0
  173. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +30 -0
  174. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoReducer.test.js.snap +137 -0
  175. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +13 -0
  176. data/webpack/components/SyncGitRepo/components/FormTextInput.js +42 -0
  177. data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +46 -0
  178. data/webpack/components/SyncGitRepo/index.js +28 -0
  179. data/webpack/components/common/DeleteTableEntry.js +3 -3
  180. data/webpack/components/common/EditTableEntry.js +50 -0
  181. data/webpack/components/common/ExtTextInput.js +43 -0
  182. data/webpack/components/common/LockTableEntry.js +60 -0
  183. data/webpack/components/common/__tests__/EditTableEntry.test.js +53 -0
  184. data/webpack/components/common/__tests__/LockTableEntry.test.js +35 -0
  185. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +2 -2
  186. data/webpack/components/common/__tests__/__snapshots__/EditTableEntry.test.js.snap +81 -0
  187. data/webpack/components/common/__tests__/__snapshots__/LockTableEntry.test.js.snap +60 -0
  188. data/webpack/helper.js +15 -1
  189. data/webpack/helper.test.js +37 -0
  190. data/webpack/index.js +2 -0
  191. data/webpack/reducer.js +18 -11
  192. metadata +184 -10
  193. data/app/views/foreman_acd/app_instances/deploy.html.erb +0 -19
  194. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
  195. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -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
+
@@ -0,0 +1,3 @@
1
+ <% title _('New Ansible Playbook') %>
2
+
3
+ <%= render :partial => 'form' %>
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ object @ansible_playbook
4
+
5
+ attributes :id, :name
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ collection @ansible_playbooks
4
+
5
+ extends 'foreman_acd/api/v2/ansible_playbooks/base'
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ object @ansible_playbook
4
+
5
+ extends 'foreman_acd/api/v2/ansible_playbooks/base'
6
+
7
+ node do |ansible_playbook|
8
+ partial('api/v2/taxonomies/children_nodes', :object => ansible_playbook)
9
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ object @app_definition
4
+
5
+ attributes :id, :name
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ collection @app_definitions
4
+
5
+ extends 'foreman_acd/api/v2/app_definitions/base'
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ object @app_definition
4
+
5
+ extends 'foreman_acd/api/v2/app_definitions/base'
6
+
7
+ node do |app_definition|
8
+ partial('api/v2/taxonomies/children_nodes', :object => app_definition)
9
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ object @app_instance
4
+
5
+ attributes :id, :name, :organization_id, :organization_name, :location_id, :location_name
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ collection @app_instances
4
+
5
+ extends 'foreman_acd/api/v2/app_instances/base'
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ object @app_instance
4
+
5
+ extends 'foreman_acd/api/v2/app_instances/base'
@@ -1,21 +1,41 @@
1
1
  <%
2
- json = {
3
- "organization": current_organization,
4
- "location": current_location,
5
- "hostgroups": @hostgroups,
6
- "loadForemanDataUrl": ui_acd_fdata_path("__id__"),
7
- "services": [],
8
- }
9
-
10
- if !@app_definition.name.empty?
11
- json["services"] = JSON.parse(@app_definition.services)
12
- 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
+ }
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
13
27
  %>
14
28
 
15
29
  <%= form_for @app_definition, :url => (@app_definition.new_record? ? app_definitions_path : app_definition_path(:id => @app_definition.id)) do |f| %>
16
30
  <%= base_errors_for @app_definition %>
17
31
  <ul class="nav nav-tabs" data-tabs="tabs">
18
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 %>
19
39
  </ul>
20
40
 
21
41
  <div class="tab-content">
@@ -24,8 +44,10 @@
24
44
  <%= text_f f, :description %>
25
45
 
26
46
  <div id='app_definition'></div>
27
- <%= mount_react_component('ApplicationDefinition', "#app_definition", json.to_json) %>
47
+ <%= react_component('ApplicationDefinition', :data => json) %>
28
48
  </div>
49
+
50
+ <%= render 'taxonomies/loc_org_tabs', :f => f, :obj => @app_definition %>
29
51
  </div>
30
52
 
31
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 %>
@@ -2,7 +2,7 @@
2
2
 
3
3
  <% title_actions button_group(
4
4
  new_link(_('New Application Definition')),
5
- display_link_if_authorized(_("Import"), hash_for_import_app_definitions_path, :class => 'btn btn-default')
5
+ display_link_if_authorized(_("Import"), hash_for_import_app_definitions_path, :class => 'btn btn-default', :style => "display: none;")
6
6
  ) %>
7
7
 
8
8
  <table class="table table-bordered table-striped">
@@ -13,13 +13,13 @@
13
13
  </tr>
14
14
  <% for app_definition in @app_definitions %>
15
15
  <tr>
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>
16
+ <td><%=link_to_if_authorized h(app_definition.name), hash_for_edit_app_definition_path(:id => app_definition) %></td>
17
17
  <td><%= app_definition.description %></td>
18
18
  <td>
19
19
  <%= action_buttons(
20
- display_delete_if_authorized(hash_for_app_definition_path(:id => app_definition).merge(:auth_object => app_definition, :authorizer => authorizer),
20
+ display_delete_if_authorized(hash_for_app_definition_path(:id => app_definition),
21
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))
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
23
  ) %>
24
24
  </td>
25
25
  </tr>
@@ -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
- "loadAppDefinitionUrl": 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
- "loadAppDefinitionUrl": ui_acd_app_path("__id__"),
17
- "loadForemanDataUrl": ui_acd_fdata_path("__id__"),
17
+ "appDefinitionUrl": ui_acd_app_path("__id__"),
18
+ "foremanDataUrl": ui_acd_foreman_data_path("__id__"),
18
19
  "appDefinition": {
19
20
  "id": @app_instance.app_definition.id,
20
21
  "name": @app_instance.app_definition.name,
21
22
  },
22
- "hosts": JSON.parse(@app_instance.hosts),
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
  %>
@@ -36,11 +38,11 @@
36
38
  <%= text_f f, :description %>
37
39
 
38
40
  <div id='app_instance'></div>
39
- <%= mount_react_component('ApplicationInstance', "#app_instance", json.to_json) %>
41
+ <%= react_component('ApplicationInstance', :data => 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,25 +7,104 @@
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).merge(:auth_object => app_instance, :authorizer => authorizer) %></td>
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
- <%= 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(_("Report"), hash_for_report_app_instance_path(:id => app_instance), :method => :get,
21
- :title => _("Show last deployment report for application #{app_instance}")),
22
- display_delete_if_authorized(hash_for_app_instance_path(:id => app_instance).merge(:auth_object => app_instance, :authorizer => authorizer),
23
- :data => { 'confirm': _('Delete %s?') % app_instance.name })) %>
24
- </td>
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>
25
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">&times;</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">&times;</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
+ <% if app_instance.foreman_hosts.where.not(:host_id => [nil, false]).any? %>
93
+ <ul>
94
+ <li><%= check_box_tag 'delete_hosts'-%><%= _('Delete all hosts before deploying ') %><%= app_instance%></li>
95
+ <li><%= check_box_tag 'safe_deploy' -%><%= _('Deploy only new and changed hosts for ') %><%= app_instance%></li>
96
+ </ul>
97
+ <% end %>
98
+ </div>
99
+ <div class="modal-footer">
100
+ <button type="button" class="btn btn-danger" data-dismiss="modal"><%= _('Cancel') %></button>
101
+ <%= submit_tag _("Submit"), name: nil, class: "btn btn-success" %>
102
+ <% end %>
103
+ </div>
104
+ </div><!-- /.modal-content -->
105
+ </div><!-- /.modal-dialog -->
106
+ </div><!-- /.modal -->
26
107
  <% end %>
27
108
  </table>
28
-
29
109
  <%= page_entries_info @app_instances %>
30
110
  <%= will_paginate @app_instances %>
31
-
@@ -1,4 +1,4 @@
1
- <% title _("Deployment Report for Application Instance #{@app_instance}") %>
1
+ <% title _("Provisioning details for application instance #{@app_instance}") %>
2
2
 
3
3
  <% content_for(:javascripts) do %>
4
4
  <%= webpacked_plugins_js_for :foreman_acd %>
@@ -10,10 +10,13 @@
10
10
  <%
11
11
  json = {
12
12
  "mode": 'lastReport',
13
- "hosts": @report_hosts
13
+ "appInstanceName": @app_instance.name,
14
+ "hosts": @report_hosts,
15
+ "deployTaskUrl": foreman_tasks_task_path(@app_instance.last_deploy_task),
16
+ "configureJobUrl": job_invocations_path(search: "description ~ \"ACD application #{@app_instance.name}\"")
14
17
  }
15
18
  %>
16
19
 
17
20
  <div id='report'></div>
18
- <%= mount_react_component('ApplicationInstanceReport', "#report", json.to_json) %>
21
+ <%= react_component('ApplicationInstanceReport', :data => json) %>
19
22
  </div
@@ -0,0 +1,62 @@
1
+ <%#
2
+ kind: job_template
3
+ name: Run ACD Ansible Playbook - ACD Default
4
+ model: JobTemplate
5
+ job_category: Application Centric Deployment
6
+ description_format: "Run Ansible playbook to configure ACD application %{application_name}"
7
+ feature: run_acd_ansible_playbook
8
+ provider_type: ACD
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_id
16
+ description: The id of the Ansible playbook to run
17
+ input_type: user
18
+ required: true
19
+ advanced: false
20
+ - name: playbook_file
21
+ description: The playbook file of 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: "0 - Normal\n1 - Verbose\n2 - More Verbose\n3 - Debug\n4 - Connection Debug"
39
+ default: "0 - Normal"
40
+ required: false
41
+ advanced: true
42
+ - name: tags
43
+ description: List of playbook tags to specify which tasks to execute.
44
+ input_type: user
45
+ required: false
46
+ advanced: true
47
+ - name: skip_tags
48
+ description: List of playbook tags to skip certain tasks.
49
+ input_type: user
50
+ required: false
51
+ advanced: true
52
+ %>
53
+
54
+ application_name: <%= input('application_name') %>
55
+ playbook_id: <%= input('playbook_id') %>
56
+ playbook_file: <%= input('playbook_file') %>
57
+ extra_vars: <%= input('extra_vars') %>
58
+ verbose: <%= input('verbose') %>
59
+ tags: <%= input('tags') %>
60
+ skip_tags: <%= input('skip_tags') %>
61
+ inventory: |
62
+ <%= indent(2) { input('inventory') } %>