foreman_acd 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +122 -0
  3. data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +54 -0
  4. data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +54 -0
  5. data/app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb +0 -0
  6. data/app/controllers/foreman_acd/app_definitions_controller.rb +7 -4
  7. data/app/controllers/foreman_acd/app_instances_controller.rb +33 -126
  8. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +23 -0
  9. data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
  10. data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
  11. data/app/controllers/ui_acd_controller.rb +11 -3
  12. data/app/models/foreman_acd/ansible_playbook.rb +50 -0
  13. data/app/models/foreman_acd/app_definition.rb +2 -0
  14. data/app/models/foreman_acd/app_instance.rb +7 -0
  15. data/app/services/foreman_acd/app_configurator.rb +70 -0
  16. data/app/services/foreman_acd/app_deployer.rb +143 -0
  17. data/app/services/foreman_acd/inventory_creator.rb +67 -0
  18. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +21 -0
  19. data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +3 -0
  20. data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
  21. data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
  22. data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +3 -0
  23. data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +3 -0
  24. data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +3 -0
  25. data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +3 -0
  26. data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +3 -0
  27. data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +3 -0
  28. data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -0
  29. data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +3 -0
  30. data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +3 -0
  31. data/app/views/foreman_acd/app_definitions/_form.html.erb +24 -10
  32. data/app/views/foreman_acd/app_definitions/edit.html.erb +5 -0
  33. data/app/views/foreman_acd/app_instances/_form.html.erb +7 -5
  34. data/app/views/foreman_acd/app_instances/index.html.erb +5 -1
  35. data/app/views/templates/job/run_acd_ansible_playbook.erb +49 -0
  36. data/app/views/ui_acd/ansible_data.json.rabl +6 -0
  37. data/app/views/ui_acd/app.json.rabl +6 -2
  38. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  39. data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
  40. data/config/routes.rb +24 -1
  41. data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
  42. data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
  43. data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +5 -0
  44. data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +5 -0
  45. data/db/seeds.d/75-job_templates.rb +8 -0
  46. data/lib/foreman_acd/engine.rb +3 -0
  47. data/lib/foreman_acd/plugin.rb +53 -2
  48. data/lib/foreman_acd/version.rb +1 -1
  49. data/package.json +1 -1
  50. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +137 -22
  51. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +95 -11
  52. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +7 -2
  53. data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
  54. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +117 -21
  55. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +2 -0
  56. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +49 -0
  57. data/webpack/components/ApplicationDefinition/index.js +4 -0
  58. data/webpack/components/ApplicationInstance/ApplicationInstance.js +92 -22
  59. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +37 -8
  60. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +4 -2
  61. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +98 -26
  62. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +2 -1
  63. data/webpack/components/ApplicationInstance/index.js +2 -0
  64. data/webpack/components/ParameterSelection/ParameterSelection.js +46 -37
  65. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +49 -52
  66. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +5 -3
  67. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +0 -32
  68. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +32 -16
  69. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -2
  70. data/webpack/components/ParameterSelection/index.js +4 -4
  71. data/webpack/components/common/DeleteTableEntry.js +1 -1
  72. data/webpack/reducer.js +14 -11
  73. metadata +48 -3
@@ -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_delete_if_authorized(hash_for_ansible_playbook_path(:id => ansible_playbook).merge(:auth_object => ansible_playbook, :authorizer => authorizer),
20
+ :data => { 'confirm': _('Delete %s?') % ansible_playbook.name }),
21
+ display_link_if_authorized(_("Import group variables"), hash_for_import_vars_ansible_playbook_path(:id => ansible_playbook).merge(:auth_object => ansible_playbook, :authorizer => authorizer))
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,15 +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
- "services": [],
8
- }
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
+ }
9
11
 
10
- if !@app_definition.name.empty?
11
- json["services"] = JSON.parse(@app_definition.services)
12
- 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
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| %>
@@ -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 %>
@@ -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
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
  %>
@@ -17,10 +17,14 @@
17
17
  <td>
18
18
  <%= action_buttons(display_link_if_authorized(_("Deploy"), hash_for_deploy_app_instance_path(:id => app_instance), :method => :post,
19
19
  :title => _("Deploy application #{app_instance}")),
20
+ display_link_if_authorized(_("Run Playbook"), hash_for_configure_app_instance_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_configure_app_instance_path(:id => app_instance, :customize => true), :method => :post,
23
+ :title => _("Prepare job to run ansible playbook for application #{app_instance}")),
20
24
  display_link_if_authorized(_("Report"), hash_for_report_app_instance_path(:id => app_instance), :method => :get,
21
25
  :title => _("Show last deployment report for application #{app_instance}")),
22
26
  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 })) %>
27
+ :data => { 'confirm': _('Delete %s?') % app_instance.name })) %>
24
28
  </td>
25
29
  </tr>
26
30
  <% end %>
@@ -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') %>
@@ -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, :services, :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,6 +2,16 @@
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'
@@ -21,11 +31,24 @@ Rails.application.routes.draw do
21
31
 
22
32
  member do
23
33
  post 'deploy'
34
+ post 'configure'
24
35
  get 'report'
25
36
  end
26
37
  end
27
38
 
28
39
  get 'ui_acd_app/:id', :to => 'ui_acd#app', :constraints => { :id => /[\w\.-]+/ }, :as => :ui_acd_app
29
- get 'ui_acd_fdata/:id', :to => 'ui_acd#fdata', :constraints => { :id => /[\w\.-]+/ }, :as => :ui_acd_fdata
40
+ get 'ui_acd_foreman_data/:id', :to => 'ui_acd#foreman_data', :constraints => { :id => /[\w\.-]+/ }, :as => :ui_acd_foreman_data
41
+ get 'ui_acd_ansible_data/:id', :to => 'ui_acd#ansible_data', :constraints => { :id => /[\w\.-]+/ }, :as => :ui_acd_ansible_data
42
+
43
+ scope :api, :path => '/api', :defaults => { :format => 'json' } do
44
+ scope '(:apiv)', :defaults => { :apiv => 'v2' },
45
+ :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2) do
46
+ constraints(:id => /[\w\.-]+/) do
47
+ resources :app_definitions, :only => [:show, :index], :controller => 'foreman_acd/api/v2/app_definitions', :as => :acd_api_v2_app_definitions
48
+ resources :app_instances, :only => [:show, :index], :controller => 'foreman_acd/api/v2/app_instances', :as => :api_v2_foreman_acd_app_instances
49
+ resources :ansible_playbooks, :only => [:show, :index], :controller => 'foreman_acd/api/v2/ansible_playbooks', :as => :api_v2_foreman_acd_ansible_playbooks
50
+ end
51
+ end
52
+ end
30
53
  end
31
54
  end
@@ -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,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|
@@ -1,12 +1,17 @@
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
9
  divider :top_menu, :parent => :configure_menu, :caption => 'Applications'
10
+ menu :top_menu, :ansible_playbooks,
11
+ :url_hash => { :controller => :'foreman_acd/ansible_playbooks', :action => :index },
12
+ :caption => 'Ansible Playbooks',
13
+ :parent => :configure_menu
14
+
10
15
  menu :top_menu, :app_definitions,
11
16
  :url_hash => { :controller => :'foreman_acd/app_definitions', :action => :index },
12
17
  :caption => 'App Definitions',
@@ -19,6 +24,31 @@ Foreman::Plugin.register :foreman_acd do
19
24
 
20
25
  # Add permissions
21
26
  security_block :foreman_acd do
27
+ permission :create_ansible_playbooks,
28
+ { :'foreman_acd/ansible_playbooks' => [:new, :create],
29
+ :'foreman_acd/api/v2/ansible_playbooks' => [:create] },
30
+ :resource_type => 'ForemanAcd::AnsiblePlaybook'
31
+
32
+ permission :view_ansible_playbooks,
33
+ { :'foreman_acd/ansible_playbooks' => [:index, :show, :auto_complete_search],
34
+ :'foreman_acd/api/v2/ansible_playbooks' => [:index, :show] },
35
+ :resource_type => 'ForemanAcd::AnsiblePlaybook'
36
+
37
+ permission :edit_ansible_playbooks,
38
+ { :'foreman_acd/ansible_playbooks' => [:update, :edit],
39
+ :'foreman_acd/api/v2/ansible_playbooks' => [:update] },
40
+ :resource_type => 'ForemanAcd::AnsiblePlaybook'
41
+
42
+ permission :destroy_ansible_playbooks,
43
+ { :'foreman_acd/ansible_playbooks' => [:destroy],
44
+ :'foreman_acd/api/v2/ansible_playbooks' => [:destroy] },
45
+ :resource_type => 'ForemanAcd::AnsiblePlaybook'
46
+
47
+ permission :import_vars_ansible_playbooks,
48
+ { :'foreman_acd/ansible_playbooks' => [:import_vars],
49
+ :'foreman_acd/api/v2/ansible_playbooks' => [:import_vars] },
50
+ :resource_type => 'ForemanAcd::AnsiblePlaybook'
51
+
22
52
  permission :create_app_definitions,
23
53
  { :'foreman_acd/app_definitions' => [:new, :create],
24
54
  :'foreman_acd/api/v2/app_definitions' => [:create] },
@@ -74,6 +104,11 @@ Foreman::Plugin.register :foreman_acd do
74
104
  :'foreman_acd/api/v2/app_instances' => [:deploy] },
75
105
  :resource_type => 'ForemanAcd::AppInstance'
76
106
 
107
+ permission :configure_app_instances,
108
+ { :'foreman_acd/app_instances' => [:configure],
109
+ :'foreman_acd/api/v2/app_instances' => [:configure] },
110
+ :resource_type => 'ForemanAcd::AppInstance'
111
+
77
112
  permission :report_app_instances,
78
113
  { :'foreman_acd/app_instances' => [:report],
79
114
  :'foreman_acd/api/v2/app_instances' => [:report] },
@@ -81,9 +116,15 @@ Foreman::Plugin.register :foreman_acd do
81
116
  end
82
117
 
83
118
  # Manager Role
84
- role 'Application Centric Deployment Manager', [:create_app_definitions,
119
+ role 'Application Centric Deployment Manager', [:create_ansible_playbooks,
120
+ :view_ansible_playbooks,
121
+ :edit_ansible_playbooks,
122
+ :destroy_ansible_playbooks,
123
+ :import_vars_ansible_playbooks,
124
+ :create_app_definitions,
85
125
  :view_app_definitions,
86
126
  :edit_app_definitions,
127
+ :destroy_app_definitions,
87
128
  :export_app_definitions,
88
129
  :import_app_definitions]
89
130
 
@@ -93,5 +134,15 @@ Foreman::Plugin.register :foreman_acd do
93
134
  :edit_app_instances,
94
135
  :destroy_app_instances,
95
136
  :deploy_app_instances,
137
+ :configure_app_instances,
96
138
  :report_app_instances]
139
+
140
+ RemoteExecutionFeature.register(
141
+ :run_acd_ansible_playbook,
142
+ N_('Run playbook for ACD'),
143
+ {
144
+ :description => N_('Run an Ansible playbook to configure ACD application'),
145
+ :provided_inputs => %w[application_name playbook_name playbook_path inventory_path]
146
+ }
147
+ )
97
148
  end