foreman_acd 0.0.5 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +82 -27
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +122 -0
  4. data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +71 -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/acd_provider.rb +27 -0
  16. data/app/models/foreman_acd/ansible_playbook.rb +50 -0
  17. data/app/models/foreman_acd/app_definition.rb +2 -1
  18. data/app/models/foreman_acd/app_instance.rb +7 -0
  19. data/app/services/foreman_acd/app_configurator.rb +57 -0
  20. data/app/services/foreman_acd/app_deployer.rb +139 -0
  21. data/app/services/foreman_acd/inventory_creator.rb +67 -0
  22. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +21 -0
  23. data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +3 -0
  24. data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
  25. data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
  26. data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +3 -0
  27. data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +3 -0
  28. data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +3 -0
  29. data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +3 -0
  30. data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +3 -0
  31. data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +3 -0
  32. data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -0
  33. data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +3 -0
  34. data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +3 -0
  35. data/app/views/foreman_acd/app_definitions/_form.html.erb +25 -19
  36. data/app/views/foreman_acd/app_definitions/edit.html.erb +5 -0
  37. data/app/views/foreman_acd/app_definitions/import.html.erb +18 -0
  38. data/app/views/foreman_acd/app_definitions/index.html.erb +9 -5
  39. data/app/views/foreman_acd/app_instances/_form.html.erb +10 -8
  40. data/app/views/foreman_acd/app_instances/deploy.html.erb +19 -0
  41. data/app/views/foreman_acd/app_instances/index.html.erb +10 -5
  42. data/app/views/foreman_acd/app_instances/report.html.erb +19 -0
  43. data/app/views/templates/job/run_acd_ansible_playbook.erb +49 -0
  44. data/app/views/ui_acd/ansible_data.json.rabl +6 -0
  45. data/app/views/ui_acd/app.json.rabl +6 -2
  46. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  47. data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
  48. data/config/routes.rb +36 -1
  49. data/db/migrate/20190610202252_create_app_definitions.rb +1 -3
  50. data/db/migrate/20190625140305_create_app_instances.rb +1 -1
  51. data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
  52. data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
  53. data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +5 -0
  54. data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +5 -0
  55. data/db/seeds.d/62_acd_proxy_feature.rb +6 -0
  56. data/db/seeds.d/75-job_templates.rb +8 -0
  57. data/lib/foreman_acd/engine.rb +7 -0
  58. data/lib/foreman_acd/plugin.rb +84 -13
  59. data/lib/foreman_acd/version.rb +1 -1
  60. data/package.json +1 -2
  61. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +378 -0
  62. data/webpack/components/ApplicationDefinition/ApplicationDefinition.scss +1 -0
  63. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +295 -0
  64. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +14 -0
  65. data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
  66. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +243 -0
  67. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +8 -0
  68. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +49 -0
  69. data/webpack/components/ApplicationDefinition/index.js +33 -0
  70. data/webpack/components/ApplicationInstance/ApplicationInstance.js +414 -0
  71. data/webpack/components/ApplicationInstance/ApplicationInstance.scss +11 -0
  72. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +239 -0
  73. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +14 -0
  74. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +295 -0
  75. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +9 -0
  76. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +49 -0
  77. data/webpack/components/ApplicationInstance/components/Service.js +30 -0
  78. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +37 -0
  79. data/webpack/components/ApplicationInstance/index.js +35 -0
  80. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +155 -0
  81. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +27 -0
  82. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +86 -0
  83. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +4 -0
  84. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +52 -0
  85. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +5 -0
  86. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +26 -0
  87. data/webpack/components/ApplicationInstanceReport/index.js +27 -0
  88. data/webpack/components/ParameterSelection/ParameterSelection.js +121 -192
  89. data/webpack/components/ParameterSelection/ParameterSelection.scss +9 -0
  90. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +80 -104
  91. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +15 -19
  92. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +3 -35
  93. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +116 -84
  94. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +3 -7
  95. data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +12 -21
  96. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +1 -1
  97. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +3 -45
  98. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +20 -0
  99. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +22 -46
  100. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
  101. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +40 -265
  102. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +11 -96
  103. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +3 -9
  104. data/webpack/components/ParameterSelection/index.js +6 -8
  105. data/webpack/components/common/AddTableEntry.js +30 -0
  106. data/webpack/components/common/DeleteTableEntry.js +38 -0
  107. data/webpack/components/common/EasyHeaderFormatter.js +18 -0
  108. data/webpack/components/common/EditTableEntry.js +49 -0
  109. data/webpack/components/common/ExtSelect.js +43 -0
  110. data/webpack/components/common/LockTableEntry.js +59 -0
  111. data/webpack/components/common/RailsData.js +27 -0
  112. data/webpack/components/common/__tests__/AddTableEntry.test.js +26 -0
  113. data/webpack/components/common/__tests__/DeleteTableEntry.test.js +29 -0
  114. data/webpack/components/common/__tests__/ExtSelect.test.js +38 -0
  115. data/webpack/components/common/__tests__/RailsData.test.js +16 -0
  116. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +35 -0
  117. data/webpack/components/common/__tests__/__snapshots__/AddTableEntry.test.js.snap +35 -0
  118. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +41 -0
  119. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +41 -0
  120. data/webpack/components/common/__tests__/__snapshots__/ExtSelect.test.js.snap +18 -0
  121. data/webpack/components/common/__tests__/__snapshots__/RailsData.test.js.snap +10 -0
  122. data/webpack/helper.js +20 -0
  123. data/webpack/index.js +6 -0
  124. data/webpack/reducer.js +43 -3
  125. metadata +91 -39
@@ -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 - ACD Default
4
+ model: JobTemplate
5
+ job_category: Application Centric Deployment
6
+ description_format: "Run Ansible playbook %{playbook_name} for 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: "false\ntrue"
39
+ required: false
40
+ advanced: true
41
+ %>
42
+
43
+ application_name: <%= input('application_name') %>
44
+ playbook_id: <%= input('playbook_id') %>
45
+ playbook_file: <%= input('playbook_file') %>
46
+ extra_vars: <%= input('extra_vars') %>
47
+ verbose: <%= input('verbose') %>
48
+ inventory: |
49
+ <%= indent(2) { input('inventory') } %>
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ object @ansible_data
4
+ attribute :id
5
+ attribute :name
6
+ attribute :groups
@@ -4,6 +4,10 @@ child @app_data['app_definition'] => :app_definition do
4
4
  extends 'ui_acd/app_definition'
5
5
  end
6
6
 
7
- child @app_data['fdata'] => :fdata do
8
- extends 'ui_acd/fdata'
7
+ child @app_data['foreman_data'] => :foreman_data do
8
+ extends 'ui_acd/foreman_data'
9
+ end
10
+
11
+ child @app_data['ansible_data'] => :ansible_data do
12
+ extends 'ui_acd/ansible_data'
9
13
  end
@@ -2,4 +2,4 @@
2
2
 
3
3
  object @app_definition
4
4
 
5
- attributes :id, :name, :description, :hostgroup_id, :parameters, :created_at, :updated_at
5
+ attributes :id, :name, :description, :services, :ansible_vars_all, :created_at, :updated_at
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- object @fdata
3
+ object @foreman_data
4
4
  attribute :hostgroup_id
5
5
 
6
6
  child :environments => :environments do
@@ -2,10 +2,26 @@
2
2
 
3
3
  Rails.application.routes.draw do
4
4
  scope :acd, :path => '/acd' do
5
+ resources :ansible_playbooks, :controller => 'foreman_acd/ansible_playbooks' do
6
+ collection do
7
+ get 'auto_complete_search'
8
+ end
9
+
10
+ member do
11
+ get 'import_vars'
12
+ end
13
+
14
+ end
5
15
  resources :app_definitions, :controller => 'foreman_acd/app_definitions' do
6
16
  collection do
7
17
  get 'auto_complete_search'
18
+ get 'import'
8
19
  end
20
+
21
+ member do
22
+ get 'export'
23
+ end
24
+
9
25
  end
10
26
 
11
27
  resources :app_instances, :controller => 'foreman_acd/app_instances' do
@@ -15,10 +31,29 @@ Rails.application.routes.draw do
15
31
 
16
32
  member do
17
33
  post 'deploy'
34
+ get 'report'
18
35
  end
19
36
  end
20
37
 
38
+ match '/remote_execution', :controller => 'foreman_acd/remote_execution', :action => 'create', :via => [:post]
39
+
21
40
  get 'ui_acd_app/:id', :to => 'ui_acd#app', :constraints => { :id => /[\w\.-]+/ }, :as => :ui_acd_app
22
- get 'ui_acd_fdata/:id', :to => 'ui_acd#fdata', :constraints => { :id => /[\w\.-]+/ }, :as => :ui_acd_fdata
41
+ get 'ui_acd_foreman_data/:id', :to => 'ui_acd#foreman_data', :constraints => { :id => /[\w\.-]+/ }, :as => :ui_acd_foreman_data
42
+ get 'ui_acd_ansible_data/:id', :to => 'ui_acd#ansible_data', :constraints => { :id => /[\w\.-]+/ }, :as => :ui_acd_ansible_data
43
+
44
+ scope :api, :path => '/api', :defaults => { :format => 'json' } do
45
+ scope '(:apiv)', :defaults => { :apiv => 'v2' },
46
+ :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2) do
47
+ constraints(:id => /[\w\.-]+/) do
48
+ resources :app_definitions, :only => [:show, :index], :controller => 'foreman_acd/api/v2/app_definitions', :as => :acd_api_v2_app_definitions
49
+ resources :app_instances, :only => [:show, :index], :controller => 'foreman_acd/api/v2/app_instances', :as => :api_v2_foreman_acd_app_instances
50
+ resources :ansible_playbooks, :only => [:show, :index], :controller => 'foreman_acd/api/v2/ansible_playbooks', :as => :api_v2_foreman_acd_ansible_playbooks do
51
+ member do
52
+ get 'grab'
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
23
58
  end
24
59
  end
@@ -6,11 +6,9 @@ class CreateAppDefinitions < ActiveRecord::Migration[5.2]
6
6
  create_table :app_definitions do |t|
7
7
  t.string :name, :default => '', :null => false, :limit => 255, :unique => true
8
8
  t.text :description
9
- t.column :hostgroup_id, :integer
10
- t.text :parameters
9
+ t.text :services
11
10
  t.timestamps :null => true
12
11
  end
13
- add_foreign_key :app_definitions, :hostgroups
14
12
  end
15
13
 
16
14
  def down
@@ -7,7 +7,7 @@ class CreateAppInstances < ActiveRecord::Migration[5.2]
7
7
  t.string :name, :default => '', :null => false, :limit => 255, :unique => true
8
8
  t.column :app_definition_id, :integer, :null => false
9
9
  t.text :description
10
- t.text :parameters
10
+ t.text :hosts
11
11
  t.timestamps :null => true
12
12
  end
13
13
  add_foreign_key :app_instances, :app_definitions
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Adding acd ansible playbooks db table
4
+ class CreateAnsiblePlaybooks < ActiveRecord::Migration[5.2]
5
+ def up
6
+ create_table :acd_ansible_playbooks do |t|
7
+ t.string :name, :default => '', :null => false, :limit => 255, :unique => true
8
+ t.text :description
9
+ t.string :scm_type
10
+ t.string :path
11
+ t.string :playfile
12
+ t.text :vars
13
+ t.timestamps :null => true
14
+ end
15
+ end
16
+
17
+ def down
18
+ drop_table :acd_ansible_playbooks
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Adding acd ansible playbooks db table
4
+ class AddAnsiblePlaybookId < ActiveRecord::Migration[5.2]
5
+ def up
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"
8
+ end
9
+
10
+ def down
11
+ remove_foreign_key 'app_definitions', :name => 'app_definitions_acd_ansible_playbooks_id_fk'
12
+ remove_column :app_definitions, :acd_ansible_playbook_id
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ class AddAnsibleVarsAllToAppDefinitions < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :app_definitions, :ansible_vars_all, :text
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddAnsibleVarsAllToAppInstances < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :app_instances, :ansible_vars_all, :text
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
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
@@ -0,0 +1,8 @@
1
+ User.as_anonymous_admin do
2
+ JobTemplate.without_auditing do
3
+ Dir[File.join("#{ForemanAcd::Engine.root}/app/views/templates/**/*.erb")].each do |template|
4
+ sync = !Rails.env.test? && Setting[:remote_execution_sync_templates]
5
+ JobTemplate.import_raw!(File.read(template), :default => true, :locked => true, :update => sync)
6
+ end
7
+ end
8
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'foreman_remote_execution'
4
+
3
5
  module ForemanAcd
4
6
  # This engine connects ForemanAcd with Foreman core
5
7
  class Engine < ::Rails::Engine
@@ -12,6 +14,7 @@ module ForemanAcd
12
14
  config.autoload_paths += Dir["#{config.root}/app/overrides"]
13
15
  config.autoload_paths += Dir["#{config.root}/app/services"]
14
16
  config.autoload_paths += Dir["#{config.root}/app/lib"]
17
+ config.autoload_paths += Dir["#{config.root}/lib"]
15
18
 
16
19
  # Add any db migrations
17
20
  initializer 'foreman_acd.load_app_instance_data' do |app|
@@ -39,5 +42,9 @@ module ForemanAcd
39
42
  initializer 'foreman_acd.register_plugin', :before => :finisher_hook do
40
43
  require 'foreman_acd/plugin'
41
44
  end
45
+
46
+ config.to_prepare do
47
+ RemoteExecutionProvider.register(:ACD, AcdProvider)
48
+ end
42
49
  end
43
50
  end
@@ -1,24 +1,56 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Foreman::Plugin.register :foreman_acd do
4
- requires_foreman '>= 1.19'
4
+ requires_foreman '>= 2.1'
5
5
 
6
6
  apipie_documented_controllers ["#{ForemanAcd::Engine.root}/app/controllers/foreman_acd/api/v2/*.rb"]
7
7
 
8
8
  # Menus
9
- divider :top_menu, :parent => :configure_menu, :caption => 'Applications'
10
- menu :top_menu, :app_definitions,
11
- :url_hash => { :controller => :'foreman_acd/app_definitions', :action => :index },
12
- :caption => 'App Definitions',
13
- :parent => :configure_menu
9
+ sub_menu :top_menu, :application, :caption => N_('Applications'), :after => :hosts_menu, :icon => 'pficon pficon-integration' do
10
+ menu :top_menu, :ansible_playbooks,
11
+ :url_hash => { :controller => :'foreman_acd/ansible_playbooks', :action => :index },
12
+ :caption => 'Ansible Playbooks'
14
13
 
15
- menu :top_menu, :app_instances,
16
- :url_hash => { :controller => :'foreman_acd/app_instances', :action => :index },
17
- :caption => 'App Instances',
18
- :parent => :configure_menu
14
+ menu :top_menu, :app_definitions,
15
+ :url_hash => { :controller => :'foreman_acd/app_definitions', :action => :index },
16
+ :caption => 'App Definitions'
17
+
18
+ menu :top_menu, :app_instances,
19
+ :url_hash => { :controller => :'foreman_acd/app_instances', :action => :index },
20
+ :caption => 'App Instances'
21
+ end
19
22
 
20
23
  # Add permissions
21
24
  security_block :foreman_acd do
25
+ permission :create_ansible_playbooks,
26
+ { :'foreman_acd/ansible_playbooks' => [:new, :create],
27
+ :'foreman_acd/api/v2/ansible_playbooks' => [:create] },
28
+ :resource_type => 'ForemanAcd::AnsiblePlaybook'
29
+
30
+ permission :view_ansible_playbooks,
31
+ { :'foreman_acd/ansible_playbooks' => [:index, :show, :auto_complete_search],
32
+ :'foreman_acd/api/v2/ansible_playbooks' => [:index, :show] },
33
+ :resource_type => 'ForemanAcd::AnsiblePlaybook'
34
+
35
+ permission :edit_ansible_playbooks,
36
+ { :'foreman_acd/ansible_playbooks' => [:update, :edit],
37
+ :'foreman_acd/api/v2/ansible_playbooks' => [:update] },
38
+ :resource_type => 'ForemanAcd::AnsiblePlaybook'
39
+
40
+ permission :destroy_ansible_playbooks,
41
+ { :'foreman_acd/ansible_playbooks' => [:destroy],
42
+ :'foreman_acd/api/v2/ansible_playbooks' => [:destroy] },
43
+ :resource_type => 'ForemanAcd::AnsiblePlaybook'
44
+
45
+ permission :import_vars_ansible_playbooks,
46
+ { :'foreman_acd/ansible_playbooks' => [:import_vars],
47
+ :'foreman_acd/api/v2/ansible_playbooks' => [:import_vars] },
48
+ :resource_type => 'ForemanAcd::AnsiblePlaybook'
49
+
50
+ permission :grab_ansible_playbooks,
51
+ { :'foreman_acd/api/v2/ansible_playbooks' => [:grab] },
52
+ :resource_type => 'ForemanAcd::AnsiblePlaybook'
53
+
22
54
  permission :create_app_definitions,
23
55
  { :'foreman_acd/app_definitions' => [:new, :create],
24
56
  :'foreman_acd/api/v2/app_definitions' => [:create] },
@@ -39,6 +71,16 @@ Foreman::Plugin.register :foreman_acd do
39
71
  :'foreman_acd/api/v2/app_definitions' => [:destroy] },
40
72
  :resource_type => 'ForemanAcd::AppDefinition'
41
73
 
74
+ permission :export_app_definitions,
75
+ { :'foreman_acd/app_definitions' => [:export],
76
+ :'foreman_acd/api/v2/app_definitions' => [:export] },
77
+ :resource_type => 'ForemanAcd::AppDefinition'
78
+
79
+ permission :import_app_definitions,
80
+ { :'foreman_acd/app_definitions' => [:import],
81
+ :'foreman_acd/api/v2/app_definitions' => [:import] },
82
+ :resource_type => 'ForemanAcd::AppDefinition'
83
+
42
84
  permission :create_app_instances,
43
85
  { :'foreman_acd/app_instances' => [:new, :create],
44
86
  :'foreman_acd/api/v2/app_instances' => [:create] },
@@ -63,18 +105,47 @@ Foreman::Plugin.register :foreman_acd do
63
105
  { :'foreman_acd/app_instances' => [:deploy],
64
106
  :'foreman_acd/api/v2/app_instances' => [:deploy] },
65
107
  :resource_type => 'ForemanAcd::AppInstance'
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
+ permission :report_app_instances,
115
+ { :'foreman_acd/app_instances' => [:report],
116
+ :'foreman_acd/api/v2/app_instances' => [:report] },
117
+ :resource_type => 'ForemanAcd::AppInstance'
66
118
  end
67
119
 
68
120
  # Manager Role
69
- role 'Application Centric Deployment Manager', [:create_app_definitions,
121
+ role 'Application Centric Deployment Manager', [:create_ansible_playbooks,
122
+ :view_ansible_playbooks,
123
+ :edit_ansible_playbooks,
124
+ :destroy_ansible_playbooks,
125
+ :import_vars_ansible_playbooks,
126
+ :grab_ansible_playbooks,
127
+ :create_app_definitions,
70
128
  :view_app_definitions,
71
129
  :edit_app_definitions,
72
- :destroy_app_definitions]
130
+ :destroy_app_definitions,
131
+ :export_app_definitions,
132
+ :import_app_definitions]
73
133
 
74
134
  # User Role
75
135
  role 'Application Centric Deployment User', [:create_app_instances,
76
136
  :view_app_instances,
77
137
  :edit_app_instances,
78
138
  :destroy_app_instances,
79
- :deploy_app_instances]
139
+ :deploy_app_instances,
140
+ :configure_app_instances,
141
+ :report_app_instances]
142
+
143
+ RemoteExecutionFeature.register(
144
+ :run_acd_ansible_playbook,
145
+ N_('Run playbook for ACD'),
146
+ {
147
+ :description => N_('Run an Ansible playbook to configure ACD application'),
148
+ :provided_inputs => %w[application_name playbook_name playbook_path inventory_path]
149
+ }
150
+ )
80
151
  end