foreman_acd 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +82 -86
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +13 -11
  4. data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +4 -3
  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 +9 -1
  7. data/app/controllers/foreman_acd/app_definitions_controller.rb +14 -9
  8. data/app/controllers/foreman_acd/app_instances_controller.rb +97 -25
  9. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +1 -1
  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 +3 -6
  13. data/app/controllers/ui_acd_controller.rb +9 -0
  14. data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +42 -0
  15. data/app/lib/actions/foreman_acd/run_configurator.rb +41 -0
  16. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +51 -0
  17. data/app/models/foreman_acd/acd_provider.rb +3 -0
  18. data/app/models/foreman_acd/ansible_playbook.rb +30 -13
  19. data/app/models/foreman_acd/app_definition.rb +24 -1
  20. data/app/models/foreman_acd/app_instance.rb +40 -5
  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/app_configurator.rb +7 -10
  24. data/app/services/foreman_acd/app_deployer.rb +59 -47
  25. data/app/services/foreman_acd/inventory_creator.rb +12 -25
  26. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +11 -2
  27. data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +9 -1
  28. data/app/views/foreman_acd/ansible_playbooks/index.html.erb +3 -3
  29. data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +2 -0
  30. data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +2 -0
  31. data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +6 -0
  32. data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +2 -0
  33. data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +2 -0
  34. data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +6 -0
  35. data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -1
  36. data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +2 -0
  37. data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +2 -0
  38. data/app/views/foreman_acd/app_definitions/_form.html.erb +8 -0
  39. data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -5
  40. data/app/views/foreman_acd/app_definitions/index.html.erb +4 -4
  41. data/app/views/foreman_acd/app_instances/_form.html.erb +3 -3
  42. data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
  43. data/app/views/foreman_acd/app_instances/index.html.erb +87 -14
  44. data/app/views/foreman_acd/app_instances/report.html.erb +5 -2
  45. data/app/views/templates/job/run_acd_ansible_playbook.erb +14 -1
  46. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  47. data/config/routes.rb +1 -2
  48. data/db/migrate/20200917120220_add_ansible_playbook_id.rb +1 -1
  49. data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +3 -0
  50. data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +3 -0
  51. data/db/migrate/20210112111548_add_organization_to_app_instance.rb +22 -0
  52. data/db/migrate/20210112113853_add_location_to_app_instance.rb +8 -0
  53. data/db/migrate/20210202141658_create_foreman_hosts.rb +24 -0
  54. data/db/migrate/20210204111306_remove_hosts_from_app_instances.rb +8 -0
  55. data/db/migrate/20210209091014_rename_acd_tables.rb +16 -0
  56. data/db/migrate/20210216083522_add_last_progress_report.rb +8 -0
  57. data/db/migrate/20210216091529_add_last_deploy_task.rb +8 -0
  58. data/db/seeds.d/62_acd_proxy_feature.rb +1 -3
  59. data/db/seeds.d/75-job_templates.rb +6 -1
  60. data/lib/foreman_acd/engine.rb +14 -3
  61. data/lib/foreman_acd/plugin.rb +49 -28
  62. data/lib/foreman_acd/version.rb +1 -1
  63. data/locale/en/foreman_acd.edit.po +326 -0
  64. data/locale/en/foreman_acd.po +232 -2
  65. data/{app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb → locale/en/foreman_acd.po.time_stamp} +0 -0
  66. data/locale/foreman_acd.pot +343 -8
  67. data/test/controllers/ansible_playbooks_controller_test.rb +27 -0
  68. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +31 -18
  69. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +8 -0
  70. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +1 -0
  71. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +26 -0
  72. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +1 -0
  73. data/webpack/components/ApplicationDefinition/index.js +2 -0
  74. data/webpack/components/ApplicationInstance/ApplicationInstance.js +67 -30
  75. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +8 -0
  76. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +1 -0
  77. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +16 -2
  78. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +1 -0
  79. data/webpack/components/ApplicationInstance/components/Service.js +1 -1
  80. data/webpack/components/ApplicationInstance/index.js +2 -0
  81. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +53 -60
  82. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +17 -0
  83. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +7 -51
  84. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +2 -4
  85. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +4 -18
  86. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +0 -1
  87. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +1 -1
  88. data/webpack/components/ApplicationInstanceReport/index.js +0 -2
  89. data/webpack/components/ParameterSelection/ParameterSelection.js +10 -0
  90. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +8 -7
  91. data/webpack/components/common/DeleteTableEntry.js +3 -2
  92. data/webpack/components/common/EditTableEntry.js +2 -1
  93. data/webpack/components/common/LockTableEntry.js +2 -1
  94. metadata +48 -6
  95. data/app/views/foreman_acd/app_instances/deploy.html.erb +0 -19
@@ -7,29 +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).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(_("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 })) %>
28
- </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>
29
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
+ <!-- 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 -->
30
105
  <% end %>
31
106
  </table>
32
-
33
107
  <%= page_entries_info @app_instances %>
34
108
  <%= will_paginate @app_instances %>
35
-
@@ -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,7 +10,10 @@
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
 
@@ -35,7 +35,18 @@ template_inputs:
35
35
  - name: verbose
36
36
  description: Whether to run the ansible-playbook in verbose mode or not.
37
37
  input_type: user
38
- options: "false\ntrue"
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
39
50
  required: false
40
51
  advanced: true
41
52
  %>
@@ -45,5 +56,7 @@ playbook_id: <%= input('playbook_id') %>
45
56
  playbook_file: <%= input('playbook_file') %>
46
57
  extra_vars: <%= input('extra_vars') %>
47
58
  verbose: <%= input('verbose') %>
59
+ tags: <%= input('tags') %>
60
+ skip_tags: <%= input('skip_tags') %>
48
61
  inventory: |
49
62
  <%= indent(2) { input('inventory') } %>
@@ -2,4 +2,4 @@
2
2
 
3
3
  object @app_definition
4
4
 
5
- attributes :id, :name, :description, :services, :ansible_vars_all, :created_at, :updated_at
5
+ attributes :id, :name, :description, :services, :ansible_vars_all, :location_ids, :organization_ids, :created_at, :updated_at
data/config/routes.rb CHANGED
@@ -10,7 +10,6 @@ Rails.application.routes.draw do
10
10
  member do
11
11
  get 'import_vars'
12
12
  end
13
-
14
13
  end
15
14
  resources :app_definitions, :controller => 'foreman_acd/app_definitions' do
16
15
  collection do
@@ -21,7 +20,6 @@ Rails.application.routes.draw do
21
20
  member do
22
21
  get 'export'
23
22
  end
24
-
25
23
  end
26
24
 
27
25
  resources :app_instances, :controller => 'foreman_acd/app_instances' do
@@ -32,6 +30,7 @@ Rails.application.routes.draw do
32
30
  member do
33
31
  post 'deploy'
34
32
  get 'report'
33
+ delete 'destroy_with_hosts'
35
34
  end
36
35
  end
37
36
 
@@ -4,7 +4,7 @@
4
4
  class AddAnsiblePlaybookId < ActiveRecord::Migration[5.2]
5
5
  def up
6
6
  add_column :app_definitions, :acd_ansible_playbook_id, :integer
7
- add_foreign_key "app_definitions", "acd_ansible_playbooks", :name => "app_definitions_acd_ansible_playbooks_id_fk"
7
+ add_foreign_key 'app_definitions', 'acd_ansible_playbooks', :name => 'app_definitions_acd_ansible_playbooks_id_fk'
8
8
  end
9
9
 
10
10
  def down
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add ansible variables to app definitions
1
4
  class AddAnsibleVarsAllToAppDefinitions < ActiveRecord::Migration[5.2]
2
5
  def change
3
6
  add_column :app_definitions, :ansible_vars_all, :text
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add ansible variables to app instances
1
4
  class AddAnsibleVarsAllToAppInstances < ActiveRecord::Migration[5.2]
2
5
  def change
3
6
  add_column :app_instances, :ansible_vars_all, :text
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add organization to app instance
4
+ class AddOrganizationToAppInstance < ActiveRecord::Migration[6.0]
5
+ # FakeAppInstance, because of 'validates :location'
6
+ class AppInstance < ApplicationRecord
7
+ belongs_to :organization
8
+ end
9
+
10
+ def up
11
+ add_column :app_instances, :organization_id, :integer, :null => true, :index => true
12
+ AppInstance.all.each do |a|
13
+ a.organization = ::Organization.first
14
+ a.save!
15
+ end
16
+ change_column :app_instances, :organization_id, :integer, :null => false, :index => true
17
+ end
18
+
19
+ def down
20
+ remove_column :app_instances, :organization_id, :integer
21
+ end
22
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add location to app instance
4
+ class AddLocationToAppInstance < ActiveRecord::Migration[6.0]
5
+ def change
6
+ add_column :app_instances, :location_id, :integer, :null => true, :index => true
7
+ end
8
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Adding acd_foreman_hosts db table
4
+ class CreateForemanHosts < ActiveRecord::Migration[6.0]
5
+ def up
6
+ create_table :foreman_hosts do |t|
7
+ t.string :hostname, :default => '', :null => false, :limit => 255, :unique => true
8
+ t.column :app_instance_id, :integer, :null => false
9
+ t.column :host_id, :integer
10
+ t.string :service
11
+ t.string :description
12
+ t.text :foremanParameters
13
+ t.text :ansibleParameters
14
+
15
+ t.timestamps :null => false
16
+ end
17
+ add_foreign_key :foreman_hosts, :app_instances
18
+ add_foreign_key :foreman_hosts, :hosts
19
+ end
20
+
21
+ def down
22
+ drop_table :foreman_hosts
23
+ end
24
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Remove hosts column from app_instances db table
4
+ class RemoveHostsFromAppInstances < ActiveRecord::Migration[6.0]
5
+ def change
6
+ remove_column :app_instances, :hosts, :text
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Adding Rename ACD db tables
4
+ class RenameAcdTables < ActiveRecord::Migration[6.0]
5
+ def up
6
+ rename_table :app_definitions, :acd_app_definitions
7
+ rename_table :app_instances, :acd_app_instances
8
+ rename_table :foreman_hosts, :acd_foreman_hosts
9
+ end
10
+
11
+ def down
12
+ rename_table :acd_app_definitions
13
+ rename_table :acd_app_instances
14
+ rename_table :acd_foreman_hosts
15
+ end
16
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add AddLastProgressReport
4
+ class AddLastProgressReport < ActiveRecord::Migration[5.2]
5
+ def change
6
+ add_column :acd_foreman_hosts, :last_progress_report, :text
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add AddLastDeployTask
4
+ class AddLastDeployTask < ActiveRecord::Migration[5.2]
5
+ def change
6
+ add_column :acd_app_instances, :last_deploy_task_id, :uuid, :null => true
7
+ end
8
+ end
@@ -1,6 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  proxy_feature = Feature.where(:name => 'ACD').first_or_create
4
- if proxy_feature.nil? || proxy_feature.errors.any?
5
- raise "Unable to create proxy feature: #{format_errors proxy_feature}"
6
- end
4
+ raise "Unable to create proxy feature: #{format_errors proxy_feature}" if proxy_feature.nil? || proxy_feature.errors.any?
@@ -1,8 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  User.as_anonymous_admin do
2
4
  JobTemplate.without_auditing do
3
5
  Dir[File.join("#{ForemanAcd::Engine.root}/app/views/templates/**/*.erb")].each do |template|
4
6
  sync = !Rails.env.test? && Setting[:remote_execution_sync_templates]
5
- JobTemplate.import_raw!(File.read(template), :default => true, :locked => true, :update => sync)
7
+ template = JobTemplate.import_raw!(File.read(template), :default => true, :locked => true, :update => sync)
8
+
9
+ template.organizations << Organization.unscoped.all if template&.organizations&.empty?
10
+ template.locations << Location.unscoped.all if template&.locations&.empty?
6
11
  end
7
12
  end
8
13
  end
@@ -8,11 +8,10 @@ module ForemanAcd
8
8
  engine_name 'foreman_acd'
9
9
 
10
10
  config.autoload_paths += Dir["#{config.root}/app/controllers/foreman_acd/concerns"]
11
+ config.autoload_paths += Dir["#{config.root}/app/models"]
12
+ config.autoload_paths += Dir["#{config.root}/app/services"]
11
13
  config.autoload_paths += Dir["#{config.root}/app/helpers"]
12
- config.autoload_paths += Dir["#{config.root}/app/models/foreman_acd/concerns"]
13
- config.autoload_paths += Dir["#{config.root}/app/models/parameters"]
14
14
  config.autoload_paths += Dir["#{config.root}/app/overrides"]
15
- config.autoload_paths += Dir["#{config.root}/app/services"]
16
15
  config.autoload_paths += Dir["#{config.root}/app/lib"]
17
16
  config.autoload_paths += Dir["#{config.root}/lib"]
18
17
 
@@ -43,8 +42,20 @@ module ForemanAcd
43
42
  require 'foreman_acd/plugin'
44
43
  end
45
44
 
45
+ initializer 'foreman_acd.register_actions', :before => :finisher_hook do |_app|
46
+ ForemanTasks.dynflow.require!
47
+ action_paths = %W[#{ForemanAcd::Engine.root}/app/lib/actions]
48
+ ForemanTasks.dynflow.config.eager_load_paths.concat(action_paths)
49
+ end
50
+
46
51
  config.to_prepare do
47
52
  RemoteExecutionProvider.register(:ACD, AcdProvider)
53
+ ::Taxonomy.include ForemanAcd::TaxonomyExtensions
54
+ ::Host::Managed.prepend ForemanAcd::HostManagedExtensions
55
+ end
56
+
57
+ def self.with_katello?
58
+ defined?(::Katello)
48
59
  end
49
60
  end
50
61
  end
@@ -8,16 +8,16 @@ Foreman::Plugin.register :foreman_acd do
8
8
  # Menus
9
9
  sub_menu :top_menu, :application, :caption => N_('Applications'), :after => :hosts_menu, :icon => 'pficon pficon-integration' do
10
10
  menu :top_menu, :ansible_playbooks,
11
- :url_hash => { :controller => :'foreman_acd/ansible_playbooks', :action => :index },
12
- :caption => 'Ansible Playbooks'
11
+ :url_hash => { :controller => :'foreman_acd/ansible_playbooks', :action => :index },
12
+ :caption => 'Ansible Playbooks'
13
13
 
14
14
  menu :top_menu, :app_definitions,
15
- :url_hash => { :controller => :'foreman_acd/app_definitions', :action => :index },
16
- :caption => 'App Definitions'
15
+ :url_hash => { :controller => :'foreman_acd/app_definitions', :action => :index },
16
+ :caption => 'App Definitions'
17
17
 
18
18
  menu :top_menu, :app_instances,
19
- :url_hash => { :controller => :'foreman_acd/app_instances', :action => :index },
20
- :caption => 'App Instances'
19
+ :url_hash => { :controller => :'foreman_acd/app_instances', :action => :index },
20
+ :caption => 'App Instances'
21
21
  end
22
22
 
23
23
  # Add permissions
@@ -97,8 +97,8 @@ Foreman::Plugin.register :foreman_acd do
97
97
  :resource_type => 'ForemanAcd::AppInstance'
98
98
 
99
99
  permission :destroy_app_instances,
100
- { :'foreman_acd/app_instances' => [:destroy],
101
- :'foreman_acd/api/v2/app_instances' => [:destroy] },
100
+ { :'foreman_acd/app_instances' => [:destroy, :destroy_with_hosts],
101
+ :'foreman_acd/api/v2/app_instances' => [:destroy, :destroy_with_hosts] },
102
102
  :resource_type => 'ForemanAcd::AppInstance'
103
103
 
104
104
  permission :deploy_app_instances,
@@ -106,39 +106,60 @@ Foreman::Plugin.register :foreman_acd do
106
106
  :'foreman_acd/api/v2/app_instances' => [:deploy] },
107
107
  :resource_type => 'ForemanAcd::AppInstance'
108
108
 
109
- permission :configure_app_instances,
110
- { :'foreman_acd/app_instances' => [:configure],
111
- :'foreman_acd/api/v2/app_instances' => [:configure] },
112
- :resource_type => 'ForemanAcd::AppInstance'
113
-
114
109
  permission :report_app_instances,
115
110
  { :'foreman_acd/app_instances' => [:report],
116
111
  :'foreman_acd/api/v2/app_instances' => [:report] },
117
112
  :resource_type => 'ForemanAcd::AppInstance'
113
+
114
+ permission :new_remote_execution,
115
+ { :'foreman_acd/remote_execution' => [:new] },
116
+ :resource_type => 'ForemanAcd::RemoteExecution'
117
+
118
+ permission :create_remote_execution,
119
+ { :'foreman_acd/remote_execution' => [:create] },
120
+ :resource_type => 'ForemanAcd::RemoteExecution'
121
+
122
+ permission :view_ui_acd,
123
+ { :ui_acd => [:app, :foreman_data, :ansible_data] }
124
+
125
+ permission :acd_foreman_hosts,
126
+ { :'foreman_acd/app_instances' => [:create, :edit, :update, :deploy, :destroy_with_hosts, :destroy] },
127
+ :resource_type => 'ForemanAcd::ForemanHost'
118
128
  end
119
129
 
120
130
  # Manager Role
121
- role 'Application Centric Deployment Manager', [:create_ansible_playbooks,
122
- :view_ansible_playbooks,
123
- :edit_ansible_playbooks,
131
+ role 'Application Centric Deployment Manager', [:create_ansible_playbooks, :view_ansible_playbooks, :edit_ansible_playbooks,
124
132
  :destroy_ansible_playbooks,
125
- :import_vars_ansible_playbooks,
126
- :grab_ansible_playbooks,
127
- :create_app_definitions,
128
- :view_app_definitions,
129
- :edit_app_definitions,
133
+ :import_vars_ansible_playbooks, :grab_ansible_playbooks,
134
+ :create_app_definitions, :view_app_definitions, :edit_app_definitions,
130
135
  :destroy_app_definitions,
131
- :export_app_definitions,
132
- :import_app_definitions]
136
+ :export_app_definitions, :import_app_definitions,
137
+ :create_app_instances, :view_app_instances, :edit_app_instances,
138
+ :destroy_app_instances,
139
+ :deploy_app_instances,
140
+ :new_remote_execution, :create_remote_execution,
141
+ :report_app_instances,
142
+ :view_ui_acd,
143
+ :view_hosts, :build_hosts, :power_hosts, :create_hosts, :edit_hosts, :destroy_hosts, :console_hosts,
144
+ :view_job_invocations, :cancel_job_invocations, :create_job_invocations, :create_template_invocations,
145
+ :view_job_templates,
146
+ :view_foreman_tasks,
147
+ :acd_foreman_hosts, :view_smart_proxies]
133
148
 
134
149
  # User Role
135
- role 'Application Centric Deployment User', [:create_app_instances,
136
- :view_app_instances,
137
- :edit_app_instances,
150
+ role 'Application Centric Deployment User', [:create_app_instances, :view_app_instances, :edit_app_instances,
138
151
  :destroy_app_instances,
139
152
  :deploy_app_instances,
140
- :configure_app_instances,
141
- :report_app_instances]
153
+ :new_remote_execution, :create_remote_execution,
154
+ :report_app_instances,
155
+ :view_ui_acd,
156
+ :view_hosts, :build_hosts, :power_hosts, :create_hosts, :edit_hosts, :destroy_hosts, :console_hosts,
157
+ :view_job_invocations, :cancel_job_invocations, :create_job_invocations, :create_template_invocations,
158
+ :view_job_templates,
159
+ :view_foreman_tasks,
160
+ :acd_foreman_hosts, :view_smart_proxies]
161
+
162
+ add_all_permissions_to_default_roles
142
163
 
143
164
  RemoteExecutionFeature.register(
144
165
  :run_acd_ansible_playbook,