foreman_ansible_director 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/foreman_ansible_director/api/v2/ansible_content_controller.rb +106 -7
- data/app/controllers/foreman_ansible_director/api/v2/ansible_director_api_controller.rb +13 -0
- data/app/controllers/foreman_ansible_director/api/v2/ansible_variable_overrides_controller.rb +126 -0
- data/app/controllers/foreman_ansible_director/api/v2/ansible_variables_controller.rb +53 -0
- data/app/controllers/foreman_ansible_director/api/v2/assignments_controller.rb +91 -21
- data/app/controllers/foreman_ansible_director/api/v2/execution_environments_controller.rb +90 -1
- data/app/controllers/foreman_ansible_director/api/v2/lifecycle_environment_paths_controller.rb +90 -0
- data/app/controllers/foreman_ansible_director/api/v2/lifecycle_environments_controller.rb +182 -2
- data/app/controllers/foreman_ansible_director/api/v2/status_controller.rb +0 -9
- data/app/lib/foreman_ansible_director/abstract/content_resolution_node.rb +27 -0
- data/app/lib/foreman_ansible_director/abstract/content_source.rb +19 -0
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/bulk/destroy.rb +14 -10
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/bulk/import.rb +19 -8
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/extract_variables.rb +6 -5
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import.rb +14 -23
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/galaxy/import_collection.rb +16 -1
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/galaxy/rescue.rb +62 -0
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/galaxy/update_collection.rb +13 -3
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/git/import_collection.rb +16 -1
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/git/rescue.rb +63 -0
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/index/index_git_collection.rb +29 -11
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/index/index_static.rb +34 -21
- data/app/lib/foreman_ansible_director/actions/consistency_check/check/collection_remotes.rb +52 -0
- data/app/lib/foreman_ansible_director/actions/consistency_check/check/distributions.rb +50 -0
- data/app/lib/foreman_ansible_director/actions/consistency_check/check/git_remotes.rb +52 -0
- data/app/lib/foreman_ansible_director/actions/consistency_check/check/repositories.rb +50 -0
- data/app/lib/foreman_ansible_director/actions/consistency_check/check/role_remotes.rb +50 -0
- data/app/lib/foreman_ansible_director/actions/consistency_check/destroy/collection_remotes.rb +29 -0
- data/app/lib/foreman_ansible_director/actions/consistency_check/destroy/distributions.rb +29 -0
- data/app/lib/foreman_ansible_director/actions/consistency_check/destroy/git_remotes.rb +29 -0
- data/app/lib/foreman_ansible_director/actions/consistency_check/destroy/repositories.rb +29 -0
- data/app/lib/foreman_ansible_director/actions/consistency_check/destroy/role_remotes.rb +29 -0
- data/app/lib/foreman_ansible_director/actions/consistency_check/perform.rb +83 -0
- data/app/lib/foreman_ansible_director/actions/pulp3/ansible/distribution/create.rb +40 -16
- data/app/lib/foreman_ansible_director/actions/pulp3/ansible/distribution/destroy.rb +23 -8
- data/app/lib/foreman_ansible_director/actions/pulp3/ansible/distribution/list_all.rb +53 -0
- data/app/lib/foreman_ansible_director/actions/pulp3/ansible/remote/collection/create.rb +9 -3
- data/app/lib/foreman_ansible_director/actions/pulp3/ansible/remote/collection/destroy.rb +23 -9
- data/app/lib/foreman_ansible_director/actions/pulp3/ansible/remote/collection/list_all.rb +57 -0
- data/app/lib/foreman_ansible_director/actions/pulp3/ansible/remote/git/create.rb +8 -3
- data/app/lib/foreman_ansible_director/actions/pulp3/ansible/remote/git/destroy.rb +33 -5
- data/app/lib/foreman_ansible_director/actions/pulp3/ansible/remote/git/list_all.rb +57 -0
- data/app/lib/foreman_ansible_director/actions/pulp3/ansible/remote/role/create.rb +1 -0
- data/app/lib/foreman_ansible_director/actions/pulp3/ansible/remote/role/list_all.rb +57 -0
- data/app/lib/foreman_ansible_director/actions/pulp3/ansible/repository/create.rb +12 -4
- data/app/lib/foreman_ansible_director/actions/pulp3/ansible/repository/destroy.rb +22 -8
- data/app/lib/foreman_ansible_director/actions/pulp3/ansible/repository/list_all.rb +53 -0
- data/app/lib/foreman_ansible_director/actions/pulp3/util/destroy_all.rb +84 -0
- data/app/lib/foreman_ansible_director/actions/remote_execution/Provider/ansible_navigator_provider.rb +50 -25
- data/app/lib/foreman_ansible_director/actions/remote_execution/Provider/ansible_script_provider.rb +4 -4
- data/app/lib/foreman_ansible_director/actions/rescue/ansible_content_unit/common/cleanup_check.rb +35 -0
- data/app/lib/foreman_ansible_director/ansible_content/ansible_content_helpers.rb +1 -1
- data/app/lib/foreman_ansible_director/ansible_content/parsed_ansible_content_unit.rb +1 -1
- data/app/lib/foreman_ansible_director/ansible_content/simple_ansible_content_unit.rb +5 -4
- data/app/lib/foreman_ansible_director/generators/content_generator.rb +34 -23
- data/app/lib/foreman_ansible_director/generators/inventory_generator.rb +3 -2
- data/app/lib/foreman_ansible_director/generators/playbook_generator.rb +17 -22
- data/app/lib/foreman_ansible_director/generators/variable_generator.rb +20 -17
- data/app/lib/foreman_ansible_director/issues/base_issue.rb +29 -0
- data/app/lib/foreman_ansible_director/issues/errors/base_error.rb +9 -0
- data/app/lib/foreman_ansible_director/issues/warnings/base_warning.rb +9 -0
- data/app/lib/foreman_ansible_director/issues/warnings/no_resolution_candidate_for_collection_role.rb +42 -0
- data/app/lib/foreman_ansible_director/issues/warnings/no_resolution_candidate_for_role.rb +39 -0
- data/app/lib/foreman_ansible_director/logging/loggable_model.rb +33 -0
- data/app/models/foreman_ansible_director/ansible_content_assignment.rb +0 -10
- data/app/models/foreman_ansible_director/ansible_director_model.rb +2 -0
- data/app/models/foreman_ansible_director/ansible_variable.rb +17 -0
- data/app/models/foreman_ansible_director/concerns/content_consumer.rb +1 -1
- data/app/models/foreman_ansible_director/concerns/host_extensions.rb +27 -6
- data/app/models/foreman_ansible_director/concerns/hostgroup_extensions.rb +28 -1
- data/app/models/foreman_ansible_director/content_unit_version.rb +0 -2
- data/app/models/foreman_ansible_director/lifecycle_environment.rb +25 -8
- data/app/overrides/create_host_ansible_tab.rb +12 -12
- data/app/overrides/hostgroups_ansible_content_tab.rb +15 -0
- data/app/services/foreman_ansible_director/action_service.rb +31 -0
- data/app/services/foreman_ansible_director/ansible_director_service.rb +9 -0
- data/app/services/foreman_ansible_director/ansible_report_importer.rb +0 -3
- data/app/services/foreman_ansible_director/assignment_service.rb +169 -24
- data/app/services/foreman_ansible_director/cert/certs.rb +10 -2
- data/app/services/foreman_ansible_director/execution_environment_service.rb +7 -13
- data/app/services/foreman_ansible_director/lifecycle_environment_service.rb +8 -3
- data/app/services/foreman_ansible_director/logging/action_logger.rb +30 -0
- data/app/services/foreman_ansible_director/logging/crud_logger.rb +44 -0
- data/app/services/foreman_ansible_director/pulp3/ansible/distribution/list.rb +25 -0
- data/app/services/foreman_ansible_director/pulp3/ansible/remote/collection/list.rb +27 -0
- data/app/services/foreman_ansible_director/pulp3/ansible/remote/git/list.rb +27 -0
- data/app/services/foreman_ansible_director/pulp3/ansible/remote/role/list.rb +27 -0
- data/app/services/foreman_ansible_director/pulp3/ansible/repository/list.rb +25 -0
- data/app/services/foreman_ansible_director/pulp3/base_client.rb +14 -2
- data/app/services/foreman_ansible_director/request_ctx/request_context.rb +99 -0
- data/app/services/foreman_ansible_director/request_ctx/request_context_helper.rb +11 -0
- data/app/services/foreman_ansible_director/variable_service.rb +63 -72
- data/app/views/foreman_ansible_director/api/v2/ansible_content/consistency_check.json.rabl +13 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_content/create_units.rabl +11 -2
- data/app/views/foreman_ansible_director/api/v2/ansible_content/destroy_units.rabl +11 -2
- data/app/views/foreman_ansible_director/api/v2/ansible_variables/show.json.rabl +1 -1
- data/app/views/foreman_ansible_director/api/v2/assignments/assign.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/assignments/assignments.json.rabl +57 -26
- data/app/views/foreman_ansible_director/api/v2/common/response.json.rabl +25 -0
- data/app/views/foreman_ansible_director/api/v2/execution_environments/show.json.rabl +22 -0
- data/app/views/foreman_ansible_director/api/v2/hostgroups/ansible_content_source.rabl +24 -0
- data/app/views/foreman_ansible_director/api/v2/hosts/ansible_content_source.rabl +24 -0
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environments/show.json.rabl +7 -4
- data/app/views/foreman_ansible_director/job_templates/run_playbook-ansible_default.erb +3 -3
- data/app/views/foreman_ansible_director/overrides/_hostgroups_main_fields.erb +32 -0
- data/app/views/foreman_ansible_director/overrides/_hostgroups_tab_content.erb +11 -0
- data/app/views/foreman_ansible_director/overrides/_hostgroups_tab_title.erb +3 -0
- data/config/routes.rb +3 -3
- data/db/migrate/20260316000001_ansible_director_schema.rb +12 -4
- data/lib/foreman_ansible_director/constants.rb +7 -1
- data/lib/foreman_ansible_director/engine.rb +0 -1
- data/lib/foreman_ansible_director/register.rb +71 -30
- data/lib/foreman_ansible_director/remote_execution.rb +0 -6
- data/lib/tasks/uninstall.rake +44 -0
- data/package.json +1 -1
- data/test/ansible_content/unit/simple_ansible_content_unit_test.rb +164 -0
- data/test/factories/ansible_content_assignments_factory.rb +23 -0
- data/test/foreman_ansible_director_test_helper.rb +22 -2
- data/test/generators/unit/variable_generator_test.rb +98 -0
- data/test/models/unit/ansible_variable_test.rb +37 -0
- data/test/models/unit/execution_environment_test.rb +212 -0
- data/test/services/unit/action_service_test.rb +173 -0
- data/test/services/unit/assignment_service_test.rb +236 -89
- data/test/services/unit/content_service_test.rb +153 -0
- data/test/services/unit/execution_environment_service_test.rb +7 -31
- data/test/services/unit/variable_service_test.rb +282 -15
- data/webpack/components/ansible_content/AnsibleContentPageWrapper.tsx +5 -3
- data/webpack/components/ansible_content/components/AnsibleContentTable.tsx +7 -7
- data/webpack/components/ansible_content/components/AnsibleContentTablePrimaryRow.tsx +37 -9
- data/webpack/components/ansible_content/components/AnsibleContentTableSecondaryRow.tsx +39 -12
- data/webpack/components/ansible_content/components/AnsibleContentTableWrapper.tsx +28 -5
- data/webpack/components/ansible_content/components/AnsibleContentWizard/AnsibleContentWizard.tsx +1 -5
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/ProviderSelectionStep.tsx +0 -1
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/FinishFooter.tsx +43 -18
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/GalaxyContentUnitInput.tsx +14 -92
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/GitContentUnitInput.tsx +34 -17
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/components/IdentifierInput.tsx +121 -0
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/AnsibleVariablesOverview.tsx +2 -2
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/AnsibleVariablesSelector.tsx +148 -244
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/MatcherSelector.tsx +143 -98
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/OverrideCard.tsx +31 -5
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/OverrideManagementModal.tsx +17 -61
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/OverridesTabContent.tsx +106 -1
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/VariableManagementModalContent.tsx +87 -14
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/VariableManagementModalWrapper.tsx +11 -2
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/tabConstants.ts +2 -0
- data/webpack/components/ansible_content/components/ConsistencyCheckModal.tsx +140 -0
- data/webpack/components/ansible_environments/AnsibleEnvironmentsPageWrapper.tsx +5 -2
- data/webpack/components/ansible_environments/components/AnsibleLcePathIndex.tsx +5 -3
- data/webpack/components/ansible_environments/components/components/AnsibleLcePathComponent.tsx +4 -2
- data/webpack/components/ansible_execution_environments/AnsibleExecutionEnvPageWrapper.tsx +5 -2
- data/webpack/components/ansible_execution_environments/ExecutionEnvGrid.tsx +6 -37
- data/webpack/components/ansible_execution_environments/components/ExecutionEnvCard.tsx +37 -138
- data/webpack/components/ansible_execution_environments/components/ExecutionEnvCardHeaderActions.tsx +57 -24
- data/webpack/components/ansible_execution_environments/components/ExecutionEnvCardWrapper.tsx +278 -0
- data/webpack/components/ansible_execution_environments/components/ExecutionEnvCreateCard.tsx +84 -138
- data/webpack/components/ansible_execution_environments/components/ExecutionEnvEditCard.tsx +211 -0
- data/webpack/components/ansible_execution_environments/components/ExecutionEnvGridWrapper.tsx +2 -118
- data/webpack/components/ansible_execution_environments/components/components/TextInputEditable.tsx +3 -0
- data/webpack/components/common/AlertModal.tsx +52 -0
- data/webpack/components/common/AnsibleContentAssignment/AnsibleContentAssignment.tsx +354 -0
- data/webpack/components/common/AnsibleContentAssignment/AnsibleContentAssignmentMain.tsx +78 -0
- data/webpack/components/common/AnsibleContentAssignment/AnsibleContentAssignmentWrapper.tsx +82 -0
- data/webpack/components/common/AnsibleContentAssignment/components/AssignmentSelector.tsx +304 -0
- data/webpack/components/common/AnsibleContentAssignment/components/AssignmentSelectorWrapper.tsx +164 -0
- data/webpack/components/common/AnsibleContentAssignment/components/ContentAssignmentTable.tsx +285 -0
- data/webpack/components/common/AnsibleContentAssignment/components/HierarchyLevelSelector.tsx +47 -0
- data/webpack/components/{extensions/host_details/HostDetailsTab/components → common/AnsibleContentAssignment/components/Variables}/MergedOverrideCard.tsx +42 -17
- data/webpack/components/{extensions/host_details/HostDetailsTab/components → common/AnsibleContentAssignment/components/Variables}/OverrideGrid.tsx +28 -8
- data/webpack/components/{extensions/host_details/HostDetailsTab/components → common/AnsibleContentAssignment/components/Variables}/OverrideGridWrapper.tsx +15 -7
- data/webpack/components/common/AnsibleContentAssignment/helpers.ts +50 -0
- data/webpack/components/common/ForceTaxonomy.tsx +248 -0
- data/webpack/components/common/Permitted.tsx +47 -0
- data/webpack/components/common/__test__/Permitted.test.tsx +88 -0
- data/webpack/components/common/components/TaxonSelector.tsx +81 -0
- data/webpack/components/extensions/host_details/HostDetailsLceCard/HostDetailsLceCard.tsx +145 -57
- data/webpack/components/extensions/host_details/HostDetailsLceCard/components/HostDetailsLceCardHeaderActions.tsx +60 -45
- data/webpack/components/extensions/host_details/HostDetailsLceCard/components/LcePathSelector.tsx +15 -3
- data/webpack/components/extensions/host_details/HostDetailsTab/HostDetailsTab.tsx +9 -62
- data/webpack/constants/foremanAnsibleDirectorPermissions.ts +6 -6
- data/webpack/helpers/adContext.ts +17 -0
- data/webpack/helpers/comparisons.ts +6 -0
- data/webpack/helpers/components/ConfirmationModal.tsx +22 -15
- data/webpack/helpers/components/__test__/ConfirmationModal.test.tsx +0 -25
- data/webpack/helpers/constants.ts +2 -0
- data/webpack/helpers/hooks/useHybridSearch.ts +261 -0
- data/webpack/helpers/typeGuards/contentAssignmentTypeGuards.ts +22 -0
- data/webpack/index.js +3 -3
- data/webpack/routes/routes.tsx +6 -6
- data/webpack/types/AnsibleContentAssignmentTypes.d.ts +59 -0
- data/webpack/types/AnsibleContentTypes.d.ts +9 -0
- data/webpack/types/AnsibleExecutionEnvTypes.d.ts +1 -1
- data/webpack/types/common.d.ts +59 -0
- data/webpack/types/foremanReact/Root/Context/ForemanContext.d.ts +28 -8
- data/webpack/types/foremanReact/components/PermissionDenied/PermissionDenied.d.ts +13 -0
- data/webpack/types/foremanReact/components/ToastsList/slice.d.ts +1 -1
- data/webpack/types/issues/errors.d.ts +4 -0
- data/webpack/types/issues/warnings.d.ts +9 -0
- metadata +106 -36
- data/app/controllers/foreman_ansible_director/api/v2/ansible_runs_controller.rb +0 -35
- data/app/models/foreman_ansible_director/ansible_content_assignment_collection_role.rb +0 -9
- data/app/views/foreman_ansible_director/ansible_content/_ansible_content_tab_content.html.erb +0 -6
- data/app/views/foreman_ansible_director/ansible_content/_ansible_content_tab_title.html.erb +0 -1
- data/app/views/foreman_ansible_director/ansible_content/ansible_content/_ansible_content_tab_content.html.erb +0 -8
- data/app/views/foreman_ansible_director/ansible_content/ansible_content/_ansible_content_tab_title.html.erb +0 -1
- data/app/views/foreman_ansible_director/api/v2/hosts/ansible_lifecycle_environment.json.rabl +0 -3
- data/test/factories/ansible_content_assignments_factroy.rb +0 -20
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/AnsibleVariablesViewer.tsx +0 -0
- data/webpack/components/ansible_content/index.tsx +0 -9
- data/webpack/components/ansible_environments/index.tsx +0 -9
- data/webpack/components/ansible_execution_environments/index.tsx +0 -9
- data/webpack/components/common/AdContextWrapper.tsx +0 -63
- data/webpack/components/extensions/host_details/HostDetailsLceCard/components/LcePathSelectorWrapper.tsx +0 -122
- data/webpack/components/extensions/host_details/HostDetailsTab/components/AssignmentComponent.tsx +0 -165
- data/webpack/components/extensions/host_details/HostDetailsTab/components/AssignmentComponentWrapper.tsx +0 -116
- data/webpack/components/extensions/host_details/HostDetailsTab/components/LceAssignmentSelector.tsx +0 -323
- data/webpack/components/extensions/host_details/HostDetailsTab/components/LceContentList.tsx +0 -115
- data/webpack/components/extensions/host_details/HostDetailsTab/components/LceContentListWrapper.tsx +0 -36
- data/webpack/types/foremanReact/components/Permitted/Permitted.d.ts +0 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9bfa5c13b50ecdad46dceeb00e2691c16c586e8060094b5fe21eb1b19ae0eb60
|
|
4
|
+
data.tar.gz: 12749d98c77fe7008baf803bdfcc627b428f82f1192da8f904602611dbbac9f6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8650021501539c07fc71f21cacaea22dae5abe0066b209354b9ae68b8bc2d802c7ea5440c55df65b3d53f5b218b67bcbdb7d88c9699cd6c2219bd46749c69e17
|
|
7
|
+
data.tar.gz: 5537935a1c0f62ca5a3465b7fc998bb713e8dd22a2fdfa193b5db14a6e1176367112268124f2bb879d139bd8740706e44d620347c60e40e251c6386975130efb
|
|
@@ -7,19 +7,72 @@ module ForemanAnsibleDirector
|
|
|
7
7
|
before_action :find_organization, only: %i[create_units]
|
|
8
8
|
before_action :find_optional_organization, only: %i[index]
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
resource_description { resource_id 'AD Ansible Content' }
|
|
11
11
|
|
|
12
|
+
# region ApiDoc: POST /api/v2/ansible_director/ansible_content
|
|
13
|
+
api :POST, '/v2/ansible_director/ansible_content', N_('Import Ansible content units')
|
|
14
|
+
param :organization_id, :number, desc: N_('Organization identifier.'), required: true
|
|
15
|
+
param :units, Array, desc: N_('Array of content units to import.'), required: true do
|
|
16
|
+
param :unit_name,
|
|
17
|
+
String,
|
|
18
|
+
desc: N_('Identifier of the content unit.'),
|
|
19
|
+
example: N_('manala.roles'),
|
|
20
|
+
required: true
|
|
21
|
+
param :unit_type,
|
|
22
|
+
%w[role collection],
|
|
23
|
+
desc: N_('Type of the content unit.'),
|
|
24
|
+
example: N_('collection'),
|
|
25
|
+
required: true
|
|
26
|
+
param :unit_source_type,
|
|
27
|
+
%w[galaxy git],
|
|
28
|
+
desc: N_('Source type of the content unit.'),
|
|
29
|
+
example: N_('galaxy'),
|
|
30
|
+
required: true
|
|
31
|
+
param :unit_source,
|
|
32
|
+
String,
|
|
33
|
+
desc: N_('Source URL or path for the content unit (e.g., Galaxy URL or Git repo).'),
|
|
34
|
+
example: N_('https://galaxy.ansible.com'),
|
|
35
|
+
required: true
|
|
36
|
+
param :unit_versions,
|
|
37
|
+
Array,
|
|
38
|
+
desc: N_('An array of versions to import (e.g., ["1.0.0", "2.0.0"]).'),
|
|
39
|
+
example: %w[1.0.0 2.0.0],
|
|
40
|
+
required: true
|
|
41
|
+
end
|
|
42
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
43
|
+
example <<~EXAMPLE
|
|
44
|
+
{
|
|
45
|
+
"organization_id": 1,
|
|
46
|
+
"units": [
|
|
47
|
+
{
|
|
48
|
+
"unit_name": "manala.roles",
|
|
49
|
+
"unit_type": "collection",
|
|
50
|
+
"unit_source_type": "galaxy",
|
|
51
|
+
"unit_source": "https://galaxy.ansible.com",
|
|
52
|
+
"unit_versions": ["5.2.0"]
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
EXAMPLE
|
|
57
|
+
# endregion
|
|
12
58
|
def create_units
|
|
13
59
|
resolved = ::ForemanAnsibleDirector::AnsibleContent::AnsibleContentHelpers.resolve_import_payload(
|
|
14
60
|
params[:units]
|
|
15
61
|
)
|
|
16
|
-
@bulk_create_task =
|
|
62
|
+
@bulk_create_task = ::ForemanAnsibleDirector::ActionService.trigger(
|
|
17
63
|
::ForemanAnsibleDirector::Actions::AnsibleContentUnit::Bulk::Import,
|
|
18
|
-
|
|
19
|
-
|
|
64
|
+
task_args: {
|
|
65
|
+
resolved_content_units: resolved,
|
|
66
|
+
organization_id: @organization.id,
|
|
67
|
+
}
|
|
20
68
|
)
|
|
21
69
|
end
|
|
22
70
|
|
|
71
|
+
# region ApiDoc: GET /api/v2/ansible_director/ansible_content
|
|
72
|
+
api :GET, '/v2/ansible_director/ansible_content', N_('List Ansible content units')
|
|
73
|
+
param :organization_id, :number, desc: N_('Organization identifier'), required: false
|
|
74
|
+
param_group :search_and_pagination, ::Api::V2::BaseController
|
|
75
|
+
# endregion
|
|
23
76
|
def index
|
|
24
77
|
scope = resource_scope_for_index
|
|
25
78
|
@ansible_content_units = if @organization
|
|
@@ -29,18 +82,64 @@ module ForemanAnsibleDirector
|
|
|
29
82
|
end
|
|
30
83
|
end
|
|
31
84
|
|
|
85
|
+
# region ApiDoc: GET /api/v2/ansible_director/ansible_content/:content_unit_id/versions/:content_unit_version_id
|
|
86
|
+
api :GET, '/v2/ansible_director/ansible_content/:content_unit_id/versions/:content_unit_version_id',
|
|
87
|
+
N_('Show details of a specific Ansible content unit version')
|
|
88
|
+
# endregion
|
|
32
89
|
def version_detail
|
|
33
90
|
@content_unit_version = ::ForemanAnsibleDirector::ContentUnitVersion.find_by(id: params[:version])
|
|
34
91
|
end
|
|
35
92
|
|
|
36
93
|
# TODO: This needs to check and invalidate built EEs
|
|
94
|
+
# region ApiDoc: DELETE /api/v2/ansible_director/ansible_content
|
|
95
|
+
api :DELETE, '/v2/ansible_director/ansible_content',
|
|
96
|
+
N_('Destroy previously imported Ansible content units.')
|
|
97
|
+
param :units, Array, desc: N_('Array of content units to destroy.'), required: true do
|
|
98
|
+
param :unit_id, :number, desc: N_('ID of the Ansible content unit to destroy.'), required: true
|
|
99
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
100
|
+
param :unit_version_ids, Array,
|
|
101
|
+
desc: <<~DESC,
|
|
102
|
+
Array of version IDs to delete.
|
|
103
|
+
Optional: If not supplied, every version of the given content unit will be deleted.
|
|
104
|
+
DESC
|
|
105
|
+
required: false
|
|
106
|
+
end
|
|
107
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
108
|
+
example <<~EXAMPLE
|
|
109
|
+
{
|
|
110
|
+
"units": [
|
|
111
|
+
{
|
|
112
|
+
"unit_id": 42,
|
|
113
|
+
"unit_version_ids": [101, 102]
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"unit_id": 43,
|
|
117
|
+
"unit_version_ids": [105]
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
EXAMPLE
|
|
122
|
+
# endregion
|
|
37
123
|
def destroy_units
|
|
38
124
|
resolved = ::ForemanAnsibleDirector::AnsibleContent::AnsibleContentHelpers.resolve_destroy_payload(
|
|
39
125
|
destroy_params
|
|
40
126
|
)
|
|
41
|
-
@bulk_destroy_task =
|
|
42
|
-
|
|
43
|
-
|
|
127
|
+
@bulk_destroy_task = ::ForemanAnsibleDirector::ActionService.trigger(
|
|
128
|
+
::ForemanAnsibleDirector::Actions::AnsibleContentUnit::Bulk::Destroy,
|
|
129
|
+
task_args: {
|
|
130
|
+
resolved_content_units: resolved,
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# region ApiDoc: POST /api/v2/ansible_director/ansible_content/consistency_check
|
|
136
|
+
api :POST, '/v2/ansible_director/ansible_content/consistency_check',
|
|
137
|
+
N_('Run a consistency check to clean up the database after a failed content import.')
|
|
138
|
+
# endregion
|
|
139
|
+
def consistency_check
|
|
140
|
+
@consistency_check = ::ForemanAnsibleDirector::ActionService.trigger(
|
|
141
|
+
::ForemanAnsibleDirector::Actions::ConsistencyCheck::Perform
|
|
142
|
+
)
|
|
44
143
|
end
|
|
45
144
|
|
|
46
145
|
def model_of_controller
|
|
@@ -7,6 +7,19 @@ module ForemanAnsibleDirector
|
|
|
7
7
|
include ::Api::Version2
|
|
8
8
|
include ::Foreman::Controller::AutoCompleteSearch
|
|
9
9
|
|
|
10
|
+
include ::ForemanAnsibleDirector::RequestCtx::RequestContextHelper
|
|
11
|
+
|
|
12
|
+
around_action :attach_request_ctx
|
|
13
|
+
|
|
14
|
+
def attach_request_ctx
|
|
15
|
+
::ForemanAnsibleDirector::RequestCtx::RequestContext.with_context(
|
|
16
|
+
::ForemanAnsibleDirector::RequestCtx::RequestContext.new(request.request_id)
|
|
17
|
+
) do
|
|
18
|
+
@ctx = ctx
|
|
19
|
+
yield
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
10
23
|
def find_organization
|
|
11
24
|
@organization = Organization.current || find_optional_organization
|
|
12
25
|
if @organization.nil?
|
data/app/controllers/foreman_ansible_director/api/v2/ansible_variable_overrides_controller.rb
CHANGED
|
@@ -7,6 +7,30 @@ module ForemanAnsibleDirector
|
|
|
7
7
|
before_action :find_variable, only: %i[create]
|
|
8
8
|
before_action :find_override, only: %i[update destroy]
|
|
9
9
|
|
|
10
|
+
resource_description { resource_id 'AD Ansible Variable Overrides' }
|
|
11
|
+
|
|
12
|
+
# region ApiDoc: GET /api/v2/ansible_director/ansible_variables/:ansible_variable_id/overrides
|
|
13
|
+
api :GET, '/v2/ansible_director/ansible_variables/:ansible_variable_id/overrides',
|
|
14
|
+
N_('List overrides for a target')
|
|
15
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
16
|
+
description <<~DESC
|
|
17
|
+
List override values associated with a given target (host or hostgroup).
|
|
18
|
+
Overrides are matched at runtime based on the predefined hierarchy: Default -> Hostgroup -> Host.
|
|
19
|
+
DESC
|
|
20
|
+
param :target,
|
|
21
|
+
%w[HOST HOSTGROUP],
|
|
22
|
+
desc: N_('Type of the target entity.'),
|
|
23
|
+
required: true
|
|
24
|
+
param :target_id,
|
|
25
|
+
:number,
|
|
26
|
+
desc: N_('ID of the target entity.'),
|
|
27
|
+
required: true
|
|
28
|
+
param :include_overridable,
|
|
29
|
+
[true, false],
|
|
30
|
+
desc: N_('Whether to include overridable variables in the response.'),
|
|
31
|
+
example: false,
|
|
32
|
+
required: false
|
|
33
|
+
# endregion
|
|
10
34
|
def index_for_target
|
|
11
35
|
target = ::ForemanAnsibleDirector::AssignmentService.find_target(
|
|
12
36
|
target_type: params[:target],
|
|
@@ -17,6 +41,46 @@ module ForemanAnsibleDirector
|
|
|
17
41
|
include_overridable: include_overridable
|
|
18
42
|
end
|
|
19
43
|
|
|
44
|
+
# region ApiDoc: POST /api/v2/ansible_director/ansible_variables/:ansible_variable_id/overrides
|
|
45
|
+
api :POST, '/v2/ansible_director/ansible_variables/:ansible_variable_id/overrides',
|
|
46
|
+
N_('Create an override for an Ansible variable')
|
|
47
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
48
|
+
description <<~DESC
|
|
49
|
+
Create a new override rule for the specified Ansible variable.
|
|
50
|
+
Overrides allow customizing the variable value for specific hosts, hostgroups, or other matchers.
|
|
51
|
+
DESC
|
|
52
|
+
param :ansible_variable_id,
|
|
53
|
+
:number,
|
|
54
|
+
desc: N_('ID of the Ansible variable to override.'),
|
|
55
|
+
required: true
|
|
56
|
+
param :override, Hash, desc: N_('Override definition'), required: true do
|
|
57
|
+
param :value,
|
|
58
|
+
String,
|
|
59
|
+
desc: N_('Override value (must be valid JSON when the variable type is `json`, `array`, or `hash`).'),
|
|
60
|
+
example: '192.168.1.1',
|
|
61
|
+
required: true
|
|
62
|
+
param :matcher,
|
|
63
|
+
%w[fqdn hostgroup],
|
|
64
|
+
desc: N_('Matcher type.'),
|
|
65
|
+
example: 'fqdn',
|
|
66
|
+
required: true
|
|
67
|
+
param :matcher_value,
|
|
68
|
+
String,
|
|
69
|
+
desc: N_('Value for the matcher (e.g., "myhost.example.com").'),
|
|
70
|
+
example: 'myhost.example.com',
|
|
71
|
+
required: true
|
|
72
|
+
end
|
|
73
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
74
|
+
example <<~EXAMPLE
|
|
75
|
+
{
|
|
76
|
+
"override": {
|
|
77
|
+
"value": "prod-ntp.internal",
|
|
78
|
+
"matcher": "fqdn",
|
|
79
|
+
"matcher_value": "prod-web-01.example.com"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
EXAMPLE
|
|
83
|
+
# endregion
|
|
20
84
|
def create
|
|
21
85
|
override = override_params
|
|
22
86
|
::ForemanAnsibleDirector::VariableService.create_override(
|
|
@@ -27,6 +91,48 @@ module ForemanAnsibleDirector
|
|
|
27
91
|
)
|
|
28
92
|
end
|
|
29
93
|
|
|
94
|
+
# region ApiDoc: PUT /api/v2/ansible_director/ansible_variables/:ansible_variable_id/overrides/:id
|
|
95
|
+
api :PUT, '/v2/ansible_director/ansible_variables/:ansible_variable_id/overrides/:id', N_('Update an override')
|
|
96
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
97
|
+
description <<~DESC
|
|
98
|
+
Update an existing override rule.
|
|
99
|
+
DESC
|
|
100
|
+
param :ansible_variable_id,
|
|
101
|
+
:number,
|
|
102
|
+
desc: N_('ID of the Ansible variable.'),
|
|
103
|
+
required: true
|
|
104
|
+
param :id,
|
|
105
|
+
:number,
|
|
106
|
+
desc: N_('ID of the override to update.'),
|
|
107
|
+
required: true
|
|
108
|
+
param :override, Hash, desc: N_('Override update'), required: true do
|
|
109
|
+
param :value,
|
|
110
|
+
String,
|
|
111
|
+
desc: N_('New override value.'),
|
|
112
|
+
example: 'backup-ntp.internal',
|
|
113
|
+
required: false
|
|
114
|
+
param :matcher,
|
|
115
|
+
String,
|
|
116
|
+
desc: N_('New matcher type (e.g., "hostgroup").'),
|
|
117
|
+
example: 'hostgroup',
|
|
118
|
+
required: false
|
|
119
|
+
param :matcher_value,
|
|
120
|
+
String,
|
|
121
|
+
desc: N_('New matcher value (e.g., "my_hostgroup").'),
|
|
122
|
+
example: 'my_hostgroup',
|
|
123
|
+
required: false
|
|
124
|
+
end
|
|
125
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
126
|
+
example <<~EXAMPLE
|
|
127
|
+
{
|
|
128
|
+
"override": {
|
|
129
|
+
"value": "staging-ntp.internal",
|
|
130
|
+
"matcher": "hostgroup",
|
|
131
|
+
"matcher_value": "Staging"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
EXAMPLE
|
|
135
|
+
# endregion
|
|
30
136
|
def update
|
|
31
137
|
override = override_params
|
|
32
138
|
::ForemanAnsibleDirector::VariableService.edit_override(
|
|
@@ -37,6 +143,22 @@ module ForemanAnsibleDirector
|
|
|
37
143
|
)
|
|
38
144
|
end
|
|
39
145
|
|
|
146
|
+
# region ApiDoc: DELETE /api/v2/ansible_director/ansible_variables/:ansible_variable_id/overrides/:id
|
|
147
|
+
api :DELETE, '/v2/ansible_director/ansible_variables/:ansible_variable_id/overrides/:id',
|
|
148
|
+
N_('Delete an override')
|
|
149
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
150
|
+
description <<~DESC
|
|
151
|
+
Delete an override rule.
|
|
152
|
+
DESC
|
|
153
|
+
param :ansible_variable_id,
|
|
154
|
+
:number,
|
|
155
|
+
desc: N_('ID of the Ansible variable.'),
|
|
156
|
+
required: true
|
|
157
|
+
param :id,
|
|
158
|
+
:number,
|
|
159
|
+
desc: N_('ID of the override to delete.'),
|
|
160
|
+
required: true
|
|
161
|
+
# endregion
|
|
40
162
|
def destroy
|
|
41
163
|
::ForemanAnsibleDirector::VariableService.destroy_override(@override)
|
|
42
164
|
end
|
|
@@ -71,6 +193,10 @@ module ForemanAnsibleDirector
|
|
|
71
193
|
}
|
|
72
194
|
)
|
|
73
195
|
end
|
|
196
|
+
|
|
197
|
+
def controller_permission
|
|
198
|
+
'ansible_director_variable_overrides'
|
|
199
|
+
end
|
|
74
200
|
end
|
|
75
201
|
end
|
|
76
202
|
end
|
|
@@ -6,9 +6,58 @@ module ForemanAnsibleDirector
|
|
|
6
6
|
class AnsibleVariablesController < AnsibleDirectorApiController
|
|
7
7
|
before_action :find_resource, only: %i[show update]
|
|
8
8
|
|
|
9
|
+
resource_description { resource_id 'AD Ansible Variables' }
|
|
10
|
+
|
|
11
|
+
# region ApiDoc: GET /api/v2/ansible_director/ansible_variables/:id
|
|
12
|
+
api :GET, '/v2/ansible_director/ansible_variables/:id', N_('Show details of an Ansible variable')
|
|
13
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
14
|
+
description <<~DESC
|
|
15
|
+
Retrieve details of a specific Ansible variable.
|
|
16
|
+
DESC
|
|
17
|
+
# endregion
|
|
9
18
|
def show
|
|
10
19
|
end
|
|
11
20
|
|
|
21
|
+
# region ApiDoc: PUT /api/v2/ansible_director/ansible_variables/:id
|
|
22
|
+
api :PUT, '/v2/ansible_director/ansible_variables/:id', N_('Update an Ansible variable')
|
|
23
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
24
|
+
description <<~DESC
|
|
25
|
+
Update basic attributes (key, type, default value, and overridability) of an Ansible variable.
|
|
26
|
+
DESC
|
|
27
|
+
param :ansible_variable, Hash, desc: N_('Ansible variable updates'), required: true do
|
|
28
|
+
param :key,
|
|
29
|
+
String,
|
|
30
|
+
desc: N_('Name of the variable.'),
|
|
31
|
+
example: 'ansible_user',
|
|
32
|
+
required: true
|
|
33
|
+
param :type,
|
|
34
|
+
%w[string integer boolean float json array hash],
|
|
35
|
+
desc: N_('Type of the variable value.'),
|
|
36
|
+
example: 'string',
|
|
37
|
+
required: true
|
|
38
|
+
param :default_value,
|
|
39
|
+
String,
|
|
40
|
+
desc: N_('Default value (must be valid JSON when type is `json`, `array`, or `hash`).'),
|
|
41
|
+
example: 'root',
|
|
42
|
+
required: true
|
|
43
|
+
param :overridable,
|
|
44
|
+
[true, false],
|
|
45
|
+
desc: N_('Whether this variable can be overridden on hosts or hostgroups.'),
|
|
46
|
+
example: true,
|
|
47
|
+
required: false
|
|
48
|
+
end
|
|
49
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
50
|
+
example <<~EXAMPLE
|
|
51
|
+
{
|
|
52
|
+
"ansible_variable": {
|
|
53
|
+
"key": "ansible_user",
|
|
54
|
+
"type": "string",
|
|
55
|
+
"default_value": "root",
|
|
56
|
+
"overridable": true
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
EXAMPLE
|
|
60
|
+
# endregion
|
|
12
61
|
def update
|
|
13
62
|
variable = variable_params
|
|
14
63
|
::ForemanAnsibleDirector::VariableService.edit_variable(
|
|
@@ -29,6 +78,10 @@ module ForemanAnsibleDirector
|
|
|
29
78
|
def resource_class
|
|
30
79
|
::ForemanAnsibleDirector::AnsibleVariable
|
|
31
80
|
end
|
|
81
|
+
|
|
82
|
+
def controller_permission
|
|
83
|
+
'ansible_director_variables'
|
|
84
|
+
end
|
|
32
85
|
end
|
|
33
86
|
end
|
|
34
87
|
end
|
|
@@ -6,41 +6,114 @@ module ForemanAnsibleDirector
|
|
|
6
6
|
class AssignmentsController < AnsibleDirectorApiController
|
|
7
7
|
before_action :find_resource, only: %i[destroy]
|
|
8
8
|
|
|
9
|
+
resource_description { resource_id 'AD Ansible Content Assignments' }
|
|
10
|
+
|
|
11
|
+
# region ApiDoc: GET /api/v2/ansible_director/assignments/:target/:target_id
|
|
12
|
+
api :GET, '/v2/ansible_director/assignments/:target/:target_id',
|
|
13
|
+
N_('List Ansible content assignments for a target')
|
|
14
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
15
|
+
description <<~DESC
|
|
16
|
+
Retrieve all Ansible content units for a given target (host or hostgroup).
|
|
17
|
+
This includes content inherited through the assignment hierarchy and direct assignments.
|
|
18
|
+
If resolve is true, the server will try to map the assignment to an actual content unit available to target.
|
|
19
|
+
DESC
|
|
20
|
+
param :target,
|
|
21
|
+
%w[host hostgroup],
|
|
22
|
+
desc: N_('Type of the target entity.'),
|
|
23
|
+
required: true
|
|
24
|
+
param :target_id,
|
|
25
|
+
:number,
|
|
26
|
+
desc: N_('ID of the target entity.'),
|
|
27
|
+
required: true
|
|
28
|
+
param :resolve,
|
|
29
|
+
:boolean,
|
|
30
|
+
desc: N_('Resolve content units for assignments.'),
|
|
31
|
+
required: false
|
|
32
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
33
|
+
example <<~EXAMPLE
|
|
34
|
+
GET /api/v2/ansible_director/assignments/host/1
|
|
35
|
+
EXAMPLE
|
|
36
|
+
# endregion
|
|
9
37
|
def assignments
|
|
10
38
|
target = ::ForemanAnsibleDirector::AssignmentService.find_target(
|
|
11
39
|
target_type: params[:target],
|
|
12
40
|
target_id: params[:target_id]
|
|
13
41
|
)
|
|
14
42
|
# TODO: Null check target
|
|
15
|
-
@assignments =
|
|
43
|
+
@assignments, @resolved_assignments, @hierarchy = ::ForemanAnsibleDirector::AssignmentService.assignments_for(
|
|
44
|
+
target: target,
|
|
45
|
+
resolve: ::Foreman::Cast.to_bool(params[:resolve])
|
|
46
|
+
)
|
|
16
47
|
end
|
|
17
48
|
|
|
49
|
+
# region ApiDoc: POST /api/v2/ansible_director/assignments/:target/:target_id
|
|
50
|
+
api :POST, '/v2/ansible_director/assignments/:target/:target_id', N_('Assign Ansible content.')
|
|
51
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
52
|
+
description <<~DESC
|
|
53
|
+
Create Ansible content assignments for a target.
|
|
54
|
+
An assignment represents an Ansible role or Ansible collection role.
|
|
55
|
+
The version of this role is determined dynamically.
|
|
56
|
+
DESC
|
|
57
|
+
param :assignments, Array, desc: N_('Array of assignment objects.'), required: true do
|
|
58
|
+
param :assignable_type,
|
|
59
|
+
%w[ForemanAnsibleDirector::AnsibleCollectionRole ForemanAnsibleDirector::AnsibleRole],
|
|
60
|
+
desc: N_('Type of the Ansible content unit.'),
|
|
61
|
+
required: true
|
|
62
|
+
param :assignable_namespace,
|
|
63
|
+
String,
|
|
64
|
+
desc: N_('Namespace of the Ansible content unit.'),
|
|
65
|
+
required: true
|
|
66
|
+
param :assignable_name,
|
|
67
|
+
String,
|
|
68
|
+
desc: N_('Name of the Ansible content unit.'),
|
|
69
|
+
required: true
|
|
70
|
+
param :assignable_role_name,
|
|
71
|
+
String,
|
|
72
|
+
desc: <<~DESC,
|
|
73
|
+
Only required if assignable_type = "ForemanAnsibleDirector::AnsibleCollectionRole".
|
|
74
|
+
An identifier of a role in the supplied collection.
|
|
75
|
+
$assignable_namespace.$assignable_name.$assignable_role_name must form a fully qualified role name.
|
|
76
|
+
DESC
|
|
77
|
+
required: false
|
|
78
|
+
end
|
|
79
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
80
|
+
example <<~EXAMPLE
|
|
81
|
+
{
|
|
82
|
+
"assignments": [
|
|
83
|
+
{
|
|
84
|
+
"assignable_type": "ForemanAnsibleDirector::AnsibleCollectionRole",
|
|
85
|
+
"assignable_namespace": "manala",
|
|
86
|
+
"assignable_name": "roles",
|
|
87
|
+
"assignable_role_name": "motd"
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
EXAMPLE
|
|
92
|
+
# endregion
|
|
18
93
|
def assign
|
|
19
|
-
assignment = assignment_params
|
|
20
|
-
|
|
21
|
-
source = ::ForemanAnsibleDirector::AssignmentService.find_target(
|
|
22
|
-
target_type: assignment[:source][:type],
|
|
23
|
-
target_id: assignment[:source][:id]
|
|
24
|
-
)
|
|
25
|
-
|
|
26
94
|
target = ::ForemanAnsibleDirector::AssignmentService.find_target(
|
|
27
|
-
target_type:
|
|
28
|
-
target_id:
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
::ForemanAnsibleDirector::AssignmentService.create_assignment(
|
|
32
|
-
consumable: source,
|
|
33
|
-
assignable: target
|
|
95
|
+
target_type: params[:target],
|
|
96
|
+
target_id: params[:target_id]
|
|
34
97
|
)
|
|
35
|
-
end
|
|
36
98
|
|
|
37
|
-
def assign_bulk
|
|
38
99
|
assignments = bulk_assignment_params
|
|
39
100
|
::ForemanAnsibleDirector::AssignmentService.create_bulk_assignments(
|
|
101
|
+
target: target,
|
|
40
102
|
assignments: assignments
|
|
41
103
|
)
|
|
42
104
|
end
|
|
43
105
|
|
|
106
|
+
# region ApiDoc: DELETE /api/v2/ansible_director/assignments/:id
|
|
107
|
+
api :DELETE, '/v2/ansible_director/assignments/:id', N_('Delete an Ansible content assignment')
|
|
108
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
109
|
+
description <<~DESC
|
|
110
|
+
Note: This deletes the assignment record but not the underlying Ansible content.
|
|
111
|
+
DESC
|
|
112
|
+
param :id,
|
|
113
|
+
:number,
|
|
114
|
+
desc: N_('ID of the assignment to delete.'),
|
|
115
|
+
required: true
|
|
116
|
+
# endregion
|
|
44
117
|
def destroy
|
|
45
118
|
::ForemanAnsibleDirector::AssignmentService.destroy_assignment(@assignment)
|
|
46
119
|
end
|
|
@@ -62,10 +135,7 @@ module ForemanAnsibleDirector
|
|
|
62
135
|
return [] if params[:assignments].empty?
|
|
63
136
|
|
|
64
137
|
params.require(:assignments).map do |assignment|
|
|
65
|
-
assignment.permit(
|
|
66
|
-
source: %i[type id],
|
|
67
|
-
target: %i[type id]
|
|
68
|
-
)
|
|
138
|
+
assignment.permit(:assignable_type, :assignable_namespace, :assignable_name, :assignable_role_name)
|
|
69
139
|
end
|
|
70
140
|
end
|
|
71
141
|
end
|
|
@@ -6,13 +6,64 @@ module ForemanAnsibleDirector
|
|
|
6
6
|
class ExecutionEnvironmentsController < AnsibleDirectorApiController
|
|
7
7
|
include ::Api::Version2
|
|
8
8
|
|
|
9
|
-
before_action :find_resource, only: %i[update destroy]
|
|
9
|
+
before_action :find_resource, only: %i[show update destroy]
|
|
10
10
|
before_action :find_organization, only: %i[create]
|
|
11
11
|
|
|
12
|
+
resource_description { resource_id 'AD Ansible Execution Environments' }
|
|
13
|
+
|
|
14
|
+
# region ApiDoc: GET /api/v2/ansible_director/execution_environments
|
|
15
|
+
api :GET, '/v2/ansible_director/execution_environments', N_('List all execution environments')
|
|
16
|
+
param :organization_id, :number, desc: N_('Organization identifier.'), required: false
|
|
17
|
+
param_group :search_and_pagination, ::Api::V2::BaseController
|
|
18
|
+
# endregion
|
|
12
19
|
def index
|
|
13
20
|
@execution_environments = resource_scope_for_index
|
|
14
21
|
end
|
|
15
22
|
|
|
23
|
+
# region ApiDoc: GET /api/v2/ansible_director/execution_environments/:id
|
|
24
|
+
api :GET, '/v2/ansible_director/execution_environments/:id', N_('Show details of an execution environment')
|
|
25
|
+
param :id, :number, desc: N_('Execution Environment identifier.'), required: true
|
|
26
|
+
# endregion
|
|
27
|
+
def show
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# region ApiDoc: POST /api/v2/ansible_director/execution_environments
|
|
31
|
+
api :POST, '/v2/ansible_director/execution_environments', N_('Create an Execution Environment')
|
|
32
|
+
param :organization_id, :number, desc: N_('Organization identifier'), required: true
|
|
33
|
+
param :execution_environment, Hash, desc: N_('Execution Environment definition'), required: true do
|
|
34
|
+
param :name,
|
|
35
|
+
String,
|
|
36
|
+
desc: N_('Execution Environment name.'),
|
|
37
|
+
example: 'MyExecutionEnvironment',
|
|
38
|
+
required: true
|
|
39
|
+
param :base_image_url,
|
|
40
|
+
String,
|
|
41
|
+
desc: N_('Execution Environment base image URL. The image must be pullable by an unauthenticated user.'),
|
|
42
|
+
example: 'registry.fedoraproject.org/fedora:43',
|
|
43
|
+
required: true
|
|
44
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
45
|
+
param :ansible_version,
|
|
46
|
+
String,
|
|
47
|
+
desc: <<~DESC,
|
|
48
|
+
Version of "ansible-core" to be used in this execution environment.
|
|
49
|
+
The version must match one of the available releases.
|
|
50
|
+
See: https://pypi.org/project/ansible-core/#history
|
|
51
|
+
DESC
|
|
52
|
+
example: ::ForemanAnsibleDirector::Constants::DEFAULT_ANSIBLE_VERSION,
|
|
53
|
+
required: true
|
|
54
|
+
end
|
|
55
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
56
|
+
example <<~EXAMPLE
|
|
57
|
+
{
|
|
58
|
+
"organization_id": 1,
|
|
59
|
+
"execution_environment": {
|
|
60
|
+
"name": "EE-2.20.0",
|
|
61
|
+
"base_image_url": "quay.io/fedora/fedora:42",
|
|
62
|
+
"ansible_version": "2.20.0"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
EXAMPLE
|
|
66
|
+
# endregion
|
|
16
67
|
def create
|
|
17
68
|
permitted_params = execution_environment_params
|
|
18
69
|
# content = permitted_params.delete(:content)
|
|
@@ -25,6 +76,41 @@ module ForemanAnsibleDirector
|
|
|
25
76
|
)
|
|
26
77
|
end
|
|
27
78
|
|
|
79
|
+
# region ApiDoc: PATCH /api/v2/ansible_director/execution_environments/:id
|
|
80
|
+
api :PATCH, '/v2/ansible_director/execution_environments/:id', N_('Update an Execution Environment')
|
|
81
|
+
param :execution_environment, Hash, desc: N_('Execution Environment definition'), required: true do
|
|
82
|
+
param :name,
|
|
83
|
+
String,
|
|
84
|
+
desc: N_('Execution Environment name.'),
|
|
85
|
+
example: 'MyExecutionEnvironment',
|
|
86
|
+
required: false
|
|
87
|
+
param :base_image_url,
|
|
88
|
+
String,
|
|
89
|
+
desc: N_('Execution Environment base image URL. The image must be pullable by an unauthenticated user.'),
|
|
90
|
+
example: 'registry.fedoraproject.org/fedora:43',
|
|
91
|
+
required: false
|
|
92
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
93
|
+
param :ansible_version,
|
|
94
|
+
String,
|
|
95
|
+
desc: <<~DESC,
|
|
96
|
+
Version of "ansible-core" to be used in this execution environment.
|
|
97
|
+
The version must match one of the available releases.
|
|
98
|
+
See: https://pypi.org/project/ansible-core/#history
|
|
99
|
+
DESC
|
|
100
|
+
example: ::ForemanAnsibleDirector::Constants::DEFAULT_ANSIBLE_VERSION,
|
|
101
|
+
required: false
|
|
102
|
+
end
|
|
103
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
104
|
+
example <<~EXAMPLE
|
|
105
|
+
{
|
|
106
|
+
"execution_environment": {
|
|
107
|
+
"name": "EE-2.20.0",
|
|
108
|
+
"base_image_url": "quay.io/fedora/fedora:42",
|
|
109
|
+
"ansible_version": "2.20.0"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
EXAMPLE
|
|
113
|
+
# endregion
|
|
28
114
|
def update
|
|
29
115
|
permitted_params = execution_environment_params
|
|
30
116
|
# content = permitted_params.delete(:content)
|
|
@@ -37,6 +123,9 @@ module ForemanAnsibleDirector
|
|
|
37
123
|
)
|
|
38
124
|
end
|
|
39
125
|
|
|
126
|
+
# region ApiDoc: DELETE /api/v2/ansible_director/execution_environments/:id
|
|
127
|
+
api :DELETE, '/v2/ansible_director/execution_environments/:id', N_('Delete an Execution Environment')
|
|
128
|
+
# endregion
|
|
40
129
|
def destroy
|
|
41
130
|
@execution_environment.destroy
|
|
42
131
|
::ForemanAnsibleDirector::ExecutionEnvironmentService.destroy_execution_environment @execution_environment
|