foreman_acd 0.4.0 → 0.9.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 +84 -84
- data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +103 -11
- data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +21 -3
- data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -0
- data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +9 -1
- data/app/controllers/foreman_acd/app_definitions_controller.rb +117 -15
- data/app/controllers/foreman_acd/app_instances_controller.rb +104 -30
- data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +1 -1
- data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
- data/app/controllers/foreman_acd/concerns/app_instance_mixins.rb +36 -0
- data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
- data/app/controllers/foreman_acd/remote_execution_controller.rb +36 -23
- data/app/controllers/ui_acd_controller.rb +46 -0
- data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +47 -0
- data/app/lib/actions/foreman_acd/run_configurator.rb +45 -0
- data/app/models/concerns/foreman_acd/host_managed_extensions.rb +39 -0
- data/app/models/foreman_acd/acd_provider.rb +36 -0
- data/app/models/foreman_acd/ansible_playbook.rb +32 -14
- data/app/models/foreman_acd/app_definition.rb +24 -1
- data/app/models/foreman_acd/app_instance.rb +85 -5
- data/app/models/foreman_acd/foreman_host.rb +31 -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 +64 -36
- data/app/services/foreman_acd/app_deployer.rb +83 -48
- data/app/services/foreman_acd/inventory_creator.rb +36 -25
- data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +50 -7
- data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +9 -1
- data/app/views/foreman_acd/ansible_playbooks/index.html.erb +3 -3
- data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +6 -0
- data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +6 -0
- data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -1
- data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +2 -0
- data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +2 -0
- data/app/views/foreman_acd/app_definitions/_form.html.erb +9 -1
- data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -5
- data/app/views/foreman_acd/app_definitions/import.html.erb +20 -1
- data/app/views/foreman_acd/app_definitions/index.html.erb +5 -8
- data/app/views/foreman_acd/app_instances/_form.html.erb +4 -4
- data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
- data/app/views/foreman_acd/app_instances/index.html.erb +93 -14
- data/app/views/foreman_acd/app_instances/report.html.erb +12 -4
- data/app/views/templates/job/run_acd_ansible_playbook.erb +28 -15
- data/app/views/ui_acd/app_definition.json.rabl +1 -1
- data/app/views/ui_acd/host_report.json.rabl +4 -0
- data/app/views/ui_acd/report_data.json.rabl +10 -0
- data/app/views/ui_acd/validate_hostname.json.rabl +6 -0
- data/config/routes.rb +12 -3
- data/db/migrate/20200917120220_add_ansible_playbook_id.rb +1 -1
- data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +3 -0
- data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +3 -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/migrate/20210818125913_add_is_existing_host_to_foreman_host.rb +8 -0
- data/db/migrate/20210902110645_add_initial_configure_task.rb +8 -0
- data/db/seeds.d/62_acd_proxy_feature.rb +4 -0
- data/db/seeds.d/75-job_templates.rb +6 -1
- data/lib/foreman_acd/engine.rb +40 -3
- data/lib/foreman_acd/plugin.rb +60 -45
- data/lib/foreman_acd/version.rb +1 -1
- data/lib/foreman_acd.rb +30 -0
- 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/{app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb → locale/en/foreman_acd.po.time_stamp} +0 -0
- data/locale/foreman_acd.pot +343 -8
- data/package.json +8 -8
- 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/ForemanModalActions.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 +55 -21
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +14 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +2 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +48 -1
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +4 -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 +26 -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 +225 -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 +2 -1
- 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 +8 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +214 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.scss +1 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +161 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +6 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +79 -0
- data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +8 -0
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportConfData_1.fixtures.js +129 -0
- data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +29 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +20 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +43 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +29 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +62 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportReducer.test.js.snap +362 -0
- data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +130 -0
- data/webpack/components/ApplicationDefinitionImport/index.js +32 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +153 -45
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +120 -6
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +5 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +15 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +77 -22
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +4 -0
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
- data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +80 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +24 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +131 -0
- data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +44 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +299 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2990 -0
- data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +276 -0
- data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +1 -0
- data/webpack/components/ApplicationInstance/components/Service.js +1 -1
- data/webpack/components/ApplicationInstance/components/ServiceCounter.js +1 -1
- data/webpack/components/ApplicationInstance/helper.js +0 -0
- data/webpack/components/ApplicationInstance/index.js +8 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +128 -60
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +17 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +40 -50
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +5 -4
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +19 -14
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +4 -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 +7 -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 +8 -3
- data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +104 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelection.scss +15 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +71 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +4 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionHelper.js +0 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +90 -0
- data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -0
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +191 -0
- data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +203 -0
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +19 -0
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionReducer.test.js +59 -0
- data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +36 -0
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelection.test.js.snap +35 -0
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionReducer.test.js.snap +614 -0
- data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +27 -0
- data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +48 -0
- data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +35 -0
- data/webpack/components/ExistingHostSelection/components/__tests__/__snapshots__/ServiceSelector.test.js.snap +77 -0
- data/webpack/components/ExistingHostSelection/index.js +26 -0
- data/webpack/components/ParameterSelection/ParameterSelection.js +138 -15
- data/webpack/components/ParameterSelection/ParameterSelection.scss +7 -0
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +52 -9
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +3 -0
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +62 -25
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +1 -0
- 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 +33 -25
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +84 -112
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1488 -872
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +117 -79
- data/webpack/components/ParameterSelection/index.js +2 -1
- data/webpack/components/SyncGitRepo/SyncGitRepo.js +202 -0
- data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +123 -0
- data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +8 -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 +31 -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 +47 -0
- data/webpack/components/SyncGitRepo/index.js +28 -0
- data/webpack/components/common/DeleteTableEntry.js +18 -4
- 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 +40 -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 +20 -1
- data/webpack/helper.test.js +37 -0
- data/webpack/index.js +7 -0
- data/webpack/js-yaml.js +3874 -0
- data/webpack/reducer.js +16 -1
- metadata +182 -11
- data/app/views/foreman_acd/app_instances/deploy.html.erb +0 -19
- data/webpack/components/common/EasyHeaderFormatter.js +0 -18
- data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
- data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -1,24 +1,24 @@
|
|
1
1
|
<%#
|
2
2
|
kind: job_template
|
3
|
-
name: Run ACD Ansible Playbook -
|
3
|
+
name: Run ACD Ansible Playbook - ACD Default
|
4
4
|
model: JobTemplate
|
5
5
|
job_category: Application Centric Deployment
|
6
|
-
description_format: "Run Ansible playbook
|
7
|
-
provider_type: SSH
|
6
|
+
description_format: "Run Ansible playbook to configure ACD application %{application_name}"
|
8
7
|
feature: run_acd_ansible_playbook
|
8
|
+
provider_type: ACD
|
9
9
|
template_inputs:
|
10
10
|
- name: application_name
|
11
11
|
description: The name of the ACD application instance to run
|
12
12
|
input_type: user
|
13
13
|
required: true
|
14
14
|
advanced: false
|
15
|
-
- name:
|
16
|
-
description: The
|
15
|
+
- name: playbook_id
|
16
|
+
description: The id of the Ansible playbook to run
|
17
17
|
input_type: user
|
18
18
|
required: true
|
19
19
|
advanced: false
|
20
|
-
- name:
|
21
|
-
description: The
|
20
|
+
- name: playbook_file
|
21
|
+
description: The playbook file of to the Ansible playbook
|
22
22
|
input_type: user
|
23
23
|
required: true
|
24
24
|
advanced: false
|
@@ -35,15 +35,28 @@ 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: "
|
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
|
%>
|
42
53
|
|
43
|
-
|
44
|
-
|
45
|
-
<%= input('
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
54
|
+
application_name: <%= input('application_name') %>
|
55
|
+
playbook_id: <%= input('playbook_id') %>
|
56
|
+
playbook_file: <%= input('playbook_file') %>
|
57
|
+
extra_vars: <%= input('extra_vars') %>
|
58
|
+
verbose: <%= input('verbose') %>
|
59
|
+
tags: <%= input('tags') %>
|
60
|
+
skip_tags: <%= input('skip_tags') %>
|
61
|
+
inventory: |
|
62
|
+
<%= indent(2) { input('inventory') } %>
|
data/config/routes.rb
CHANGED
@@ -5,23 +5,25 @@ Rails.application.routes.draw do
|
|
5
5
|
resources :ansible_playbooks, :controller => 'foreman_acd/ansible_playbooks' do
|
6
6
|
collection do
|
7
7
|
get 'auto_complete_search'
|
8
|
+
put 'sync_git_repo'
|
9
|
+
post 'sync_git_repo'
|
8
10
|
end
|
9
11
|
|
10
12
|
member do
|
13
|
+
post 'sync_git_repo'
|
11
14
|
get 'import_vars'
|
12
15
|
end
|
13
|
-
|
14
16
|
end
|
15
17
|
resources :app_definitions, :controller => 'foreman_acd/app_definitions' do
|
16
18
|
collection do
|
17
19
|
get 'auto_complete_search'
|
18
20
|
get 'import'
|
21
|
+
post 'handle_file_upload'
|
19
22
|
end
|
20
23
|
|
21
24
|
member do
|
22
25
|
get 'export'
|
23
26
|
end
|
24
|
-
|
25
27
|
end
|
26
28
|
|
27
29
|
resources :app_instances, :controller => 'foreman_acd/app_instances' do
|
@@ -32,6 +34,7 @@ Rails.application.routes.draw do
|
|
32
34
|
member do
|
33
35
|
post 'deploy'
|
34
36
|
get 'report'
|
37
|
+
delete 'destroy_with_hosts'
|
35
38
|
end
|
36
39
|
end
|
37
40
|
|
@@ -40,6 +43,8 @@ Rails.application.routes.draw do
|
|
40
43
|
get 'ui_acd_app/:id', :to => 'ui_acd#app', :constraints => { :id => /[\w\.-]+/ }, :as => :ui_acd_app
|
41
44
|
get 'ui_acd_foreman_data/:id', :to => 'ui_acd#foreman_data', :constraints => { :id => /[\w\.-]+/ }, :as => :ui_acd_foreman_data
|
42
45
|
get 'ui_acd_ansible_data/:id', :to => 'ui_acd#ansible_data', :constraints => { :id => /[\w\.-]+/ }, :as => :ui_acd_ansible_data
|
46
|
+
get 'ui_acd_report_data/:id', :to => 'ui_acd#report_data', :constraints => { :id => /[\w\.-]+/ }, :as => :ui_acd_report_data
|
47
|
+
get 'ui_acd_validate_hostname', :to => 'ui_acd#validate_hostname', :as => :ui_acd_validate_hostname
|
43
48
|
|
44
49
|
scope :api, :path => '/api', :defaults => { :format => 'json' } do
|
45
50
|
scope '(:apiv)', :defaults => { :apiv => 'v2' },
|
@@ -47,7 +52,11 @@ Rails.application.routes.draw do
|
|
47
52
|
constraints(:id => /[\w\.-]+/) do
|
48
53
|
resources :app_definitions, :only => [:show, :index], :controller => 'foreman_acd/api/v2/app_definitions', :as => :acd_api_v2_app_definitions
|
49
54
|
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
|
55
|
+
resources :ansible_playbooks, :only => [:show, :index], :controller => 'foreman_acd/api/v2/ansible_playbooks', :as => :api_v2_foreman_acd_ansible_playbooks do
|
56
|
+
member do
|
57
|
+
get 'grab'
|
58
|
+
end
|
59
|
+
end
|
51
60
|
end
|
52
61
|
end
|
53
62
|
end
|
@@ -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
|
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
|
@@ -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
|
@@ -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, :
|
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?
|
6
11
|
end
|
7
12
|
end
|
8
13
|
end
|
data/lib/foreman_acd/engine.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'foreman_remote_execution'
|
4
|
+
require 'git'
|
4
5
|
|
6
|
+
# The ForemanAcd module
|
5
7
|
module ForemanAcd
|
6
8
|
# This engine connects ForemanAcd with Foreman core
|
7
9
|
class Engine < ::Rails::Engine
|
8
10
|
engine_name 'foreman_acd'
|
9
11
|
|
10
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"]
|
11
15
|
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
16
|
config.autoload_paths += Dir["#{config.root}/app/overrides"]
|
15
|
-
config.autoload_paths += Dir["#{config.root}/app/services"]
|
16
17
|
config.autoload_paths += Dir["#{config.root}/app/lib"]
|
17
18
|
config.autoload_paths += Dir["#{config.root}/lib"]
|
18
19
|
|
@@ -42,5 +43,41 @@ module ForemanAcd
|
|
42
43
|
initializer 'foreman_acd.register_plugin', :before => :finisher_hook do
|
43
44
|
require 'foreman_acd/plugin'
|
44
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
|
+
)
|
45
82
|
end
|
46
83
|
end
|
data/lib/foreman_acd/plugin.rb
CHANGED
@@ -6,21 +6,19 @@ Foreman::Plugin.register :foreman_acd do
|
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
:caption => 'App Instances',
|
23
|
-
: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'
|
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
|
24
22
|
|
25
23
|
# Add permissions
|
26
24
|
security_block :foreman_acd do
|
@@ -49,6 +47,10 @@ Foreman::Plugin.register :foreman_acd do
|
|
49
47
|
:'foreman_acd/api/v2/ansible_playbooks' => [:import_vars] },
|
50
48
|
:resource_type => 'ForemanAcd::AnsiblePlaybook'
|
51
49
|
|
50
|
+
permission :grab_ansible_playbooks,
|
51
|
+
{ :'foreman_acd/api/v2/ansible_playbooks' => [:grab] },
|
52
|
+
:resource_type => 'ForemanAcd::AnsiblePlaybook'
|
53
|
+
|
52
54
|
permission :create_app_definitions,
|
53
55
|
{ :'foreman_acd/app_definitions' => [:new, :create],
|
54
56
|
:'foreman_acd/api/v2/app_definitions' => [:create] },
|
@@ -95,8 +97,8 @@ Foreman::Plugin.register :foreman_acd do
|
|
95
97
|
:resource_type => 'ForemanAcd::AppInstance'
|
96
98
|
|
97
99
|
permission :destroy_app_instances,
|
98
|
-
{ :'foreman_acd/app_instances' => [:destroy],
|
99
|
-
:'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] },
|
100
102
|
:resource_type => 'ForemanAcd::AppInstance'
|
101
103
|
|
102
104
|
permission :deploy_app_instances,
|
@@ -104,45 +106,58 @@ Foreman::Plugin.register :foreman_acd do
|
|
104
106
|
:'foreman_acd/api/v2/app_instances' => [:deploy] },
|
105
107
|
:resource_type => 'ForemanAcd::AppInstance'
|
106
108
|
|
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
|
-
|
112
109
|
permission :report_app_instances,
|
113
110
|
{ :'foreman_acd/app_instances' => [:report],
|
114
111
|
:'foreman_acd/api/v2/app_instances' => [:report] },
|
115
112
|
:resource_type => 'ForemanAcd::AppInstance'
|
113
|
+
|
114
|
+
permission :new_acd_configure_job,
|
115
|
+
{ :'foreman_acd/remote_execution' => [:new] },
|
116
|
+
:resource_type => 'ForemanAcd::AppInstance'
|
117
|
+
|
118
|
+
permission :create_acd_configure_job,
|
119
|
+
{ :'foreman_acd/remote_execution' => [:create] },
|
120
|
+
:resource_type => 'ForemanAcd::AppInstance'
|
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'
|
116
128
|
end
|
117
129
|
|
118
130
|
# Manager Role
|
119
|
-
role 'Application Centric Deployment Manager', [:create_ansible_playbooks,
|
120
|
-
:view_ansible_playbooks,
|
121
|
-
:edit_ansible_playbooks,
|
131
|
+
role 'Application Centric Deployment Manager', [:create_ansible_playbooks, :view_ansible_playbooks, :edit_ansible_playbooks,
|
122
132
|
:destroy_ansible_playbooks,
|
123
|
-
:import_vars_ansible_playbooks,
|
124
|
-
:create_app_definitions,
|
125
|
-
:view_app_definitions,
|
126
|
-
:edit_app_definitions,
|
133
|
+
:import_vars_ansible_playbooks, :grab_ansible_playbooks,
|
134
|
+
:create_app_definitions, :view_app_definitions, :edit_app_definitions,
|
127
135
|
:destroy_app_definitions,
|
128
|
-
:export_app_definitions,
|
129
|
-
:
|
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_acd_configure_job, :create_acd_configure_job,
|
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]
|
130
148
|
|
131
149
|
# User Role
|
132
|
-
role 'Application Centric Deployment User', [:create_app_instances,
|
133
|
-
:view_app_instances,
|
134
|
-
:edit_app_instances,
|
150
|
+
role 'Application Centric Deployment User', [:create_app_instances, :view_app_instances, :edit_app_instances,
|
135
151
|
:destroy_app_instances,
|
136
152
|
:deploy_app_instances,
|
137
|
-
:
|
138
|
-
:report_app_instances
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
)
|
153
|
+
:new_acd_configure_job, :create_acd_configure_job,
|
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
|
148
163
|
end
|
data/lib/foreman_acd/version.rb
CHANGED
data/lib/foreman_acd.rb
CHANGED
@@ -4,4 +4,34 @@ require 'foreman_acd/engine'
|
|
4
4
|
|
5
5
|
# Module required to start the Foreman Rails engine
|
6
6
|
module ForemanAcd
|
7
|
+
RUN_CONFIGURATOR_DELAY = 240
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def acd_base_path
|
11
|
+
'/var/lib/foreman/foreman_acd/'
|
12
|
+
end
|
13
|
+
|
14
|
+
def ansible_playbook_path
|
15
|
+
File.join(acd_base_path, 'ansible-playbooks')
|
16
|
+
end
|
17
|
+
|
18
|
+
def proxy_setting
|
19
|
+
HttpProxy.default_global_content_proxy&.full_url ||
|
20
|
+
Setting[:http_proxy]
|
21
|
+
end
|
22
|
+
|
23
|
+
def initiate_acd_app_configurator(app_instance)
|
24
|
+
return unless app_instance.hosts_deployment_finished?
|
25
|
+
|
26
|
+
::Foreman::Logging.logger('foreman_acd').info("All hosts of app (#{app_instance.name}) were built. Schedule app configurator...")
|
27
|
+
start_acd_app_configurator(app_instance)
|
28
|
+
end
|
29
|
+
|
30
|
+
def start_acd_app_configurator(app_instance)
|
31
|
+
task = ForemanTasks.delay(::Actions::ForemanAcd::RunConfigurator,
|
32
|
+
{ :start_at => Time.zone.now + RUN_CONFIGURATOR_DELAY },
|
33
|
+
app_instance)
|
34
|
+
app_instance.update(:initial_configure_task_id => task.id)
|
35
|
+
end
|
36
|
+
end
|
7
37
|
end
|
@@ -1,17 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'rake/testtask'
|
4
|
-
|
5
|
-
# Tasks
|
6
|
-
namespace :foreman_acd do
|
7
|
-
namespace :example do
|
8
|
-
desc 'Example Task'
|
9
|
-
task :task => :environment do
|
10
|
-
# Task goes here
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
3
|
# Tests
|
16
4
|
namespace :test do
|
17
5
|
desc 'Test ForemanAcd'
|