foreman_acd 0.0.5 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +82 -27
- data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +122 -0
- data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +71 -0
- data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -2
- data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +54 -0
- data/app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb +0 -0
- data/app/controllers/foreman_acd/app_definitions_controller.rb +36 -4
- data/app/controllers/foreman_acd/app_instances_controller.rb +24 -90
- 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 +49 -0
- data/app/controllers/ui_acd_controller.rb +11 -4
- data/app/models/foreman_acd/acd_provider.rb +27 -0
- data/app/models/foreman_acd/ansible_playbook.rb +50 -0
- data/app/models/foreman_acd/app_definition.rb +2 -1
- data/app/models/foreman_acd/app_instance.rb +7 -0
- data/app/services/foreman_acd/app_configurator.rb +57 -0
- data/app/services/foreman_acd/app_deployer.rb +139 -0
- data/app/services/foreman_acd/inventory_creator.rb +67 -0
- data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +21 -0
- data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +3 -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 +3 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +3 -0
- data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +3 -0
- data/app/views/foreman_acd/app_definitions/_form.html.erb +25 -19
- data/app/views/foreman_acd/app_definitions/edit.html.erb +5 -0
- data/app/views/foreman_acd/app_definitions/import.html.erb +18 -0
- data/app/views/foreman_acd/app_definitions/index.html.erb +9 -5
- data/app/views/foreman_acd/app_instances/_form.html.erb +10 -8
- data/app/views/foreman_acd/app_instances/deploy.html.erb +19 -0
- data/app/views/foreman_acd/app_instances/index.html.erb +10 -5
- data/app/views/foreman_acd/app_instances/report.html.erb +19 -0
- data/app/views/templates/job/run_acd_ansible_playbook.erb +49 -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 +36 -1
- data/db/migrate/20190610202252_create_app_definitions.rb +1 -3
- data/db/migrate/20190625140305_create_app_instances.rb +1 -1
- 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 +5 -0
- data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +5 -0
- data/db/seeds.d/62_acd_proxy_feature.rb +6 -0
- data/db/seeds.d/75-job_templates.rb +8 -0
- data/lib/foreman_acd/engine.rb +7 -0
- data/lib/foreman_acd/plugin.rb +84 -13
- data/lib/foreman_acd/version.rb +1 -1
- data/package.json +1 -2
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +378 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinition.scss +1 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +295 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +14 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +243 -0
- data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +8 -0
- data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +49 -0
- data/webpack/components/ApplicationDefinition/index.js +33 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.js +414 -0
- data/webpack/components/ApplicationInstance/ApplicationInstance.scss +11 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +239 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +14 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +295 -0
- data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +9 -0
- data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +49 -0
- data/webpack/components/ApplicationInstance/components/Service.js +30 -0
- data/webpack/components/ApplicationInstance/components/ServiceCounter.js +37 -0
- data/webpack/components/ApplicationInstance/index.js +35 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +155 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +27 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +86 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +4 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +52 -0
- data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +5 -0
- data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +26 -0
- data/webpack/components/ApplicationInstanceReport/index.js +27 -0
- data/webpack/components/ParameterSelection/ParameterSelection.js +121 -192
- data/webpack/components/ParameterSelection/ParameterSelection.scss +9 -0
- data/webpack/components/ParameterSelection/ParameterSelectionActions.js +80 -104
- data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +15 -19
- data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +3 -35
- data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +116 -84
- data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +3 -7
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +12 -21
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +1 -1
- data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +3 -45
- data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +20 -0
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +22 -46
- data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +40 -265
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +11 -96
- data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +3 -9
- data/webpack/components/ParameterSelection/index.js +6 -8
- data/webpack/components/common/AddTableEntry.js +30 -0
- data/webpack/components/common/DeleteTableEntry.js +38 -0
- data/webpack/components/common/EasyHeaderFormatter.js +18 -0
- data/webpack/components/common/EditTableEntry.js +49 -0
- data/webpack/components/common/ExtSelect.js +43 -0
- data/webpack/components/common/LockTableEntry.js +59 -0
- data/webpack/components/common/RailsData.js +27 -0
- data/webpack/components/common/__tests__/AddTableEntry.test.js +26 -0
- data/webpack/components/common/__tests__/DeleteTableEntry.test.js +29 -0
- data/webpack/components/common/__tests__/ExtSelect.test.js +38 -0
- data/webpack/components/common/__tests__/RailsData.test.js +16 -0
- data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +35 -0
- data/webpack/components/common/__tests__/__snapshots__/AddTableEntry.test.js.snap +35 -0
- data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +41 -0
- data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +41 -0
- data/webpack/components/common/__tests__/__snapshots__/ExtSelect.test.js.snap +18 -0
- data/webpack/components/common/__tests__/__snapshots__/RailsData.test.js.snap +10 -0
- data/webpack/helper.js +20 -0
- data/webpack/index.js +6 -0
- data/webpack/reducer.js +43 -3
- metadata +91 -39
@@ -0,0 +1,139 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ForemanAcd
|
4
|
+
# application instances deployer
|
5
|
+
class AppDeployer
|
6
|
+
|
7
|
+
delegate :logger, :to => :Rails
|
8
|
+
|
9
|
+
def initialize(app_instance)
|
10
|
+
@app_instance = app_instance
|
11
|
+
end
|
12
|
+
|
13
|
+
def deploy
|
14
|
+
services = JSON.parse(@app_instance.app_definition.services)
|
15
|
+
app_hosts = JSON.parse(@app_instance.hosts)
|
16
|
+
|
17
|
+
app_hosts.each do |host_data|
|
18
|
+
begin
|
19
|
+
service_data = services.select { |k| k['id'] == host_data['service'].to_i }.first
|
20
|
+
host_params = set_host_params(host_data, service_data)
|
21
|
+
|
22
|
+
host = nil
|
23
|
+
if host_data.has_key?('foreman_host_id')
|
24
|
+
logger.debug("Try to find host with id #{host_data['foreman_host_id']}")
|
25
|
+
begin
|
26
|
+
host = Host.find(host_data['foreman_host_id'])
|
27
|
+
rescue ActiveRecord::RecordNotFound
|
28
|
+
logger.info("Host with id #{host_data['foreman_host_id']} couldn\'t be found, create a new one!")
|
29
|
+
host = nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
if host.nil?
|
34
|
+
params = host_attributes(host_params)
|
35
|
+
logger.info("Host creation parameters for #{host_data['hostname']}:\n#{params}\n")
|
36
|
+
host = Host.new(params)
|
37
|
+
else
|
38
|
+
logger.info("Update parameters and re-deploy host #{host_data['hostname']}")
|
39
|
+
host.attributes = host_attributes(host_params, host)
|
40
|
+
host.setBuild
|
41
|
+
host.power.reset
|
42
|
+
end
|
43
|
+
|
44
|
+
# REMOVE ME (but very nice for testing)
|
45
|
+
# host.mac = "00:11:22:33:44:55"
|
46
|
+
|
47
|
+
apply_compute_profile(host)
|
48
|
+
host.suggest_default_pxe_loader
|
49
|
+
host.save
|
50
|
+
|
51
|
+
# save the foreman host id
|
52
|
+
host_data['foreman_host_id'] = host.id
|
53
|
+
rescue StandardError => e
|
54
|
+
logger.error("Failed to initiate host creation: #{e.class}: #{e.message}\n#{e.backtrace.join($INPUT_RECORD_SEPARATOR)}")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
return app_hosts
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
# Copied from foreman/app/controllers/api/v2/hosts_controller.rb
|
64
|
+
def apply_compute_profile(host)
|
65
|
+
host.apply_compute_profile(InterfaceMerge.new(:merge_compute_attributes => true))
|
66
|
+
host.apply_compute_profile(ComputeAttributeMerge.new)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Copied from foreman/app/controllers/api/v2/hosts_controller.rb
|
70
|
+
def host_attributes(params, host = nil)
|
71
|
+
return {} if params.nil?
|
72
|
+
|
73
|
+
params = params.deep_clone
|
74
|
+
if params[:interfaces_attributes]
|
75
|
+
# handle both hash and array styles of nested attributes
|
76
|
+
params[:interfaces_attributes] = params[:interfaces_attributes].values if params[:interfaces_attributes].is_a?(Hash) || params[:interfaces_attributes].is_a?(ActionController::Parameters)
|
77
|
+
# map interface types
|
78
|
+
params[:interfaces_attributes] = params[:interfaces_attributes].map do |nic_attr|
|
79
|
+
interface_attributes(nic_attr, :allow_nil_type => host.nil?)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
params = host.apply_inherited_attributes(params) if host
|
83
|
+
params
|
84
|
+
end
|
85
|
+
|
86
|
+
# Copied from foreman/app/controllers/api/v2/hosts_controller.rb
|
87
|
+
def interface_attributes(params, allow_nil_type: false)
|
88
|
+
params[:type] = InterfaceTypeMapper.map(params[:type]) if params.key?(:type) || allow_nil_type
|
89
|
+
params
|
90
|
+
end
|
91
|
+
|
92
|
+
def hardcoded_params
|
93
|
+
result = {}
|
94
|
+
result['managed'] = true
|
95
|
+
result['enabled'] = true
|
96
|
+
result['build'] = true
|
97
|
+
result['compute_attributes'] = { 'start' => '1' }
|
98
|
+
result['host_parameters_attributes'] = []
|
99
|
+
result
|
100
|
+
end
|
101
|
+
|
102
|
+
def set_host_params(host_data, service_data)
|
103
|
+
result = hardcoded_params
|
104
|
+
result['name'] = host_data['hostname']
|
105
|
+
result['hostgroup_id'] = service_data['hostgroup']
|
106
|
+
|
107
|
+
host_data['foremanParameters'].each do |param|
|
108
|
+
case param['type']
|
109
|
+
|
110
|
+
when 'computeprofile'
|
111
|
+
result['compute_profile_id'] = param['value']
|
112
|
+
|
113
|
+
when 'domain'
|
114
|
+
result['domain_id'] = param['value']
|
115
|
+
|
116
|
+
when 'hostparam'
|
117
|
+
result['host_parameters_attributes'].push(:name => param['name'], :value => param['value'])
|
118
|
+
|
119
|
+
when 'ip'
|
120
|
+
result['ip'] = param['value']
|
121
|
+
|
122
|
+
when 'lifecycleenv'
|
123
|
+
result['content_facet_attributes'] = { 'lifecycle_environment_id' => param['value'] }
|
124
|
+
|
125
|
+
when 'ptable'
|
126
|
+
result['ptable_id'] = param['value']
|
127
|
+
|
128
|
+
when 'puppetenv'
|
129
|
+
result['environment_id'] = param['value']
|
130
|
+
|
131
|
+
when 'password'
|
132
|
+
result['root_pass'] = param['value']
|
133
|
+
|
134
|
+
end
|
135
|
+
end
|
136
|
+
result
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ForemanAcd
|
4
|
+
# inventory creator for application instances
|
5
|
+
class InventoryCreator
|
6
|
+
|
7
|
+
delegate :logger, :to => :Rails
|
8
|
+
|
9
|
+
def initialize(app_instance, host_ids)
|
10
|
+
@app_instance = app_instance
|
11
|
+
@host_ids = host_ids
|
12
|
+
end
|
13
|
+
|
14
|
+
# TODO: this might be part of the smart proxy plugin.
|
15
|
+
def create_inventory
|
16
|
+
inventory = {}
|
17
|
+
inventory['all'] = {}
|
18
|
+
|
19
|
+
inventory['all'] = { 'vars' => inventory_all_vars } unless @app_instance.ansible_vars_all.nil? || @app_instance.ansible_vars_all.empty?
|
20
|
+
|
21
|
+
services = JSON.parse(@app_instance.app_definition.services)
|
22
|
+
app_hosts = filtered_hosts
|
23
|
+
|
24
|
+
children = {}
|
25
|
+
app_hosts.each do |host_data|
|
26
|
+
if host_data['foreman_host_id'].nil?
|
27
|
+
logger.warn "Ignore host #{host_data['hostname']} because no foreman host id could be found. Is the host not provisioned yet?"
|
28
|
+
next
|
29
|
+
end
|
30
|
+
|
31
|
+
service_id = host_data['service'].to_i
|
32
|
+
host_service = services.select { |s| s['id'] == service_id }.first
|
33
|
+
ansible_group = host_service['ansibleGroup']
|
34
|
+
|
35
|
+
unless children.has_key?(host_service['ansibleGroup'])
|
36
|
+
children[ansible_group] = { 'hosts' => {} }
|
37
|
+
end
|
38
|
+
|
39
|
+
ansible_vars = host_data['ansibleParameters'].map { |v| { v['name'] => v['value'] } }.reduce({}, :merge!)
|
40
|
+
|
41
|
+
# in case there is no ansible_user defined, set "root" as default.
|
42
|
+
unless ansible_vars.has_key?('ansible_user')
|
43
|
+
ansible_vars['ansible_user'] = 'root'
|
44
|
+
end
|
45
|
+
|
46
|
+
children[ansible_group]['hosts'][get_fqdn(host_data['foreman_host_id'])] = ansible_vars
|
47
|
+
end
|
48
|
+
inventory['all']['children'] = children
|
49
|
+
inventory
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
def inventory_all_vars
|
54
|
+
JSON.parse(@app_instance.ansible_vars_all).map do |a|
|
55
|
+
{ a['name'] => a['value'] }
|
56
|
+
end.reduce({}, :merge!)
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_fqdn(host_id)
|
60
|
+
Host.find(host_id)&.name
|
61
|
+
end
|
62
|
+
|
63
|
+
def filtered_hosts
|
64
|
+
JSON.parse(@app_instance.hosts).select{ |h| h&.key?('foreman_host_id') && @host_ids.include?(h['foreman_host_id']) }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%= form_for @ansible_playbook, :url => (@ansible_playbook.new_record? ? ansible_playbooks_path : ansible_playbook_path(:id => @ansible_playbook.id)) do |f| %>
|
2
|
+
<%= base_errors_for @ansible_playbook %>
|
3
|
+
|
4
|
+
<ul class="nav nav-tabs" data-tabs="tabs">
|
5
|
+
<li class="active"><a href="#primary" data-toggle="tab"><%= _('Ansible playbooks') %></a></li>
|
6
|
+
</ul>
|
7
|
+
|
8
|
+
<div class="tab-content">
|
9
|
+
<div class="tab-pane active" id="primary">
|
10
|
+
<%= text_f f, :name %>
|
11
|
+
<%= text_f f, :description %>
|
12
|
+
<%= f.hidden_field :scm_type, :value => 'directory' %>
|
13
|
+
<% # TODO:
|
14
|
+
# select_f(f, :scm_type, %w[Directory GIT], :downcase, :to_s)
|
15
|
+
%>
|
16
|
+
<%= text_f f, :path %>
|
17
|
+
<%= text_f f, :playfile %>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
<%= submit_or_cancel f %>
|
21
|
+
<% end %>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<% title _('Ansible Playbooks') %>
|
2
|
+
|
3
|
+
<% title_actions button_group(
|
4
|
+
new_link(_('New Ansible Playbook')),
|
5
|
+
) %>
|
6
|
+
|
7
|
+
<table class="table table-bordered table-striped">
|
8
|
+
<tr>
|
9
|
+
<th><%= sort :name, :as => s_('AnsiblePlaybook|Name') %></th>
|
10
|
+
<th><%= _('Description') %></th>
|
11
|
+
<th></th>
|
12
|
+
</tr>
|
13
|
+
<% for ansible_playbook in @ansible_playbooks %>
|
14
|
+
<tr>
|
15
|
+
<td><%=link_to_if_authorized h(ansible_playbook.name), hash_for_edit_ansible_playbook_path(:id => ansible_playbook).merge(:auth_object => ansible_playbook, :authorizer => authorizer) %></td>
|
16
|
+
<td><%= ansible_playbook.description %></td>
|
17
|
+
<td>
|
18
|
+
<%= action_buttons(
|
19
|
+
display_link_if_authorized(_("Import group variables"), hash_for_import_vars_ansible_playbook_path(:id => ansible_playbook).merge(:auth_object => ansible_playbook, :authorizer => authorizer)),
|
20
|
+
display_delete_if_authorized(hash_for_ansible_playbook_path(:id => ansible_playbook).merge(:auth_object => ansible_playbook, :authorizer => authorizer),
|
21
|
+
:data => { 'confirm': _('Delete %s?') % ansible_playbook.name })
|
22
|
+
) %>
|
23
|
+
</td>
|
24
|
+
</tr>
|
25
|
+
<% end %>
|
26
|
+
</table>
|
27
|
+
|
28
|
+
<%= page_entries_info @ansible_playbooks %>
|
29
|
+
<%= will_paginate @ansible_playbooks %>
|
30
|
+
|
@@ -1,23 +1,29 @@
|
|
1
1
|
<%
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
json = {
|
3
|
+
"organization": current_organization,
|
4
|
+
"location": current_location,
|
5
|
+
"hostgroups": @hostgroups,
|
6
|
+
"foremanDataUrl": ui_acd_foreman_data_path("__id__"),
|
7
|
+
"ansibleDataUrl": ui_acd_ansible_data_path("__id__"),
|
8
|
+
"services": [],
|
9
|
+
"ansibleVarsAll": [],
|
10
|
+
}
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
"hostgroup_id": @app_definition.hostgroup_id,
|
17
|
-
}
|
18
|
-
json["parameters"] = JSON.parse(@app_definition.parameters)
|
19
|
-
end
|
12
|
+
if @app_definition.new_record?
|
13
|
+
json["mode"] = "newDefinition"
|
14
|
+
json["ansiblePlaybooks"] = @ansible_playbooks
|
15
|
+
else
|
16
|
+
json["mode"] = "editDefinition"
|
17
|
+
json["ansiblePlaybook"] = @app_definition.ansible_playbook.as_unified_structobj
|
18
|
+
end
|
20
19
|
|
20
|
+
if @app_definition.services.present?
|
21
|
+
json["services"] = JSON.parse(@app_definition.services)
|
22
|
+
end
|
23
|
+
|
24
|
+
if @app_definition.ansible_vars_all.present?
|
25
|
+
json["ansibleVarsAll"] = JSON.parse(@app_definition.ansible_vars_all)
|
26
|
+
end
|
21
27
|
%>
|
22
28
|
|
23
29
|
<%= form_for @app_definition, :url => (@app_definition.new_record? ? app_definitions_path : app_definition_path(:id => @app_definition.id)) do |f| %>
|
@@ -31,8 +37,8 @@
|
|
31
37
|
<%= text_f f, :name %>
|
32
38
|
<%= text_f f, :description %>
|
33
39
|
|
34
|
-
<div id='
|
35
|
-
<%= mount_react_component('
|
40
|
+
<div id='app_definition'></div>
|
41
|
+
<%= mount_react_component('ApplicationDefinition', "#app_definition", json.to_json) %>
|
36
42
|
</div>
|
37
43
|
</div>
|
38
44
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<% title _('Import Application Definition') %>
|
2
|
+
|
3
|
+
<%= form_for @app_definition, :url => (app_definitions_path), :html => { :multipart => true } do |f| %>
|
4
|
+
<%= base_errors_for @app_definition %>
|
5
|
+
<ul class="nav nav-tabs" data-tabs="tabs">
|
6
|
+
<li class="active"><a href="#primary" data-toggle="tab"><%= _('Application Definitions') %></a></li>
|
7
|
+
</ul>
|
8
|
+
|
9
|
+
<div class="tab-content">
|
10
|
+
<div class="tab-pane active" id="primary">
|
11
|
+
<%= text_f f, :name %>
|
12
|
+
<%= text_f f, :description %>
|
13
|
+
<%= file_field_f f, :app_definition_file, :label_help => _("Application Definition file") %>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<%= submit_or_cancel f %>
|
18
|
+
<% end %>
|
@@ -1,22 +1,26 @@
|
|
1
1
|
<% title _('Application Definitions') %>
|
2
2
|
|
3
|
-
<% title_actions button_group(
|
3
|
+
<% title_actions button_group(
|
4
|
+
new_link(_('New Application Definition')),
|
5
|
+
display_link_if_authorized(_("Import"), hash_for_import_app_definitions_path, :class => 'btn btn-default')
|
6
|
+
) %>
|
4
7
|
|
5
8
|
<table class="table table-bordered table-striped">
|
6
9
|
<tr>
|
7
10
|
<th><%= sort :name, :as => s_('AppDefinition|Name') %></th>
|
8
11
|
<th><%= _('Description') %></th>
|
9
|
-
<th><%= sort :hostgroup, :as => _('Host groups'), :default => 'DESC' %></th>
|
10
12
|
<th></th>
|
11
13
|
</tr>
|
12
14
|
<% for app_definition in @app_definitions %>
|
13
15
|
<tr>
|
14
16
|
<td><%=link_to_if_authorized h(app_definition.name), hash_for_edit_app_definition_path(:id => app_definition).merge(:auth_object => app_definition, :authorizer => authorizer) %></td>
|
15
17
|
<td><%= app_definition.description %></td>
|
16
|
-
<td><%= app_definition.hostgroup %></td>
|
17
18
|
<td>
|
18
|
-
|
19
|
-
|
19
|
+
<%= action_buttons(
|
20
|
+
display_delete_if_authorized(hash_for_app_definition_path(:id => app_definition).merge(:auth_object => app_definition, :authorizer => authorizer),
|
21
|
+
:data => { 'confirm': _('Delete %s?') % app_definition.name }),
|
22
|
+
display_link_if_authorized(_("Export"), hash_for_export_app_definition_path(:id => app_definition).merge(:auth_object => app_definition, :authorizer => authorizer))
|
23
|
+
) %>
|
20
24
|
</td>
|
21
25
|
</tr>
|
22
26
|
<% end %>
|
@@ -1,25 +1,27 @@
|
|
1
1
|
<%
|
2
|
-
if @app_instance.
|
2
|
+
if @app_instance.new_record?
|
3
3
|
json = {
|
4
4
|
"mode": "newInstance",
|
5
5
|
"organization": current_organization,
|
6
6
|
"location": current_location,
|
7
7
|
"applications": @applications,
|
8
|
-
"
|
9
|
-
"
|
8
|
+
"appDefinitionUrl": ui_acd_app_path("__id__"),
|
9
|
+
"foremanDataUrl": ui_acd_foreman_data_path("__id__"),
|
10
|
+
"ansibleVarsAll": [],
|
10
11
|
}
|
11
12
|
else
|
12
13
|
json = {
|
13
14
|
"mode": "editInstance",
|
14
15
|
"organization": current_organization,
|
15
16
|
"location": current_location,
|
16
|
-
"
|
17
|
+
"appDefinitionUrl": ui_acd_app_path("__id__"),
|
18
|
+
"foremanDataUrl": ui_acd_foreman_data_path("__id__"),
|
17
19
|
"appDefinition": {
|
18
20
|
"id": @app_instance.app_definition.id,
|
19
21
|
"name": @app_instance.app_definition.name,
|
20
|
-
"hostgroup_id": @app_instance.app_definition.hostgroup_id,
|
21
22
|
},
|
22
|
-
"
|
23
|
+
"hosts": JSON.parse(@app_instance.hosts),
|
24
|
+
"ansibleVarsAll": @app_instance.ansible_vars_all.blank? ? [] : JSON.parse(@app_instance.ansible_vars_all),
|
23
25
|
}
|
24
26
|
end
|
25
27
|
%>
|
@@ -35,8 +37,8 @@
|
|
35
37
|
<%= text_f f, :name %>
|
36
38
|
<%= text_f f, :description %>
|
37
39
|
|
38
|
-
<div id='
|
39
|
-
<%= mount_react_component('
|
40
|
+
<div id='app_instance'></div>
|
41
|
+
<%= mount_react_component('ApplicationInstance', "#app_instance", json.to_json) %>
|
40
42
|
</div>
|
41
43
|
</div>
|
42
44
|
</div>
|