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
@@ -3,12 +3,11 @@
|
|
3
3
|
module ForemanAcd
|
4
4
|
# inventory creator for application instances
|
5
5
|
class InventoryCreator
|
6
|
-
|
7
6
|
delegate :logger, :to => :Rails
|
8
7
|
|
9
|
-
def initialize(app_instance,
|
8
|
+
def initialize(app_instance, foreman_hosts)
|
10
9
|
@app_instance = app_instance
|
11
|
-
@
|
10
|
+
@foreman_hosts = foreman_hosts
|
12
11
|
end
|
13
12
|
|
14
13
|
# TODO: this might be part of the smart proxy plugin.
|
@@ -16,52 +15,64 @@ module ForemanAcd
|
|
16
15
|
inventory = {}
|
17
16
|
inventory['all'] = {}
|
18
17
|
|
19
|
-
inventory['all'] = { 'vars' => inventory_all_vars }
|
18
|
+
inventory['all'] = { 'vars' => inventory_all_vars } if @app_instance.ansible_vars_all.present?
|
20
19
|
|
21
20
|
services = JSON.parse(@app_instance.app_definition.services)
|
22
|
-
app_hosts = filtered_hosts
|
23
21
|
|
24
22
|
children = {}
|
25
|
-
|
26
|
-
if
|
27
|
-
logger.warn "Ignore host #{
|
23
|
+
@foreman_hosts.each do |foreman_host|
|
24
|
+
if foreman_host.host_id.nil?
|
25
|
+
logger.warn "Ignore host #{foreman_h.hostname} because no foreman host id could be found. Is the host not provisioned yet?"
|
28
26
|
next
|
29
27
|
end
|
30
28
|
|
31
|
-
service_id =
|
29
|
+
service_id = foreman_host.service.to_i
|
32
30
|
host_service = services.select { |s| s['id'] == service_id }.first
|
33
31
|
ansible_group = host_service['ansibleGroup']
|
34
32
|
|
35
|
-
unless children.
|
36
|
-
children[ansible_group] = { 'hosts' => {} }
|
37
|
-
end
|
33
|
+
children[ansible_group] = { 'hosts' => {} } unless children.key?(host_service['ansibleGroup'])
|
38
34
|
|
39
|
-
ansible_vars =
|
35
|
+
ansible_vars = JSON.parse(foreman_host.ansibleParameters).map { |v| { v['name'] => get_param_value(foreman_host.host, v['value']) } }.reduce({}, :merge!)
|
40
36
|
|
41
37
|
# in case there is no ansible_user defined, set "root" as default.
|
42
|
-
unless ansible_vars.
|
43
|
-
|
44
|
-
end
|
38
|
+
ansible_vars['ansible_user'] = 'root' unless ansible_vars.key?('ansible_user')
|
39
|
+
ansible_vars['ansible_ssh_private_key_file'] = ansible_or_rex_ssh_private_key(foreman_host.host)
|
45
40
|
|
46
|
-
children[ansible_group]['hosts'][
|
41
|
+
children[ansible_group]['hosts'][foreman_host.host.name] = ansible_vars
|
47
42
|
end
|
48
43
|
inventory['all']['children'] = children
|
49
44
|
inventory
|
50
45
|
end
|
51
46
|
|
52
47
|
private
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
48
|
+
|
49
|
+
def get_param_value(host, value)
|
50
|
+
search_param = value.match(/PARAM\[([^\s]*)\]/)
|
51
|
+
return value if search_param.nil?
|
52
|
+
|
53
|
+
resolved_value = host.host_param(search_param[1])
|
54
|
+
logger.warn "Could not resolve ansible host param value #{value} for host #{host}" if resolved_value.nil?
|
55
|
+
|
56
|
+
resolved_value
|
57
|
+
end
|
58
|
+
|
59
|
+
def ansible_or_rex_ssh_private_key(host)
|
60
|
+
ansible_private_file = host_setting(host, 'ansible_ssh_private_key_file')
|
61
|
+
if !ansible_private_file.empty?
|
62
|
+
ansible_private_file
|
63
|
+
else
|
64
|
+
ForemanRemoteExecutionCore.settings[:ssh_identity_key_file]
|
65
|
+
end
|
57
66
|
end
|
58
67
|
|
59
|
-
def
|
60
|
-
|
68
|
+
def host_setting(host, setting)
|
69
|
+
host.params[setting] || Setting[setting]
|
61
70
|
end
|
62
71
|
|
63
|
-
def
|
64
|
-
JSON.parse(@app_instance.
|
72
|
+
def inventory_all_vars
|
73
|
+
JSON.parse(@app_instance.ansible_vars_all).map do |a|
|
74
|
+
{ a['name'] => a['value'] }
|
75
|
+
end.reduce({}, :merge!)
|
65
76
|
end
|
66
77
|
end
|
67
78
|
end
|
@@ -1,21 +1,64 @@
|
|
1
|
+
<% content_for(:javascripts) do %>
|
2
|
+
<%= webpacked_plugins_js_for :foreman_acd %>
|
3
|
+
<% end %>
|
4
|
+
<% content_for(:stylesheets) do %>
|
5
|
+
<%= webpacked_plugins_css_for :foreman_acd %>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<%
|
9
|
+
if @ansible_playbook.new_record?
|
10
|
+
json = {
|
11
|
+
"scmTypes": {"directory" => "directory", "git" => "git"},
|
12
|
+
"mode": "newPlaybook",
|
13
|
+
"organization": current_organization,
|
14
|
+
"location": current_location,
|
15
|
+
"path": "",
|
16
|
+
"gitUrl": "",
|
17
|
+
"gitCommit": "",
|
18
|
+
"scmType": "",
|
19
|
+
"appDefinitions": [],
|
20
|
+
}
|
21
|
+
|
22
|
+
else
|
23
|
+
json = {
|
24
|
+
"scmTypes": {"directory" => "directory", "git" => "git"},
|
25
|
+
"mode": "editPlaybook",
|
26
|
+
"organization": current_organization,
|
27
|
+
"location": current_location,
|
28
|
+
"path": @ansible_playbook.path,
|
29
|
+
"gitUrl": @ansible_playbook.git_url,
|
30
|
+
"gitCommit": @ansible_playbook.git_commit,
|
31
|
+
"scmType": @ansible_playbook.scm_type,
|
32
|
+
"appDefinitions": @ansible_playbook.app_definitions
|
33
|
+
}
|
34
|
+
end
|
35
|
+
%>
|
36
|
+
|
1
37
|
<%= form_for @ansible_playbook, :url => (@ansible_playbook.new_record? ? ansible_playbooks_path : ansible_playbook_path(:id => @ansible_playbook.id)) do |f| %>
|
2
38
|
<%= base_errors_for @ansible_playbook %>
|
3
39
|
|
4
40
|
<ul class="nav nav-tabs" data-tabs="tabs">
|
5
41
|
<li class="active"><a href="#primary" data-toggle="tab"><%= _('Ansible playbooks') %></a></li>
|
42
|
+
<% if show_location_tab? %>
|
43
|
+
<li><a href="#locations" data-toggle="tab"><%= _("Locations") %></a></li>
|
44
|
+
<% end %>
|
45
|
+
<% if show_organization_tab? %>
|
46
|
+
<li><a href="#organizations" data-toggle="tab"><%= _("Organizations") %></a></li>
|
47
|
+
<% end %>
|
6
48
|
</ul>
|
7
49
|
|
8
50
|
<div class="tab-content">
|
9
51
|
<div class="tab-pane active" id="primary">
|
52
|
+
|
10
53
|
<%= text_f f, :name %>
|
11
54
|
<%= text_f f, :description %>
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
%>
|
16
|
-
|
17
|
-
|
55
|
+
<div id='ansible_playbook'>
|
56
|
+
<%= react_component('SyncGitRepo', :data => json,) %>
|
57
|
+
</div>
|
58
|
+
<%= text_f f, :playfile, :required => true %>
|
59
|
+
</div>
|
60
|
+
|
61
|
+
<%= render 'taxonomies/loc_org_tabs', :f => f, :obj => @ansible_playbook %>
|
18
62
|
</div>
|
19
|
-
|
20
63
|
<%= submit_or_cancel f %>
|
21
64
|
<% end %>
|
@@ -1,3 +1,11 @@
|
|
1
|
+
<%=
|
2
|
+
breadcrumbs(:resource_url => "/acd/api/v2/ansible_playbooks",
|
3
|
+
:items => [
|
4
|
+
{ :caption => _('Ansible Playbooks'),
|
5
|
+
:url => url_for(ansible_playbooks_path) },
|
6
|
+
{ :caption => "Edit #{@ansible_playbook.name}",
|
7
|
+
:url => (edit_ansible_playbook_path(@ansible_playbook) if authorized_for(hash_for_edit_ansible_playbook_path(@ansible_playbook))) }
|
8
|
+
])
|
9
|
+
%>
|
1
10
|
<% title(_('Edit Ansible Playbook %s') % @ansible_playbook) %>
|
2
|
-
|
3
11
|
<%= render :partial => 'form' %>
|
@@ -12,12 +12,12 @@
|
|
12
12
|
</tr>
|
13
13
|
<% for ansible_playbook in @ansible_playbooks %>
|
14
14
|
<tr>
|
15
|
-
<td><%=link_to_if_authorized h(ansible_playbook.name), hash_for_edit_ansible_playbook_path(:id => ansible_playbook)
|
15
|
+
<td><%=link_to_if_authorized h(ansible_playbook.name), hash_for_edit_ansible_playbook_path(:id => ansible_playbook) %></td>
|
16
16
|
<td><%= ansible_playbook.description %></td>
|
17
17
|
<td>
|
18
18
|
<%= action_buttons(
|
19
|
-
display_link_if_authorized(_("Import
|
20
|
-
display_delete_if_authorized(hash_for_ansible_playbook_path(:id => ansible_playbook)
|
19
|
+
display_link_if_authorized(_("Import groups"), hash_for_import_vars_ansible_playbook_path(:id => ansible_playbook)),
|
20
|
+
display_delete_if_authorized(hash_for_ansible_playbook_path(:id => ansible_playbook),
|
21
21
|
:data => { 'confirm': _('Delete %s?') % ansible_playbook.name })
|
22
22
|
) %>
|
23
23
|
</td>
|
@@ -30,6 +30,12 @@
|
|
30
30
|
<%= base_errors_for @app_definition %>
|
31
31
|
<ul class="nav nav-tabs" data-tabs="tabs">
|
32
32
|
<li class="active"><a href="#primary" data-toggle="tab"><%= _('Application Definitions') %></a></li>
|
33
|
+
<% if show_location_tab? %>
|
34
|
+
<li><a href="#locations" data-toggle="tab"><%= _("Locations") %></a></li>
|
35
|
+
<% end %>
|
36
|
+
<% if show_organization_tab? %>
|
37
|
+
<li><a href="#organizations" data-toggle="tab"><%= _("Organizations") %></a></li>
|
38
|
+
<% end %>
|
33
39
|
</ul>
|
34
40
|
|
35
41
|
<div class="tab-content">
|
@@ -38,8 +44,10 @@
|
|
38
44
|
<%= text_f f, :description %>
|
39
45
|
|
40
46
|
<div id='app_definition'></div>
|
41
|
-
<%=
|
47
|
+
<%= react_component('ApplicationDefinition', :data => json) %>
|
42
48
|
</div>
|
49
|
+
|
50
|
+
<%= render 'taxonomies/loc_org_tabs', :f => f, :obj => @app_definition %>
|
43
51
|
</div>
|
44
52
|
|
45
53
|
<%= submit_or_cancel f %>
|
@@ -1,10 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
<%=
|
2
|
+
breadcrumbs(:resource_url => "/acd/api/v2/app_definitions",
|
3
|
+
:items => [
|
4
|
+
{ :caption => _('App Definitions'),
|
5
|
+
:url => url_for(app_definitions_path) },
|
6
|
+
{ :caption => "Edit #{@app_definition.name}",
|
7
|
+
:url => (edit_app_definition_path(@app_definition) if authorized_for(hash_for_edit_app_definition_path(@app_definition))) }
|
8
|
+
])
|
6
9
|
%>
|
7
10
|
|
11
|
+
<% title(_('Edit Application Definition %s') % @app_definition) %>
|
12
|
+
|
8
13
|
<% content_for(:javascripts) do %>
|
9
14
|
<%= webpacked_plugins_js_for :foreman_acd %>
|
10
15
|
<% end %>
|
@@ -1,3 +1,22 @@
|
|
1
|
+
<%= javascript_include_tag *webpack_asset_paths('foreman_acd', extension: 'js') %>
|
2
|
+
<%
|
3
|
+
json = {
|
4
|
+
"organization": current_organization,
|
5
|
+
"location": current_location,
|
6
|
+
"hostgroups": @hostgroups,
|
7
|
+
"foremanDataUrl": ui_acd_foreman_data_path("__id__"),
|
8
|
+
"ansibleDataUrl": ui_acd_ansible_data_path("__id__"),
|
9
|
+
"services": [],
|
10
|
+
"ansibleVarsAll": [],
|
11
|
+
}
|
12
|
+
|
13
|
+
if @app_definition.new_record?
|
14
|
+
json["mode"] = "newDefinition"
|
15
|
+
else
|
16
|
+
json["mode"] = "editDefinition"
|
17
|
+
end
|
18
|
+
%>
|
19
|
+
|
1
20
|
<% title _('Import Application Definition') %>
|
2
21
|
|
3
22
|
<%= form_for @app_definition, :url => (app_definitions_path), :html => { :multipart => true } do |f| %>
|
@@ -10,7 +29,7 @@
|
|
10
29
|
<div class="tab-pane active" id="primary">
|
11
30
|
<%= text_f f, :name %>
|
12
31
|
<%= text_f f, :description %>
|
13
|
-
<%=
|
32
|
+
<%= react_component('ApplicationDefinitionImport', json,) %>
|
14
33
|
</div>
|
15
34
|
</div>
|
16
35
|
|
@@ -1,25 +1,22 @@
|
|
1
1
|
<% title _('Application Definitions') %>
|
2
2
|
|
3
|
-
<% title_actions
|
4
|
-
new_link(_('New Application Definition')),
|
5
|
-
display_link_if_authorized(_("Import"), hash_for_import_app_definitions_path, :class => 'btn btn-default')
|
6
|
-
) %>
|
3
|
+
<% title_actions new_link(_('New Application Definition')), display_link_if_authorized(_("Import"), hash_for_import_app_definitions_path, :class => 'btn btn-default') %>
|
7
4
|
|
8
5
|
<table class="table table-bordered table-striped">
|
9
6
|
<tr>
|
10
7
|
<th><%= sort :name, :as => s_('AppDefinition|Name') %></th>
|
11
8
|
<th><%= _('Description') %></th>
|
12
|
-
<th
|
9
|
+
<th><%= _('Actions') %></th>
|
13
10
|
</tr>
|
14
11
|
<% for app_definition in @app_definitions %>
|
15
12
|
<tr>
|
16
|
-
<td><%=link_to_if_authorized h(app_definition.name), hash_for_edit_app_definition_path(:id => app_definition)
|
13
|
+
<td><%=link_to_if_authorized h(app_definition.name), hash_for_edit_app_definition_path(:id => app_definition) %></td>
|
17
14
|
<td><%= app_definition.description %></td>
|
18
15
|
<td>
|
19
16
|
<%= action_buttons(
|
20
|
-
display_delete_if_authorized(hash_for_app_definition_path(:id => app_definition)
|
17
|
+
display_delete_if_authorized(hash_for_app_definition_path(:id => app_definition),
|
21
18
|
:data => { 'confirm': _('Delete %s?') % app_definition.name }),
|
22
|
-
display_link_if_authorized(_("Export"), hash_for_export_app_definition_path(:id => app_definition)
|
19
|
+
display_link_if_authorized(_("Export"), hash_for_export_app_definition_path(:id => app_definition))
|
23
20
|
) %>
|
24
21
|
</td>
|
25
22
|
</tr>
|
@@ -20,7 +20,7 @@
|
|
20
20
|
"id": @app_instance.app_definition.id,
|
21
21
|
"name": @app_instance.app_definition.name,
|
22
22
|
},
|
23
|
-
"hosts":
|
23
|
+
"hosts": collect_hosts_data,
|
24
24
|
"ansibleVarsAll": @app_instance.ansible_vars_all.blank? ? [] : JSON.parse(@app_instance.ansible_vars_all),
|
25
25
|
}
|
26
26
|
end
|
@@ -38,11 +38,11 @@
|
|
38
38
|
<%= text_f f, :description %>
|
39
39
|
|
40
40
|
<div id='app_instance'></div>
|
41
|
-
<%=
|
41
|
+
<%= react_component('ApplicationInstance', :data => json) %>
|
42
42
|
</div>
|
43
43
|
</div>
|
44
44
|
</div>
|
45
|
-
|
45
|
+
<%= f.hidden_field :organization_id %>
|
46
|
+
<%= f.hidden_field :location_id %>
|
46
47
|
<%= submit_or_cancel f %>
|
47
48
|
<% end %>
|
48
|
-
|
@@ -1,3 +1,13 @@
|
|
1
|
+
<%=
|
2
|
+
breadcrumbs(:resource_url => "/acd/api/v2/app_instances?location_id=#{@location.id}&organization_id=#{@organization.id}",
|
3
|
+
:items => [
|
4
|
+
{ :caption => _('App Instances'),
|
5
|
+
:url => url_for(app_instances_path) },
|
6
|
+
{ :caption => "Edit #{@app_instance.name}",
|
7
|
+
:url => (edit_app_instance_path(@app_instance) if authorized_for(hash_for_edit_app_instance_path(@app_instance))) }
|
8
|
+
])
|
9
|
+
%>
|
10
|
+
|
1
11
|
<% title(_('Edit Application Instance %s') % @app_instance) %>
|
2
12
|
|
3
13
|
<% content_for(:javascripts) do %>
|
@@ -7,29 +7,108 @@
|
|
7
7
|
<th><%= sort :name, :as => s_('AppInstance|Name') %></th>
|
8
8
|
<th><%= sort :application, :as => _('Application'), :default => 'DESC' %></th>
|
9
9
|
<th><%= _('Description') %></th>
|
10
|
+
<th><%= _('Report') %></th>
|
10
11
|
<th></th>
|
11
12
|
</tr>
|
12
13
|
<% for app_instance in @app_instances %>
|
13
14
|
<tr>
|
14
|
-
<td><%=link_to_if_authorized h(app_instance.name), hash_for_edit_app_instance_path(:id => app_instance)
|
15
|
+
<td><%=link_to_if_authorized h(app_instance.name), hash_for_edit_app_instance_path(:id => app_instance) %></td>
|
15
16
|
<td><%= app_instance.app_definition %></td>
|
16
17
|
<td><%= app_instance.description %></td>
|
18
|
+
<td><%= link_to_if((authorized_for(:auth_object => app_instance, :authorizer => authorizer, :permission => :report_app_instances) &&
|
19
|
+
!app_instance.last_deploy_task.nil? && app_instance.last_deploy_task.ended_at?),
|
20
|
+
_("Show Report"),
|
21
|
+
hash_for_report_app_instance_path(:id => app_instance),
|
22
|
+
:method => :get, :title => _("Show last deployment report for application #{app_instance}")) %></td>
|
17
23
|
<td>
|
18
|
-
<%= action_buttons(
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
<%= action_buttons(
|
25
|
+
display_link_if_authorized(_("Deploy"), { :use_route=>"#",
|
26
|
+
:id => app_instance.id,
|
27
|
+
:action => :deploy,
|
28
|
+
:auth_object => app_instance,
|
29
|
+
:controller => :app_instances },
|
30
|
+
:remote => true, 'data-toggle': "modal", 'data-target': "#deploy#{app_instance.id}",
|
31
|
+
:title => _("Deploy application #{app_instance}")),
|
32
|
+
display_link_if_authorized(_("Run Playbook"),
|
33
|
+
hash_for_remote_execution_path(:id => app_instance.id),
|
34
|
+
:method => :post,
|
35
|
+
:title => _("Run ansible playbook for application #{app_instance}")),
|
36
|
+
display_link_if_authorized(_("Run Playbook - customize first"),
|
37
|
+
hash_for_remote_execution_path(:id => app_instance.id, :customize => true),
|
38
|
+
:method => :post,
|
39
|
+
:title => _("Prepare job to run ansible playbook for application #{app_instance}")),
|
40
|
+
display_link_if_authorized(_("Delete"), { :use_route=>"#",
|
41
|
+
:id => app_instance.id,
|
42
|
+
:action => :destroy,
|
43
|
+
:auth_object => app_instance,
|
44
|
+
:controller => :app_instances },
|
45
|
+
:remote => true, 'data-toggle': "modal", 'data-target': "#delete#{app_instance.id}",
|
46
|
+
:title => _("Delete application #{app_instance}"))
|
47
|
+
) %>
|
48
|
+
</td>
|
29
49
|
</tr>
|
50
|
+
<!-- Delete Modal -->
|
51
|
+
<div class="modal fade" id="delete<%=app_instance.id%>" tabindex="-1" role="dialog" aria-labelledby="deleteLabel" aria-hidden="true">
|
52
|
+
<div class="modal-dialog">
|
53
|
+
<div class="modal-content">
|
54
|
+
<div class="modal-header">
|
55
|
+
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
56
|
+
<h4 class="modal-title"><%= _('Confirmation')%></h4>
|
57
|
+
</div>
|
58
|
+
<div class="modal-body">
|
59
|
+
<p> <%= _("Confirm to delete application instance: ") %> <%= app_instance %></p>
|
60
|
+
<%= form_tag destroy_with_hosts_app_instance_path(:id => app_instance.id), :method => :delete do %>
|
61
|
+
<% showSelectHostsNote = true %>
|
62
|
+
<% app_instance.foreman_hosts.select(&:fresh_host?).each do |foreman_host|%>
|
63
|
+
<% if foreman_host.host_id? %>
|
64
|
+
<% if showSelectHostsNote %>
|
65
|
+
<p><%= _("Select the hosts to delete along with ") %> <%= app_instance %>: </p>
|
66
|
+
<% showSelectHostsNote = false %>
|
67
|
+
<% end %>
|
68
|
+
<%= check_box_tag 'foreman_host_ids[]', foreman_host.host_id, false, class: 'acd_host' -%> <%= h foreman_host.host.name -%>
|
69
|
+
</br>
|
70
|
+
<% end %>
|
71
|
+
<% end %>
|
72
|
+
<hr width="90%">
|
73
|
+
<p> <%= check_box_tag "check_all", "", false, { :onchange => "toggleCheckboxesBySelector('.acd_host')" } %> Select / unselect all hosts</p>
|
74
|
+
<br /><p><%= _("Note: Hosts which already existed and were added to the application instance are not shown in this dialog!") %></p>
|
75
|
+
</div>
|
76
|
+
<div class="modal-footer">
|
77
|
+
<button type="button" class="btn btn-primary" data-dismiss="modal"><%= _('Cancel') %></button>
|
78
|
+
<%= submit_tag _("Delete"), name: nil, class: "btn btn-danger" %>
|
79
|
+
<% end %>
|
80
|
+
</div>
|
81
|
+
</div><!-- /.modal-content -->
|
82
|
+
</div><!-- /.modal-dialog -->
|
83
|
+
</div><!-- /.modal -->
|
84
|
+
|
85
|
+
<!-- Deploy Modal -->
|
86
|
+
<div class="modal fade" id="deploy<%=app_instance.id%>" tabindex="-1" role="dialog" aria-labelledby="deployLabel" aria-hidden="true">
|
87
|
+
<div class="modal-dialog">
|
88
|
+
<div class="modal-content">
|
89
|
+
<div class="modal-header">
|
90
|
+
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
91
|
+
<h4 class="modal-title"><%= _('Confirmation Box') %></h4>
|
92
|
+
</div>
|
93
|
+
<div class="modal-body">
|
94
|
+
<p><%= _('Confirm to deploy ') %><%= app_instance%></p>
|
95
|
+
<%= form_tag deploy_app_instance_path(:id => app_instance.id), :method => :post do %>
|
96
|
+
<% if app_instance.foreman_hosts.where.not(:host_id => [nil, false]).any? %>
|
97
|
+
<ul>
|
98
|
+
<li><%= check_box_tag 'delete_hosts'-%> <%= _('Delete all hosts before deploying ') %><%= app_instance%></li>
|
99
|
+
<li><%= check_box_tag 'safe_deploy' -%> <%= _('Deploy only new and changed hosts for ') %><%= app_instance%></li>
|
100
|
+
</ul>
|
101
|
+
<% end %>
|
102
|
+
</div>
|
103
|
+
<div class="modal-footer">
|
104
|
+
<button type="button" class="btn btn-danger" data-dismiss="modal"><%= _('Cancel') %></button>
|
105
|
+
<%= submit_tag _("Submit"), name: nil, class: "btn btn-success" %>
|
106
|
+
<% end %>
|
107
|
+
</div>
|
108
|
+
</div><!-- /.modal-content -->
|
109
|
+
</div><!-- /.modal-dialog -->
|
110
|
+
</div><!-- /.modal -->
|
30
111
|
<% end %>
|
31
112
|
</table>
|
32
|
-
|
33
113
|
<%= page_entries_info @app_instances %>
|
34
114
|
<%= will_paginate @app_instances %>
|
35
|
-
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<% title _("
|
1
|
+
<% title _("Provisioning details for application instance #{@app_instance}") %>
|
2
2
|
|
3
3
|
<% content_for(:javascripts) do %>
|
4
4
|
<%= webpacked_plugins_js_for :foreman_acd %>
|
@@ -9,11 +9,19 @@
|
|
9
9
|
|
10
10
|
<%
|
11
11
|
json = {
|
12
|
-
"
|
13
|
-
"
|
12
|
+
"deploymentState": @app_instance.deployment_state.to_s,
|
13
|
+
"initialConfigureState": @app_instance.initial_configure_state.to_s,
|
14
|
+
"appInstanceName": @app_instance.name,
|
15
|
+
"hosts": @report_hosts,
|
16
|
+
"deployTaskUrl": foreman_tasks_task_path(@app_instance.last_deploy_task),
|
17
|
+
"configureJobUrl": job_invocations_path(search: "description ~ \"ACD application #{@app_instance.name}\""),
|
18
|
+
"reportDataUrl": ui_acd_report_data_path("__id__"),
|
19
|
+
"appInstanceId": @app_instance.id,
|
14
20
|
}
|
21
|
+
|
22
|
+
json["initialConfigureJobUrl"] = job_invocation_path(@app_instance.initial_configure_job) unless @app_instance.initial_configure_job.nil?
|
15
23
|
%>
|
16
24
|
|
17
25
|
<div id='report'></div>
|
18
|
-
<%=
|
26
|
+
<%= react_component('ApplicationInstanceReport', :data => json) %>
|
19
27
|
</div
|