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.
- checksums.yaml +4 -4
- data/README.md +107 -56
- data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +199 -0
- data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +72 -0
- data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -0
- data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +62 -0
- data/app/controllers/foreman_acd/app_definitions_controller.rb +19 -10
- data/app/controllers/foreman_acd/app_instances_controller.rb +111 -137
- data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +23 -0
- data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
- data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
- data/app/controllers/foreman_acd/remote_execution_controller.rb +62 -0
- data/app/controllers/ui_acd_controller.rb +20 -3
- data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +47 -0
- data/app/lib/actions/foreman_acd/run_configurator.rb +44 -0
- data/app/models/concerns/foreman_acd/host_managed_extensions.rb +51 -0
- data/app/models/foreman_acd/acd_provider.rb +36 -0
- data/app/models/foreman_acd/ansible_playbook.rb +68 -0
- data/app/models/foreman_acd/app_definition.rb +25 -0
- data/app/models/foreman_acd/app_instance.rb +42 -0
- data/app/models/foreman_acd/foreman_host.rb +23 -0
- data/app/models/foreman_acd/taxonomy_extensions.rb +17 -0
- data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
- data/app/services/foreman_acd/app_configurator.rb +98 -0
- data/app/services/foreman_acd/app_deployer.rb +157 -0
- data/app/services/foreman_acd/inventory_creator.rb +68 -0
- data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +64 -0
- data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +11 -0
- data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
- data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +9 -0
- data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +9 -0
- data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +5 -0
- data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +5 -0
- data/app/views/foreman_acd/app_definitions/_form.html.erb +34 -12
- data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -0
- data/app/views/foreman_acd/app_definitions/index.html.erb +4 -4
- data/app/views/foreman_acd/app_instances/_form.html.erb +11 -9
- data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
- data/app/views/foreman_acd/app_instances/index.html.erb +89 -10
- data/app/views/foreman_acd/app_instances/report.html.erb +6 -3
- data/app/views/templates/job/run_acd_ansible_playbook.erb +62 -0
- data/app/views/ui_acd/ansible_data.json.rabl +6 -0
- data/app/views/ui_acd/app.json.rabl +6 -2
- data/app/views/ui_acd/app_definition.json.rabl +1 -1
- data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
- data/config/routes.rb +32 -2
- data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
- data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
- data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +8 -0
- data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +8 -0
- data/db/migrate/20210112111548_add_organization_to_app_instance.rb +22 -0
- data/db/migrate/20210112113853_add_location_to_app_instance.rb +8 -0
- data/db/migrate/20210202141658_create_foreman_hosts.rb +24 -0
- data/db/migrate/20210204111306_remove_hosts_from_app_instances.rb +8 -0
- data/db/migrate/20210209091014_rename_acd_tables.rb +16 -0
- data/db/migrate/20210216083522_add_last_progress_report.rb +8 -0
- data/db/migrate/20210216091529_add_last_deploy_task.rb +8 -0
- data/db/migrate/20210316151145_add_git_commit_to_ansible_playbooks.rb +8 -0
- data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +8 -0
- data/db/seeds.d/62_acd_proxy_feature.rb +4 -0
- data/db/seeds.d/75-job_templates.rb +13 -0
- data/lib/foreman_acd.rb +12 -0
- data/lib/foreman_acd/engine.rb +43 -3
- data/lib/foreman_acd/plugin.rb +88 -22
- data/lib/foreman_acd/version.rb +1 -1
- data/lib/tasks/foreman_acd_tasks.rake +0 -12
- data/locale/en/foreman_acd.edit.po +326 -0
- data/locale/en/foreman_acd.po +232 -2
- data/locale/en/foreman_acd.po.time_stamp +0 -0
- data/locale/foreman_acd.pot +343 -8
- data/package.json +9 -9
- data/test/controllers/ansible_playbooks_controller_test.rb +27 -0
- data/test/controllers/app_instances_controller_test.rb +8 -3
- data/test/controllers/ui_acd_controller_test.rb +22 -6
- data/test/factories/foreman_acd_factories.rb +18 -4
- data/test/models/acd_provider_test.rb +37 -0
- data/test/models/ansible_playbook_test.rb +11 -0
- data/test/models/app_definition_test.rb +1 -1
- data/test/models/app_instance_test.rb +2 -0
- data/test/models/concerns/host_extensions_test.rb +26 -0
- data/test/models/foreman_host_test.rb +12 -0
- data/webpack/__mocks__/foremanReact/API.js +2 -0
- data/webpack/__mocks__/foremanReact/common/I18n.js +3 -0
- data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
- data/webpack/__mocks__/foremanReact/components/ForemanModal.js +7 -0
- data/webpack/__mocks__/foremanReact/components/common/forms/CommonForm.js +2 -0
- data/webpack/__mocks__/foremanReact/components/common/forms/TextInput.js +2 -0
- data/webpack/__mocks__/foremanReact/components/hosts/powerStatus.js +1 -0
- data/webpack/__snapshots__/helper.test.js.snap +14 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +159 -29
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +106 -14
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +8 -2
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +143 -21
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +3 -0
- data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionConfData_1.fixtures.js +288 -0
- data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +79 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +25 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +119 -0
- data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +41 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +200 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +3033 -0
- data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +299 -0
- data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +50 -0
- data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +41 -0
- data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +121 -0
- data/webpack/components/ApplicationDefinition/index.js +6 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +151 -44
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +47 -10
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +5 -2
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +114 -28
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +3 -1
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +78 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +23 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +119 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +44 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +209 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2719 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +276 -0
- data/webpack/components/ApplicationInstance/components/Service.js +1 -1
- data/webpack/components/ApplicationInstance/index.js +4 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +53 -60
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +17 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +7 -51
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +2 -4
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +4 -18
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +0 -1
- data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportData_1.fixtures.js +349 -0
- data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +20 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +47 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportReducer.test.js +41 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +26 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +130 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +718 -0
- data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +347 -0
- data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +1 -1
- data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +24 -0
- data/webpack/components/ApplicationInstanceReport/components/__tests__/__snapshots__/ReportViewer.test.js.snap +24 -0
- data/webpack/components/ApplicationInstanceReport/index.js +0 -2
- data/webpack/components/ParameterSelection/ParameterSelection.js +85 -50
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +68 -62
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +6 -3
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +0 -32
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +47 -35
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -2
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +116 -84
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +10 -4
- data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +36 -46
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +31 -25
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +2 -126
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1483 -872
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +117 -79
- data/webpack/components/ParameterSelection/index.js +4 -4
- data/webpack/components/SyncGitRepo/SyncGitRepo.js +210 -0
- data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +124 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +9 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +80 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoSelectors.js +6 -0
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +7 -0
- data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +44 -0
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +27 -0
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoReducer.test.js +95 -0
- data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +32 -0
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +30 -0
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoReducer.test.js.snap +137 -0
- data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +13 -0
- data/webpack/components/SyncGitRepo/components/FormTextInput.js +42 -0
- data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +46 -0
- data/webpack/components/SyncGitRepo/index.js +28 -0
- data/webpack/components/common/DeleteTableEntry.js +3 -3
- data/webpack/components/common/EditTableEntry.js +50 -0
- data/webpack/components/common/ExtTextInput.js +43 -0
- data/webpack/components/common/LockTableEntry.js +60 -0
- data/webpack/components/common/__tests__/EditTableEntry.test.js +53 -0
- data/webpack/components/common/__tests__/LockTableEntry.test.js +35 -0
- data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +2 -2
- data/webpack/components/common/__tests__/__snapshots__/EditTableEntry.test.js.snap +81 -0
- data/webpack/components/common/__tests__/__snapshots__/LockTableEntry.test.js.snap +60 -0
- data/webpack/helper.js +15 -1
- data/webpack/helper.test.js +37 -0
- data/webpack/index.js +2 -0
- data/webpack/reducer.js +18 -11
- metadata +184 -10
- data/app/views/foreman_acd/app_instances/deploy.html.erb +0 -19
- data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
- data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -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['
|
8
|
-
extends 'ui_acd/
|
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
|
data/config/routes.rb
CHANGED
@@ -2,6 +2,18 @@
|
|
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
|
+
put 'sync_git_repo'
|
9
|
+
post 'sync_git_repo'
|
10
|
+
end
|
11
|
+
|
12
|
+
member do
|
13
|
+
post 'sync_git_repo'
|
14
|
+
get 'import_vars'
|
15
|
+
end
|
16
|
+
end
|
5
17
|
resources :app_definitions, :controller => 'foreman_acd/app_definitions' do
|
6
18
|
collection do
|
7
19
|
get 'auto_complete_search'
|
@@ -11,7 +23,6 @@ Rails.application.routes.draw do
|
|
11
23
|
member do
|
12
24
|
get 'export'
|
13
25
|
end
|
14
|
-
|
15
26
|
end
|
16
27
|
|
17
28
|
resources :app_instances, :controller => 'foreman_acd/app_instances' do
|
@@ -22,10 +33,29 @@ Rails.application.routes.draw do
|
|
22
33
|
member do
|
23
34
|
post 'deploy'
|
24
35
|
get 'report'
|
36
|
+
delete 'destroy_with_hosts'
|
25
37
|
end
|
26
38
|
end
|
27
39
|
|
40
|
+
match '/remote_execution', :controller => 'foreman_acd/remote_execution', :action => 'create', :via => [:post]
|
41
|
+
|
28
42
|
get 'ui_acd_app/:id', :to => 'ui_acd#app', :constraints => { :id => /[\w\.-]+/ }, :as => :ui_acd_app
|
29
|
-
get '
|
43
|
+
get 'ui_acd_foreman_data/:id', :to => 'ui_acd#foreman_data', :constraints => { :id => /[\w\.-]+/ }, :as => :ui_acd_foreman_data
|
44
|
+
get 'ui_acd_ansible_data/:id', :to => 'ui_acd#ansible_data', :constraints => { :id => /[\w\.-]+/ }, :as => :ui_acd_ansible_data
|
45
|
+
|
46
|
+
scope :api, :path => '/api', :defaults => { :format => 'json' } do
|
47
|
+
scope '(:apiv)', :defaults => { :apiv => 'v2' },
|
48
|
+
:apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2) do
|
49
|
+
constraints(:id => /[\w\.-]+/) do
|
50
|
+
resources :app_definitions, :only => [:show, :index], :controller => 'foreman_acd/api/v2/app_definitions', :as => :acd_api_v2_app_definitions
|
51
|
+
resources :app_instances, :only => [:show, :index], :controller => 'foreman_acd/api/v2/app_instances', :as => :api_v2_foreman_acd_app_instances
|
52
|
+
resources :ansible_playbooks, :only => [:show, :index], :controller => 'foreman_acd/api/v2/ansible_playbooks', :as => :api_v2_foreman_acd_ansible_playbooks do
|
53
|
+
member do
|
54
|
+
get 'grab'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
30
60
|
end
|
31
61
|
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,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,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,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,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
User.as_anonymous_admin do
|
4
|
+
JobTemplate.without_auditing do
|
5
|
+
Dir[File.join("#{ForemanAcd::Engine.root}/app/views/templates/**/*.erb")].each do |template|
|
6
|
+
sync = !Rails.env.test? && Setting[:remote_execution_sync_templates]
|
7
|
+
template = JobTemplate.import_raw!(File.read(template), :default => true, :lock => true, :update => sync)
|
8
|
+
|
9
|
+
template.organizations << Organization.unscoped.all if template&.organizations&.empty?
|
10
|
+
template.locations << Location.unscoped.all if template&.locations&.empty?
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/foreman_acd.rb
CHANGED
@@ -4,4 +4,16 @@ require 'foreman_acd/engine'
|
|
4
4
|
|
5
5
|
# Module required to start the Foreman Rails engine
|
6
6
|
module ForemanAcd
|
7
|
+
def self.acd_base_path
|
8
|
+
'/var/lib/foreman/foreman_acd/'
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.ansible_playbook_path
|
12
|
+
File.join(acd_base_path, 'ansible-playbooks')
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.proxy_setting
|
16
|
+
HttpProxy.default_global_content_proxy&.full_url ||
|
17
|
+
Setting[:http_proxy]
|
18
|
+
end
|
7
19
|
end
|
data/lib/foreman_acd/engine.rb
CHANGED
@@ -1,17 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'foreman_remote_execution'
|
4
|
+
require 'git'
|
5
|
+
|
6
|
+
# The ForemanAcd module
|
3
7
|
module ForemanAcd
|
4
8
|
# This engine connects ForemanAcd with Foreman core
|
5
9
|
class Engine < ::Rails::Engine
|
6
10
|
engine_name 'foreman_acd'
|
7
11
|
|
8
12
|
config.autoload_paths += Dir["#{config.root}/app/controllers/foreman_acd/concerns"]
|
13
|
+
config.autoload_paths += Dir["#{config.root}/app/models"]
|
14
|
+
config.autoload_paths += Dir["#{config.root}/app/services"]
|
9
15
|
config.autoload_paths += Dir["#{config.root}/app/helpers"]
|
10
|
-
config.autoload_paths += Dir["#{config.root}/app/models/foreman_acd/concerns"]
|
11
|
-
config.autoload_paths += Dir["#{config.root}/app/models/parameters"]
|
12
16
|
config.autoload_paths += Dir["#{config.root}/app/overrides"]
|
13
|
-
config.autoload_paths += Dir["#{config.root}/app/services"]
|
14
17
|
config.autoload_paths += Dir["#{config.root}/app/lib"]
|
18
|
+
config.autoload_paths += Dir["#{config.root}/lib"]
|
15
19
|
|
16
20
|
# Add any db migrations
|
17
21
|
initializer 'foreman_acd.load_app_instance_data' do |app|
|
@@ -39,5 +43,41 @@ module ForemanAcd
|
|
39
43
|
initializer 'foreman_acd.register_plugin', :before => :finisher_hook do
|
40
44
|
require 'foreman_acd/plugin'
|
41
45
|
end
|
46
|
+
|
47
|
+
initializer 'foreman_acd.register_actions', :before => :finisher_hook do |_app|
|
48
|
+
ForemanTasks.dynflow.require!
|
49
|
+
action_paths = %W[#{ForemanAcd::Engine.root}/app/lib/actions]
|
50
|
+
ForemanTasks.dynflow.config.eager_load_paths.concat(action_paths)
|
51
|
+
end
|
52
|
+
|
53
|
+
config.to_prepare do
|
54
|
+
::Taxonomy.include ForemanAcd::TaxonomyExtensions
|
55
|
+
::Host::Managed.prepend ForemanAcd::HostManagedExtensions
|
56
|
+
|
57
|
+
RemoteExecutionProvider.register(:ACD, AcdProvider)
|
58
|
+
ForemanAcd.register_rex_feature
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.with_katello?
|
63
|
+
defined?(::Katello)
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.with_remote_execution?
|
67
|
+
RemoteExecutionFeature
|
68
|
+
rescue StandardError
|
69
|
+
false
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.register_rex_feature
|
73
|
+
return unless ForemanAcd.with_remote_execution?
|
74
|
+
RemoteExecutionFeature.register(
|
75
|
+
:run_acd_ansible_playbook,
|
76
|
+
N_('Run playbook for ACD'),
|
77
|
+
{
|
78
|
+
:description => N_('Run an Ansible playbook to configure ACD application'),
|
79
|
+
:provided_inputs => %w[application_name playbook_name playbook_path inventory_path]
|
80
|
+
}
|
81
|
+
)
|
42
82
|
end
|
43
83
|
end
|
data/lib/foreman_acd/plugin.rb
CHANGED
@@ -1,24 +1,56 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Foreman::Plugin.register :foreman_acd do
|
4
|
-
requires_foreman '>= 1
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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'
|
13
|
+
|
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] },
|
@@ -65,8 +97,8 @@ Foreman::Plugin.register :foreman_acd do
|
|
65
97
|
:resource_type => 'ForemanAcd::AppInstance'
|
66
98
|
|
67
99
|
permission :destroy_app_instances,
|
68
|
-
{ :'foreman_acd/app_instances' => [:destroy],
|
69
|
-
:'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] },
|
70
102
|
:resource_type => 'ForemanAcd::AppInstance'
|
71
103
|
|
72
104
|
permission :deploy_app_instances,
|
@@ -78,20 +110,54 @@ Foreman::Plugin.register :foreman_acd do
|
|
78
110
|
{ :'foreman_acd/app_instances' => [:report],
|
79
111
|
:'foreman_acd/api/v2/app_instances' => [:report] },
|
80
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'
|
81
128
|
end
|
82
129
|
|
83
130
|
# Manager Role
|
84
|
-
role 'Application Centric Deployment Manager', [:
|
85
|
-
:
|
86
|
-
:
|
87
|
-
:
|
88
|
-
:
|
131
|
+
role 'Application Centric Deployment Manager', [:create_ansible_playbooks, :view_ansible_playbooks, :edit_ansible_playbooks,
|
132
|
+
:destroy_ansible_playbooks,
|
133
|
+
:import_vars_ansible_playbooks, :grab_ansible_playbooks,
|
134
|
+
:create_app_definitions, :view_app_definitions, :edit_app_definitions,
|
135
|
+
:destroy_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]
|
89
148
|
|
90
149
|
# User Role
|
91
|
-
role 'Application Centric Deployment User', [:create_app_instances,
|
92
|
-
:view_app_instances,
|
93
|
-
:edit_app_instances,
|
150
|
+
role 'Application Centric Deployment User', [:create_app_instances, :view_app_instances, :edit_app_instances,
|
94
151
|
:destroy_app_instances,
|
95
152
|
:deploy_app_instances,
|
96
|
-
:
|
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
|
97
163
|
end
|