foreman_acd 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +122 -0
  3. data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +54 -0
  4. data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +54 -0
  5. data/app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb +0 -0
  6. data/app/controllers/foreman_acd/app_definitions_controller.rb +7 -4
  7. data/app/controllers/foreman_acd/app_instances_controller.rb +33 -126
  8. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +23 -0
  9. data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
  10. data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
  11. data/app/controllers/ui_acd_controller.rb +11 -3
  12. data/app/models/foreman_acd/ansible_playbook.rb +50 -0
  13. data/app/models/foreman_acd/app_definition.rb +2 -0
  14. data/app/models/foreman_acd/app_instance.rb +7 -0
  15. data/app/services/foreman_acd/app_configurator.rb +70 -0
  16. data/app/services/foreman_acd/app_deployer.rb +143 -0
  17. data/app/services/foreman_acd/inventory_creator.rb +67 -0
  18. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +21 -0
  19. data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +3 -0
  20. data/app/views/foreman_acd/ansible_playbooks/index.html.erb +30 -0
  21. data/app/views/foreman_acd/ansible_playbooks/new.html.erb +3 -0
  22. data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +3 -0
  23. data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +3 -0
  24. data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +3 -0
  25. data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +3 -0
  26. data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +3 -0
  27. data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +3 -0
  28. data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -0
  29. data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +3 -0
  30. data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +3 -0
  31. data/app/views/foreman_acd/app_definitions/_form.html.erb +24 -10
  32. data/app/views/foreman_acd/app_definitions/edit.html.erb +5 -0
  33. data/app/views/foreman_acd/app_instances/_form.html.erb +7 -5
  34. data/app/views/foreman_acd/app_instances/index.html.erb +5 -1
  35. data/app/views/templates/job/run_acd_ansible_playbook.erb +49 -0
  36. data/app/views/ui_acd/ansible_data.json.rabl +6 -0
  37. data/app/views/ui_acd/app.json.rabl +6 -2
  38. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  39. data/app/views/ui_acd/{fdata.json.rabl → foreman_data.json.rabl} +1 -1
  40. data/config/routes.rb +24 -1
  41. data/db/migrate/20200916091018_create_ansible_playbooks.rb +20 -0
  42. data/db/migrate/20200917120220_add_ansible_playbook_id.rb +14 -0
  43. data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +5 -0
  44. data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +5 -0
  45. data/db/seeds.d/75-job_templates.rb +8 -0
  46. data/lib/foreman_acd/engine.rb +3 -0
  47. data/lib/foreman_acd/plugin.rb +53 -2
  48. data/lib/foreman_acd/version.rb +1 -1
  49. data/package.json +1 -1
  50. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +137 -22
  51. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +95 -11
  52. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +7 -2
  53. data/webpack/components/ApplicationDefinition/ApplicationDefinitionHelper.js +26 -0
  54. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +117 -21
  55. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +2 -0
  56. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +49 -0
  57. data/webpack/components/ApplicationDefinition/index.js +4 -0
  58. data/webpack/components/ApplicationInstance/ApplicationInstance.js +92 -22
  59. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +37 -8
  60. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +4 -2
  61. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +98 -26
  62. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +2 -1
  63. data/webpack/components/ApplicationInstance/index.js +2 -0
  64. data/webpack/components/ParameterSelection/ParameterSelection.js +46 -37
  65. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +49 -52
  66. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +5 -3
  67. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +0 -32
  68. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +32 -16
  69. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -2
  70. data/webpack/components/ParameterSelection/index.js +4 -4
  71. data/webpack/components/common/DeleteTableEntry.js +1 -1
  72. data/webpack/reducer.js +14 -11
  73. metadata +48 -3
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanAcd
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_acd",
3
- "version": "0.0.6",
3
+ "version": "0.3.0",
4
4
  "description": "foreman application centric deployment",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -1,3 +1,4 @@
1
+ import $ from 'jquery';
1
2
  import React, { useState } from 'react'
2
3
  import PropTypes from 'prop-types';
3
4
  import {
@@ -11,6 +12,7 @@ import ParameterSelection from '../ParameterSelection';
11
12
  import AddTableEntry from '../common/AddTableEntry';
12
13
  import DeleteTableEntry from '../common/DeleteTableEntry';
13
14
  import RailsData from '../common/RailsData'
15
+ import AnsiblePlaybookSelector from './components/AnsiblePlaybookSelector';
14
16
 
15
17
  import {
16
18
  Table,
@@ -18,6 +20,11 @@ import {
18
20
  inlineEditFormatterFactory,
19
21
  } from 'patternfly-react';
20
22
 
23
+ import {
24
+ PARAMETER_SELECTION_PARAM_TYPE_FOREMAN,
25
+ PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE,
26
+ } from '../ParameterSelection/ParameterSelectionConstants';
27
+
21
28
  class ApplicationDefinition extends React.Component {
22
29
 
23
30
  constructor(props) {
@@ -28,16 +35,30 @@ class ApplicationDefinition extends React.Component {
28
35
  return (rowData.backup !== undefined);
29
36
  }
30
37
 
38
+ createAnsibleGroupObject(ansibleGroups, withAll=false) {
39
+ const ansibleGroupObj = {};
40
+
41
+ const ansibleGroupArray = Object.keys(ansibleGroups);
42
+ ansibleGroupArray.forEach(e => (ansibleGroupObj[e] = e));
43
+
44
+ if ((withAll === false) && (ansibleGroupObj.hasOwnProperty('all'))) {
45
+ delete ansibleGroupObj.all;
46
+ }
47
+
48
+ return ansibleGroupObj;
49
+ }
50
+
31
51
  componentDidMount() {
32
52
  const {
33
- data: { services, hostgroups },
53
+ data: { mode, ansiblePlaybook, ansibleDataUrl, services, ansibleVarsAll, hostgroups },
34
54
  initApplicationDefinition,
35
55
  addApplicationDefinitionService,
36
56
  deleteApplicationDefinitionService,
37
57
  activateEditApplicationDefinitionService,
38
58
  changeEditApplicationDefinitionService,
39
- openParameterSelectionModal,
40
- closeParameterSelectionModal,
59
+ openForemanParameterSelectionModal,
60
+ openAnsibleParameterSelectionModal,
61
+ loadAnsibleData,
41
62
  } = this.props;
42
63
 
43
64
  const inlineEditButtonsFormatter = inlineEditFormatterFactory({
@@ -48,13 +69,21 @@ class ApplicationDefinition extends React.Component {
48
69
  bsStyle="default"
49
70
  onClick={() => activateEditApplicationDefinitionService(additionalData)}
50
71
  >
51
- <Icon type="pf" name="edit" />
72
+ <Icon type="pf" name="edit" title="edit entry" />
52
73
  </Button>
74
+ &nbsp;
53
75
  <Button
54
76
  bsStyle="default"
55
- onClick={() => openParameterSelectionModal(additionalData)}
77
+ onClick={() => openForemanParameterSelectionModal(additionalData)}
56
78
  >
57
- <Icon type="pf" name="settings" />
79
+ <Icon type="pf" name="settings" title="change parameters" />
80
+ </Button>
81
+ &nbsp;
82
+ <Button
83
+ bsStyle="default"
84
+ onClick={() => openAnsibleParameterSelectionModal(additionalData)}
85
+ >
86
+ <span title="change ansible variables">A</span>
58
87
  </Button>
59
88
  <DeleteTableEntry
60
89
  hidden={false}
@@ -69,9 +98,15 @@ class ApplicationDefinition extends React.Component {
69
98
  <Button bsStyle="default" disabled>
70
99
  <Icon type="pf" name="edit" />
71
100
  </Button>
101
+ &nbsp;
72
102
  <Button bsStyle="default" disabled>
73
103
  <Icon type="pf" name="settings" />
74
104
  </Button>
105
+ &nbsp;
106
+ <Button
107
+ bsStyle="default" disabled>
108
+ <span>A</span>
109
+ </Button>
75
110
  <DeleteTableEntry
76
111
  hidden={false}
77
112
  disabled={true}
@@ -121,6 +156,10 @@ class ApplicationDefinition extends React.Component {
121
156
  if (additionalData.property == 'hostgroup') {
122
157
  prettyValue = hostgroups[value];
123
158
  }
159
+ else if (additionalData.property == 'ansibleGroup') {
160
+ const ag = this.createAnsibleGroupObject(this.props.ansiblePlaybook.groups);
161
+ prettyValue = ag[value];
162
+ }
124
163
  return inlineEditFormatterImpl.renderValue(prettyValue, additionalData)
125
164
  },
126
165
  renderEdit: (value, additionalData) => {
@@ -130,13 +169,23 @@ class ApplicationDefinition extends React.Component {
130
169
  }
131
170
  return inlineEditFormatterImpl.renderValue(hostgroups[value], additionalData)
132
171
  }
172
+ else if (additionalData.property == 'ansibleGroup') {
173
+ const ag = this.createAnsibleGroupObject(this.props.ansiblePlaybook.groups);
174
+
175
+ if (additionalData.rowData.newEntry === true) {
176
+ return inlineEditFormatterImpl.renderEditSelect(value, additionalData, ag);
177
+ }
178
+ return inlineEditFormatterImpl.renderValue(ag[value], additionalData);
179
+ }
133
180
  return inlineEditFormatterImpl.renderEditText(value, additionalData);
134
181
  }
135
182
  });
136
183
  this.inlineEditFormatter = inlineEditFormatter;
137
184
 
138
185
  initApplicationDefinition(
186
+ ansiblePlaybook,
139
187
  services,
188
+ ansibleVarsAll,
140
189
  this.headerFormatter,
141
190
  this.inlineEditFormatter,
142
191
  this.inlineEditButtonsFormatter,
@@ -145,24 +194,38 @@ class ApplicationDefinition extends React.Component {
145
194
 
146
195
  render() {
147
196
  const {
148
- data: { organization, location, loadForemanDataUrl },
197
+ data: { organization, location, mode, ansiblePlaybooks, foremanDataUrl, ansibleDataUrl },
198
+ ansiblePlaybook,
149
199
  services,
150
200
  columns,
151
201
  addApplicationDefinitionService,
152
202
  confirmEditApplicationDefinitionService,
153
203
  cancelEditApplicationDefinitionService,
154
- openParameterSelectionModal,
155
- closeParameterSelectionModal,
204
+ closeForemanParameterSelectionModal,
205
+ openAnsibleParameterSelectionModal,
206
+ closeAnsibleParameterSelectionModal,
156
207
  ParameterSelectionModal,
208
+ loadAnsibleData,
157
209
  } = this.props;
158
210
 
159
211
  return (
160
212
  <span>
213
+ <div>
214
+ <AnsiblePlaybookSelector
215
+ label="Ansible Playbook"
216
+ editable={ mode == 'newDefinition' }
217
+ viewText={ ansiblePlaybook.name }
218
+ options={ ansiblePlaybooks }
219
+ onChange={ loadAnsibleData }
220
+ selectValue={ ansiblePlaybook.id.toString() }
221
+ additionalData={{url: ansibleDataUrl }}
222
+ />
223
+ </div>
161
224
  <div className="form-group">
162
225
  <AddTableEntry
163
- hidden={ false }
164
- disabled={ this.props.editMode }
165
- onAddTableEntry={ addApplicationDefinitionService }
226
+ hidden={ false }
227
+ disabled={ this.props.editMode }
228
+ onAddTableEntry={ addApplicationDefinitionService }
166
229
  />
167
230
  <Table.PfProvider
168
231
  striped
@@ -192,33 +255,73 @@ class ApplicationDefinition extends React.Component {
192
255
  />
193
256
  </Table.PfProvider>
194
257
  <AddTableEntry
195
- hidden={ false }
196
- disabled={ this.props.editMode }
197
- onAddTableEntry={ addApplicationDefinitionService }
258
+ hidden={ false }
259
+ disabled={ this.props.editMode }
260
+ onAddTableEntry={ addApplicationDefinitionService }
198
261
  />
262
+ <span style={{ marginLeft: 30 }}>
263
+ Ansible group vars 'all':
264
+ <Button
265
+ style={{ marginLeft: 10 }}
266
+ bsStyle="default"
267
+ disabled={ this.props.editMode }
268
+ onClick={() => openAnsibleParameterSelectionModal({
269
+ isAllGroup: true
270
+ })}
271
+ >
272
+ <span title="change ansible variables for 'all'">A</span>
273
+ </Button>
274
+ </span>
199
275
  </div>
200
276
  <div>
201
277
  <ForemanModal
202
- id="AppDefinitionParamSelection"
278
+ id="AppDefinitionForemanParamSelection"
203
279
  dialogClassName="param_selection_modal"
204
- title="Parameter definition for Application Definition"
280
+ title="Foreman Parameter definition for Application Definition"
205
281
  >
206
282
  <ForemanModal.Header closeButton={false}>
207
283
  Parameter definition
208
284
  </ForemanModal.Header>
209
285
  {this.props.parametersData ? (
210
286
  <ParameterSelection
287
+ paramType={ PARAMETER_SELECTION_PARAM_TYPE_FOREMAN }
211
288
  location={ location }
212
289
  organization={ organization }
213
- loadForemanDataUrl= { loadForemanDataUrl }
290
+ paramDataUrl= { foremanDataUrl }
214
291
  data={ this.props.parametersData }
215
292
  />
216
293
  ) : (<span>Empty</span>)
217
294
  }
218
295
  <ForemanModal.Footer>
219
296
  <div>
220
- <Button bsStyle="primary" onClick={() => closeParameterSelectionModal({ mode: 'save' })}>Save</Button>
221
- <Button bsStyle="default" onClick={() => closeParameterSelectionModal({ mode: 'cancel' })}>Cancel</Button>
297
+ <Button bsStyle="primary" onClick={() => closeForemanParameterSelectionModal({ mode: 'save' })}>Save</Button>
298
+ <Button bsStyle="default" onClick={() => closeForemanParameterSelectionModal({ mode: 'cancel' })}>Cancel</Button>
299
+ </div>
300
+ </ForemanModal.Footer>
301
+ </ForemanModal>
302
+ </div>
303
+ <div>
304
+ <ForemanModal
305
+ id="AppDefinitionAnsibleParamSelection"
306
+ dialogClassName="param_selection_modal"
307
+ title="Ansible variables for Application Definition"
308
+ >
309
+ <ForemanModal.Header closeButton={false}>
310
+ Parameter definition
311
+ </ForemanModal.Header>
312
+ {this.props.parametersData ? (
313
+ <ParameterSelection
314
+ paramType={ PARAMETER_SELECTION_PARAM_TYPE_ANSIBLE }
315
+ location={ location }
316
+ organization={ organization }
317
+ data={ this.props.parametersData }
318
+ />
319
+ ) : (<span>Empty</span>)
320
+ }
321
+ <ForemanModal.Footer>
322
+ <div>
323
+ <Button bsStyle="primary" onClick={() => closeAnsibleParameterSelectionModal({ mode: 'save' })}>Save</Button>
324
+ <Button bsStyle="default" onClick={() => closeAnsibleParameterSelectionModal({ mode: 'cancel' })}>Cancel</Button>
222
325
  </div>
223
326
  </ForemanModal.Footer>
224
327
  </ForemanModal>
@@ -229,6 +332,12 @@ class ApplicationDefinition extends React.Component {
229
332
  parameter='services'
230
333
  value={JSON.stringify(this.props.services)}
231
334
  />
335
+ <RailsData
336
+ key='applications_definition'
337
+ view='app_definition'
338
+ parameter='ansible_vars_all'
339
+ value={JSON.stringify(this.props.ansibleVarsAll)}
340
+ />
232
341
  </span>
233
342
  )};
234
343
  }
@@ -236,7 +345,9 @@ class ApplicationDefinition extends React.Component {
236
345
  ApplicationDefinition.defaultProps = {
237
346
  error: {},
238
347
  editMode: false,
348
+ ansiblePlaybook: { "id": '', "name": '' },
239
349
  services: [],
350
+ ansibleVarsAll: [],
240
351
  parametersData: {},
241
352
  columns: [],
242
353
  editParamsOfRowId: null,
@@ -245,7 +356,9 @@ ApplicationDefinition.defaultProps = {
245
356
  ApplicationDefinition.propTypes = {
246
357
  initApplicationDefinition: PropTypes.func,
247
358
  editMode: PropTypes.bool.isRequired,
359
+ ansiblePlaybook: PropTypes.object,
248
360
  services: PropTypes.array,
361
+ ansibleVarsAll: PropTypes.array,
249
362
  columns: PropTypes.array,
250
363
  addApplicationDefinitionService: PropTypes.func,
251
364
  deleteApplicationDefinitionService: PropTypes.func,
@@ -253,8 +366,10 @@ ApplicationDefinition.propTypes = {
253
366
  confirmEditApplicationDefinitionService: PropTypes.func,
254
367
  cancelEditApplicationDefinitionService: PropTypes.func,
255
368
  changeEditApplicationDefinitionService: PropTypes.func,
256
- openParameterSelectionModal: PropTypes.func,
257
- closeParameterSelectionModal: PropTypes.func,
369
+ openForemanParameterSelectionModal: PropTypes.func,
370
+ closeForemanParameterSelectionModal: PropTypes.func,
371
+ openAnsibleParameterSelectionModal: PropTypes.func,
372
+ closeAnsibleParameterSelectionModal: PropTypes.func,
258
373
  parametersData: PropTypes.object,
259
374
  };
260
375
 
@@ -17,18 +17,29 @@ import {
17
17
 
18
18
  import {
19
19
  APPLICATION_DEFINITION_INIT,
20
+ APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_REQUEST,
21
+ APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_SUCCESS,
22
+ APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_FAILURE,
20
23
  APPLICATION_DEFINITION_SERVICE_DELETE,
21
24
  APPLICATION_DEFINITION_SERVICE_ADD,
22
25
  APPLICATION_DEFINITION_SERVICE_EDIT_ACTIVATE,
23
26
  APPLICATION_DEFINITION_SERVICE_EDIT_CONFIRM,
24
27
  APPLICATION_DEFINITION_SERVICE_EDIT_CHANGE,
25
28
  APPLICATION_DEFINITION_SERVICE_EDIT_CANCEL,
26
- APPLICATION_DEFINITION_PARAMETER_SELECTION_MODAL_OPEN,
27
- APPLICATION_DEFINITION_PARAMETER_SELECTION_MODAL_CLOSE,
29
+ APPLICATION_DEFINITION_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN,
30
+ APPLICATION_DEFINITION_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE,
31
+ APPLICATION_DEFINITION_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN,
32
+ APPLICATION_DEFINITION_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE,
28
33
  } from './ApplicationDefinitionConstants';
29
34
 
35
+ import {
36
+ transformAnsiblePlaybook,
37
+ } from './ApplicationDefinitionHelper';
38
+
30
39
  export const initApplicationDefinition = (
40
+ ansiblePlaybook,
31
41
  services,
42
+ ansibleVarsAll,
32
43
  headerFormatter,
33
44
  inlineEditFormatter,
34
45
  inlineEditButtonsFormatter,
@@ -84,13 +95,29 @@ export const initApplicationDefinition = (
84
95
  formatters: [inlineEditFormatter]
85
96
  }
86
97
  },
98
+ {
99
+ property: 'ansibleGroup',
100
+ header: {
101
+ label: 'Ansible Group',
102
+ formatters: [headerFormatter],
103
+ props: {
104
+ index: 3,
105
+ style: {
106
+ width: '20%'
107
+ }
108
+ },
109
+ },
110
+ cell: {
111
+ formatters: [inlineEditFormatter]
112
+ }
113
+ },
87
114
  {
88
115
  property: 'minCount',
89
116
  header: {
90
117
  label: 'min count',
91
118
  formatters: [headerFormatter],
92
119
  props: {
93
- index: 3,
120
+ index: 4,
94
121
  style: {
95
122
  width: '10%'
96
123
  }
@@ -106,7 +133,7 @@ export const initApplicationDefinition = (
106
133
  label: 'max count',
107
134
  formatters: [headerFormatter],
108
135
  props: {
109
- index: 3,
136
+ index: 5,
110
137
  style: {
111
138
  width: '10%'
112
139
  }
@@ -122,7 +149,7 @@ export const initApplicationDefinition = (
122
149
  label: 'Actions',
123
150
  formatters: [actionHeaderCellFormatter],
124
151
  props: {
125
- index: 4,
152
+ index: 6,
126
153
  style: {
127
154
  width: '20%'
128
155
  }
@@ -134,7 +161,11 @@ export const initApplicationDefinition = (
134
161
  }
135
162
  ];
136
163
 
164
+ if (ansiblePlaybook !== undefined) {
165
+ initialState.ansiblePlaybook = transformAnsiblePlaybook(ansiblePlaybook);
166
+ }
137
167
  initialState.services = services;
168
+ initialState.ansibleVarsAll = ansibleVarsAll;
138
169
 
139
170
  dispatch({
140
171
  type: APPLICATION_DEFINITION_INIT,
@@ -142,6 +173,34 @@ export const initApplicationDefinition = (
142
173
  });
143
174
  };
144
175
 
176
+ const errorHandler = (msg, err) => {
177
+ const error = {
178
+ errorMsg: 'Failed to fetch data from server.',
179
+ statusText: err,
180
+ };
181
+ return { type: msg, payload: { error } };
182
+ };
183
+
184
+ export const loadAnsibleData = (
185
+ ansiblePlaybookId,
186
+ additionalData
187
+ ) => dispatch => {
188
+ dispatch({ type: APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_REQUEST });
189
+
190
+ const baseUrl = additionalData.url;
191
+ const realUrl = baseUrl.replace("__id__", ansiblePlaybookId);
192
+
193
+ return api
194
+ .get(realUrl, {}, {})
195
+ .then(({ data }) =>
196
+ dispatch({
197
+ type: APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_SUCCESS,
198
+ payload: { ...data }
199
+ })
200
+ )
201
+ .catch(error => dispatch(errorHandler(APPLICATION_DEFINITION_LOAD_ANSIBLE_DATA_FAILURE, error)));
202
+ };
203
+
145
204
  export const addApplicationDefinitionService = (additionalData) => ({
146
205
  type: APPLICATION_DEFINITION_SERVICE_ADD,
147
206
  payload: {
@@ -185,27 +244,52 @@ export const changeEditApplicationDefinitionService = (value, additionalData) =>
185
244
  },
186
245
  });
187
246
 
188
- export const openParameterSelectionModal = (additionalData) => dispatch => {
247
+ export const openForemanParameterSelectionModal = (additionalData) => dispatch => {
248
+ dispatch({
249
+ type: APPLICATION_DEFINITION_FOREMAN_PARAMETER_SELECTION_MODAL_OPEN,
250
+ payload: {
251
+ ...additionalData,
252
+ }
253
+ });
254
+ dispatch(
255
+ setModalOpen({ id: 'AppDefinitionForemanParamSelection' })
256
+ );
257
+ }
258
+
259
+ export const closeForemanParameterSelectionModal = (additionalData) => dispatch => {
260
+ dispatch({
261
+ type: APPLICATION_DEFINITION_FOREMAN_PARAMETER_SELECTION_MODAL_CLOSE,
262
+ payload: {
263
+ ...additionalData,
264
+ }
265
+ });
266
+
267
+ dispatch(
268
+ setModalClosed({ id: 'AppDefinitionForemanParamSelection' })
269
+ );
270
+ }
271
+
272
+ export const openAnsibleParameterSelectionModal = (additionalData) => dispatch => {
189
273
  dispatch({
190
- type: APPLICATION_DEFINITION_PARAMETER_SELECTION_MODAL_OPEN,
274
+ type: APPLICATION_DEFINITION_ANSIBLE_PARAMETER_SELECTION_MODAL_OPEN,
191
275
  payload: {
192
276
  ...additionalData,
193
277
  }
194
278
  });
195
279
  dispatch(
196
- setModalOpen({ id: 'AppDefinitionParamSelection' })
280
+ setModalOpen({ id: 'AppDefinitionAnsibleParamSelection' })
197
281
  );
198
282
  }
199
283
 
200
- export const closeParameterSelectionModal = (additionalData) => dispatch => {
284
+ export const closeAnsibleParameterSelectionModal = (additionalData) => dispatch => {
201
285
  dispatch({
202
- type: APPLICATION_DEFINITION_PARAMETER_SELECTION_MODAL_CLOSE,
286
+ type: APPLICATION_DEFINITION_ANSIBLE_PARAMETER_SELECTION_MODAL_CLOSE,
203
287
  payload: {
204
288
  ...additionalData,
205
289
  }
206
290
  });
207
291
 
208
292
  dispatch(
209
- setModalClosed({ id: 'AppDefinitionParamSelection' })
293
+ setModalClosed({ id: 'AppDefinitionAnsibleParamSelection' })
210
294
  );
211
295
  }