foreman_ansible_director 0.5.0 → 0.7.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 +30 -18
- data/app/controllers/foreman_ansible_director/api/v2/ansible_director_api_controller.rb +73 -3
- data/app/controllers/foreman_ansible_director/api/v2/ansible_variable_bindings_controller.rb +347 -0
- data/app/controllers/foreman_ansible_director/api/v2/ansible_variables_controller.rb +208 -31
- data/app/controllers/foreman_ansible_director/api/v2/assignments_controller.rb +106 -112
- data/app/controllers/foreman_ansible_director/api/v2/execution_environments_controller.rb +16 -1
- data/app/controllers/foreman_ansible_director/api/v2/lifecycle_environment_paths_controller.rb +18 -2
- data/app/controllers/foreman_ansible_director/api/v2/lifecycle_environments_controller.rb +7 -4
- data/app/controllers/foreman_ansible_director/api/v2/status_controller.rb +5 -12
- data/app/controllers/foreman_ansible_director/concerns/filtered_auto_complete_search.rb +34 -0
- data/app/controllers/foreman_ansible_director/concerns/foreman/controller/host_extensions.rb +34 -0
- data/app/controllers/foreman_ansible_director/concerns/foreman/controller/hostgroup_extensions.rb +34 -0
- data/app/lib/foreman_ansible_director/abstract/content_resolution_node.rb +31 -0
- data/app/lib/foreman_ansible_director/abstract/content_source.rb +19 -0
- data/app/lib/foreman_ansible_director/abstract/variables/value_query.rb +13 -0
- data/app/lib/foreman_ansible_director/abstract/variables/value_transformer.rb +13 -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 +55 -19
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import.rb +28 -29
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/galaxy/import_collection.rb +2 -1
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/galaxy/rescue.rb +4 -8
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/galaxy/update_collection.rb +17 -4
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/git/import_collection.rb +2 -1
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/git/rescue.rb +4 -8
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/index/dynamic/index_git_collection.rb +5 -4
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/index/index_git_collection.rb +5 -4
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/index/index_static.rb +23 -13
- 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/proxy/build_execution_environment.rb +12 -3
- 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/list_all.rb +57 -0
- 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/list_all.rb +57 -0
- 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 +67 -26
- data/app/lib/foreman_ansible_director/actions/remote_execution/Provider/ansible_script_provider.rb +23 -11
- data/app/lib/foreman_ansible_director/actions/rescue/ansible_content_unit/common/cleanup_check.rb +2 -1
- 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/ansible_variable_value/query/local.rb +17 -0
- data/app/lib/foreman_ansible_director/ansible_variable_value/transformer/static.rb +16 -0
- data/app/lib/foreman_ansible_director/ansible_variable_value/value_resolution.rb +26 -0
- data/app/lib/foreman_ansible_director/generators/content_generator.rb +33 -34
- data/app/lib/foreman_ansible_director/generators/inventory_generator.rb +3 -3
- data/app/lib/foreman_ansible_director/generators/playbook_generator.rb +17 -22
- data/app/lib/foreman_ansible_director/generators/variable_generator.rb +37 -16
- data/app/lib/foreman_ansible_director/issues/base_issue.rb +22 -0
- data/app/lib/foreman_ansible_director/issues/critical_error_exception.rb +8 -0
- data/app/lib/foreman_ansible_director/issues/errors/base_error.rb +21 -0
- data/app/lib/foreman_ansible_director/issues/errors/internal_error.rb +36 -0
- data/app/lib/foreman_ansible_director/issues/errors/invalid_yaml_error.rb +33 -0
- data/app/lib/foreman_ansible_director/issues/errors/no_proxy_for_build.rb +27 -0
- data/app/lib/foreman_ansible_director/issues/errors/parameter_missing_error.rb +30 -0
- data/app/lib/foreman_ansible_director/issues/errors/record_not_found.rb +29 -0
- data/app/lib/foreman_ansible_director/issues/errors/staging_product_missing.rb +31 -0
- data/app/lib/foreman_ansible_director/issues/warnings/base_warning.rb +17 -0
- data/app/lib/foreman_ansible_director/issues/warnings/invalid_collection_role_reference.rb +37 -0
- data/app/lib/foreman_ansible_director/issues/warnings/invalid_collection_role_variable_ref.rb +42 -0
- data/app/lib/foreman_ansible_director/issues/warnings/invalid_role_reference.rb +34 -0
- data/app/lib/foreman_ansible_director/issues/warnings/invalid_role_variable_ref.rb +40 -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/issues/warnings/no_resolution_candidate_for_variable_binding.rb +28 -0
- data/app/lib/foreman_ansible_director/logging/loggable_model.rb +33 -0
- data/app/lib/foreman_ansible_director/parsers/proxy/dynflow/task_status_parser.rb +3 -5
- data/app/models/foreman_ansible_director/ansible_collection.rb +0 -4
- data/app/models/foreman_ansible_director/ansible_collection_role.rb +8 -0
- data/app/models/foreman_ansible_director/ansible_content_assignment.rb +0 -10
- data/app/models/foreman_ansible_director/ansible_director_model.rb +8 -0
- data/app/models/foreman_ansible_director/ansible_role.rb +0 -3
- data/app/models/foreman_ansible_director/ansible_variable.rb +39 -5
- data/app/models/foreman_ansible_director/ansible_variable_binding.rb +47 -0
- data/app/models/foreman_ansible_director/concerns/ansible_execution_extensions.rb +57 -0
- data/app/models/foreman_ansible_director/concerns/content_consumer.rb +3 -1
- data/app/models/foreman_ansible_director/concerns/host_extensions.rb +26 -0
- data/app/models/foreman_ansible_director/concerns/hostgroup_extensions.rb +25 -0
- data/app/models/foreman_ansible_director/concerns/organization_extensions.rb +4 -0
- data/app/models/foreman_ansible_director/content_unit.rb +3 -0
- data/app/models/foreman_ansible_director/content_unit_version.rb +6 -2
- data/app/models/foreman_ansible_director/execution_environment.rb +41 -9
- data/app/models/foreman_ansible_director/lifecycle_environment.rb +56 -8
- data/app/models/foreman_ansible_director/lifecycle_environment_path.rb +17 -0
- data/app/overrides/hostgroups_ansible_content_tab.rb +15 -0
- data/app/overrides/hosts_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_build_proxy_selector.rb +16 -0
- data/app/services/foreman_ansible_director/ansible_director_run_proxy_selector.rb +12 -0
- data/app/services/foreman_ansible_director/ansible_director_service.rb +9 -0
- data/app/services/foreman_ansible_director/assignment_service.rb +189 -27
- data/app/services/foreman_ansible_director/concerns/organization_creator_extensions.rb +24 -0
- data/app/services/foreman_ansible_director/execution_environment_service.rb +53 -14
- 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/proxy/base_client.rb +2 -2
- data/app/services/foreman_ansible_director/proxy/dynflow/single_batch_action.rb +2 -2
- data/app/services/foreman_ansible_director/proxy/dynflow/task_status.rb +2 -2
- 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 +1 -1
- data/app/services/foreman_ansible_director/request_ctx/request_context.rb +96 -0
- data/app/services/foreman_ansible_director/request_ctx/request_context_helper.rb +11 -0
- data/app/services/foreman_ansible_director/variable_binding_service.rb +53 -0
- data/app/services/foreman_ansible_director/variable_service.rb +250 -113
- 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_content/version_detail.json.rabl +3 -16
- data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/create.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/destroy.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/index_for_variable.json.rabl +9 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/show.json.rabl +7 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/update_full.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/update_partial.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variables/index_acr.json.rabl +9 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variables/resolve_single.json.rabl +34 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variables/show.json.rabl +3 -18
- data/app/views/foreman_ansible_director/api/v2/ansible_variables/update_full.json.rabl +7 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variables/update_partial.json.rabl +7 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variables/variables_for_target.json.rabl +58 -0
- 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 +63 -24
- data/app/views/foreman_ansible_director/api/v2/assignments/preresolve.json.rabl +70 -0
- data/app/views/foreman_ansible_director/api/v2/common/response.json.rabl +25 -0
- data/app/views/foreman_ansible_director/api/v2/execution_environments/create.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/execution_environments/destroy.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/execution_environments/show.json.rabl +22 -0
- data/app/views/foreman_ansible_director/api/v2/execution_environments/update.json.rabl +3 -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_environment_paths/create.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environment_paths/destroy.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environment_paths/promote.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environment_paths/show.json.rabl +7 -0
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environment_paths/update.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environments/create.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environments/destroy.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environments/show.json.rabl +3 -32
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environments/update.json.rabl +3 -0
- data/app/views/foreman_ansible_director/overrides/_hostgroups_main_fields.erb +34 -0
- data/app/views/foreman_ansible_director/overrides/_hostgroups_tab_content.erb +12 -0
- data/app/views/foreman_ansible_director/overrides/_hostgroups_tab_title.erb +3 -0
- data/app/views/foreman_ansible_director/overrides/_hosts_main_fields.erb +34 -0
- data/app/views/foreman_ansible_director/overrides/_hosts_tab_content.erb +12 -0
- data/app/views/foreman_ansible_director/overrides/_hosts_tab_title.erb +3 -0
- data/config/routes.rb +31 -19
- data/db/migrate/20260316000001_ansible_director_schema.rb +12 -4
- data/db/migrate/20260630000001_scope_execution_environment_names_to_organization.rb +14 -0
- data/db/migrate/20260630000002_scope_content_unit_identity_to_organization.rb +14 -0
- data/db/migrate/20260727000001_ad_variable_redesign.rb +51 -0
- data/db/seeds.d/100-provision_after_build_params.rb +10 -0
- data/lib/foreman_ansible_director/constants.rb +5 -1
- data/lib/foreman_ansible_director/engine.rb +8 -2
- data/lib/foreman_ansible_director/register.rb +113 -44
- data/lib/foreman_ansible_director/remote_execution.rb +7 -0
- data/lib/tasks/create_staging_products.rake +34 -0
- data/lib/tasks/uninstall.rake +44 -0
- data/package.json +18 -15
- data/test/ansible_content/unit/simple_ansible_content_unit_test.rb +164 -0
- data/test/controllers/api/v2/ansible_content_controller_test.rb +142 -0
- data/test/controllers/api/v2/execution_environments_controller_test.rb +146 -0
- data/test/controllers/api/v2/lifecycle_environment_paths_controller_test.rb +126 -0
- data/test/factories/ansible_content_assignments_factory.rb +23 -0
- data/test/factories/ansible_variable_bindings_factory.rb +51 -0
- data/test/factories/ansible_variables_factory.rb +32 -5
- data/test/factories/extensions.rb +13 -0
- data/test/foreman_ansible_director_test_helper.rb +28 -2
- data/test/generators/unit/variable_generator_test.rb +272 -0
- data/test/models/unit/ansible_variable_binding_test.rb +250 -0
- data/test/models/unit/ansible_variable_test.rb +180 -0
- data/test/models/unit/content_unit_test.rb +74 -0
- data/test/models/unit/execution_environment_test.rb +299 -0
- data/test/services/unit/action_service_test.rb +173 -0
- data/test/services/unit/assignment_service_test.rb +240 -101
- data/test/services/unit/content_service_test.rb +153 -0
- data/test/services/unit/execution_environment_service_test.rb +44 -24
- data/test/services/unit/variable_service_test.rb +540 -136
- data/webpack/components/ansible_content/AnsibleContentPageWrapper.tsx +8 -3
- data/webpack/components/ansible_content/components/AnsibleContentTable.tsx +27 -38
- data/webpack/components/ansible_content/components/AnsibleContentTablePrimaryRow.tsx +37 -9
- data/webpack/components/ansible_content/components/AnsibleContentTableSecondaryRow.tsx +52 -35
- data/webpack/components/ansible_content/components/AnsibleContentTableWrapper.tsx +33 -9
- data/webpack/components/ansible_content/components/AnsibleContentWizard/AnsibleContentWizard.tsx +3 -7
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/ProviderSelectionStep.tsx +6 -2
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/ReviewStep.tsx +2 -2
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/FinishFooter.tsx +42 -17
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/GalaxyContentUnitInput.tsx +9 -7
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/GitContentUnitInput.tsx +10 -12
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/components/GitRefInput.tsx +2 -5
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/components/VersionInput.tsx +2 -5
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/TargetNodeSelector.tsx +263 -0
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/ValueAdapters/ArrayAdapter.tsx +209 -0
- data/webpack/components/ansible_content/components/ConsistencyCheckModal.tsx +140 -0
- data/webpack/components/ansible_content/components/Variables/CollectionOverviewWrapper.tsx +49 -0
- data/webpack/components/ansible_content/components/Variables/CollectionRoleOverview.tsx +140 -0
- data/webpack/components/ansible_content/components/Variables/ManagementDrawer.tsx +89 -0
- data/webpack/components/ansible_content/components/Variables/VariableList.tsx +166 -0
- data/webpack/components/ansible_content/components/Variables/VariableListWrapper.tsx +59 -0
- data/webpack/components/ansible_content/components/Variables/components/DrawerBindingContent.tsx +170 -0
- data/webpack/components/ansible_content/components/Variables/components/DrawerBindingContentWrapper.tsx +62 -0
- data/webpack/components/ansible_content/components/Variables/components/DrawerVariableContent.tsx +134 -0
- data/webpack/components/ansible_content/components/Variables/components/components/BindingCreateContent.tsx +174 -0
- data/webpack/components/ansible_content/components/Variables/components/components/BindingDetailsContent.tsx +95 -0
- data/webpack/components/ansible_content/components/Variables/components/components/BindingIndexContent.tsx +181 -0
- data/webpack/components/ansible_environments/AnsibleEnvironmentsPageWrapper.tsx +8 -2
- data/webpack/components/ansible_environments/components/AnsibleLcePathIndex.tsx +5 -3
- data/webpack/components/ansible_environments/components/AnsibleLcePathIndexWrapper.tsx +19 -19
- data/webpack/components/ansible_environments/components/components/AnsibleExecutionEnvSelectionModal.tsx +4 -3
- data/webpack/components/ansible_environments/components/components/AnsibleExecutionEnvSelectionModalWrapper.tsx +1 -1
- data/webpack/components/ansible_environments/components/components/AnsibleLceComponent.tsx +1 -1
- data/webpack/components/ansible_environments/components/components/AnsibleLceComponentWrapper.tsx +3 -2
- data/webpack/components/ansible_environments/components/components/AnsibleLcePathComponent.tsx +36 -122
- data/webpack/components/ansible_environments/components/components/AnsibleLibraryOverview.tsx +4 -5
- data/webpack/components/ansible_execution_environments/AnsibleExecutionEnvPageWrapper.tsx +8 -2
- data/webpack/components/ansible_execution_environments/ExecutionEnvGrid.tsx +6 -37
- data/webpack/components/ansible_execution_environments/components/ContentUnitModal.tsx +4 -4
- data/webpack/components/ansible_execution_environments/components/ExecutionEnvCard.tsx +11 -17
- data/webpack/components/ansible_execution_environments/components/ExecutionEnvCardHeaderActions.tsx +62 -30
- data/webpack/components/ansible_execution_environments/components/ExecutionEnvCardWrapper.tsx +214 -0
- data/webpack/components/ansible_execution_environments/components/ExecutionEnvCreateCard.tsx +75 -53
- data/webpack/components/ansible_execution_environments/components/ExecutionEnvEditCard.tsx +3 -0
- data/webpack/components/ansible_execution_environments/components/ExecutionEnvGridWrapper.tsx +18 -157
- data/webpack/components/ansible_execution_environments/components/components/components/ContentUnitSelector.tsx +1 -2
- data/webpack/components/common/AlertModal.tsx +52 -0
- data/webpack/components/common/Alerts/AlertContext.tsx +174 -0
- data/webpack/components/common/AnsibleContentAssignment/AnsibleContentAssignment.tsx +352 -0
- data/webpack/components/common/AnsibleContentAssignment/AnsibleContentAssignmentMain.tsx +36 -0
- data/webpack/components/common/AnsibleContentAssignment/AnsibleContentAssignmentWrapper.tsx +78 -0
- data/webpack/components/common/AnsibleContentAssignment/AssignmentContext.tsx +289 -0
- data/webpack/components/common/AnsibleContentAssignment/components/AssignmentSelector.tsx +296 -0
- data/webpack/components/common/AnsibleContentAssignment/components/AssignmentSelectorWrapper.tsx +113 -0
- data/webpack/components/common/AnsibleContentAssignment/components/ContentAssignmentTable.tsx +285 -0
- data/webpack/components/common/AnsibleContentAssignment/components/HierarchyLevelSelector.tsx +47 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/VariableContext.tsx +169 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/VariableTableWrapper.tsx +41 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/BindingDetailModal.tsx +515 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/BindingDetailModalWrapper.tsx +97 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/InlineValueRenderer.tsx +68 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/ValuePresenter.tsx +202 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/VariableAssignmentTableToolbar.tsx +34 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/VariablesAssignmentTable.tsx +112 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/VariablesTable.tsx +173 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/VariablesTableToolbar.tsx +34 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/CrossNodeDisabledAlert.tsx +46 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/DetailsCard.tsx +168 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/ValueCard.tsx +143 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/ValueCardWrapper.tsx +77 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/YamlErrorState.tsx +40 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/YamlParsedTypeMismatchErrorState.tsx +35 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/YamlParserErrorState.tsx +38 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/utils.ts +70 -0
- data/webpack/components/common/AnsibleContentAssignment/helpers.ts +52 -0
- data/webpack/components/common/ForceTaxonomy.tsx +248 -0
- data/webpack/components/common/Page.tsx +0 -2
- data/webpack/components/common/Permitted.tsx +47 -0
- data/webpack/components/common/YamlEditor.tsx +30 -20
- data/webpack/components/common/__test__/Permitted.test.tsx +88 -0
- data/webpack/components/common/components/TaxonSelector.tsx +81 -0
- data/webpack/components/extensions/components/InheritComponent.tsx +0 -1
- data/webpack/components/extensions/host_details/HostDetailsLceCard/HostDetailsLceCard.tsx +144 -58
- 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 +13 -63
- data/webpack/constants/foremanAnsibleDirectorPermissions.ts +6 -6
- data/webpack/helpers/adContext.ts +19 -0
- data/webpack/helpers/comparisons.ts +6 -0
- data/webpack/helpers/components/ConfirmationModal.tsx +27 -17
- data/webpack/helpers/components/__test__/ConfirmationModal.test.tsx +0 -25
- data/webpack/helpers/constants.ts +1 -19
- data/webpack/helpers/hooks/useFetch.ts +104 -0
- data/webpack/helpers/hooks/useHybridSearch.ts +261 -0
- data/webpack/helpers/hooks/useLegacySelectValue.tsx +67 -0
- data/webpack/helpers/toasts/crudToasts.tsx +75 -0
- data/webpack/helpers/toasts/promoteToasts.tsx +53 -0
- data/webpack/helpers/toasts/useToasts.tsx +142 -0
- data/webpack/helpers/typeGuards/contentAssignmentTypeGuards.ts +22 -0
- data/webpack/index.js +3 -3
- data/webpack/resources/backendClient.ts +150 -0
- data/webpack/resources/clients/AnsibleVariable.ts +78 -0
- data/webpack/resources/clients/AnsibleVariableBinding.ts +104 -0
- data/webpack/resources/clients/ExecutionEnvironment.ts +77 -0
- data/webpack/resources/clients/LifecycleEnvironmentPath.ts +114 -0
- data/webpack/resources/types.ts +13 -0
- data/webpack/resources/utils.ts +12 -0
- data/webpack/routes/routes.tsx +6 -6
- data/webpack/types/AnsibleContentAssignmentTypes.d.ts +49 -0
- data/webpack/types/AnsibleContentTypes.d.ts +15 -4
- data/webpack/types/AnsibleEnvironmentsTypes.d.ts +0 -4
- data/webpack/types/AnsibleExecutionEnvTypes.d.ts +2 -11
- data/webpack/types/AnsibleVariableTypes.d.ts +64 -37
- data/webpack/types/DynamicAssignmentTypes.d.ts +22 -0
- data/webpack/types/common.d.ts +59 -0
- data/webpack/types/foremanReact/Root/Context/ForemanContext.d.ts +25 -8
- data/webpack/types/foremanReact/common/hooks/API/APIHooks.d.ts +0 -2
- data/webpack/types/foremanReact/components/Pagination/index.d.ts +0 -1
- data/webpack/types/foremanReact/components/PermissionDenied/PermissionDenied.d.ts +13 -0
- data/webpack/types/foremanReact/components/ToastsList/slice.d.ts +4 -2
- data/webpack/types/issues/errors.d.ts +5 -0
- data/webpack/types/issues/types.ts +5 -0
- data/webpack/types/issues/warnings.d.ts +11 -0
- metadata +210 -110
- data/app/controllers/foreman_ansible_director/api/v2/ansible_runs_controller.rb +0 -35
- data/app/controllers/foreman_ansible_director/api/v2/ansible_variable_overrides_controller.rb +0 -199
- data/app/models/foreman_ansible_director/ansible_content_assignment_collection_role.rb +0 -9
- data/app/models/foreman_ansible_director/concerns/lookup_keys_extensions.rb +0 -13
- data/app/overrides/create_host_ansible_tab.rb +0 -15
- data/app/services/foreman_ansible_director/ansible_director_proxy_selector.rb +0 -20
- 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/ansible_variable_overrides/index_for_target.json.rabl +0 -35
- 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/AnsibleVariablesOverview.tsx +0 -103
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/AnsibleVariablesSelector.tsx +0 -319
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/AnsibleVariablesViewer.tsx +0 -0
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/MatcherSelector.tsx +0 -212
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/OverrideCard.tsx +0 -118
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/OverrideManagementModal.tsx +0 -372
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/OverridesTabContent.tsx +0 -240
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/VariableManagementModalContent.tsx +0 -372
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/VariableManagementModalWrapper.tsx +0 -74
- 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/components/extensions/host_details/HostDetailsTab/components/MergedOverrideCard.tsx +0 -285
- data/webpack/components/extensions/host_details/HostDetailsTab/components/OverrideGrid.tsx +0 -60
- data/webpack/components/extensions/host_details/HostDetailsTab/components/OverrideGridWrapper.tsx +0 -67
- 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: 20d1091937c1d76ecd26e040e861d757cc36110d28a60e74630b3cfb168db165
|
|
4
|
+
data.tar.gz: f1da955ee815b2f80233760544a9732daa44ca6713996b048f2f8b20d374b745
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b0a246ed2de42e751eac1f80e11b1fc10350a68b83babfcfceeed2df2a72cb76455f8d3094e18cafea12d973ba76d974586a561151fae60378bc9005e8d0b942
|
|
7
|
+
data.tar.gz: c13404a68266d31c7535b2658a10f8a67ee3a047cb1a817d1d475df981f2ac2461e48b9a2703b9f605a8ad9a3805c2ab80ff4a102ed420d30f505c45fb33aa51
|
|
@@ -5,7 +5,9 @@ module ForemanAnsibleDirector
|
|
|
5
5
|
module V2
|
|
6
6
|
class AnsibleContentController < AnsibleDirectorApiController
|
|
7
7
|
before_action :find_organization, only: %i[create_units]
|
|
8
|
-
|
|
8
|
+
# rubocop:disable Rails/LexicallyScopedActionFilter
|
|
9
|
+
before_action :find_optional_organization, only: %i[index auto_complete_search]
|
|
10
|
+
# rubocop:enable Rails/LexicallyScopedActionFilter
|
|
9
11
|
|
|
10
12
|
resource_description { resource_id 'AD Ansible Content' }
|
|
11
13
|
|
|
@@ -59,10 +61,12 @@ module ForemanAnsibleDirector
|
|
|
59
61
|
resolved = ::ForemanAnsibleDirector::AnsibleContent::AnsibleContentHelpers.resolve_import_payload(
|
|
60
62
|
params[:units]
|
|
61
63
|
)
|
|
62
|
-
@bulk_create_task =
|
|
64
|
+
@bulk_create_task = ::ForemanAnsibleDirector::ActionService.trigger(
|
|
63
65
|
::ForemanAnsibleDirector::Actions::AnsibleContentUnit::Bulk::Import,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
task_args: {
|
|
67
|
+
resolved_content_units: resolved,
|
|
68
|
+
organization_id: @organization.id,
|
|
69
|
+
}
|
|
66
70
|
)
|
|
67
71
|
end
|
|
68
72
|
|
|
@@ -70,14 +74,10 @@ module ForemanAnsibleDirector
|
|
|
70
74
|
api :GET, '/v2/ansible_director/ansible_content', N_('List Ansible content units')
|
|
71
75
|
param :organization_id, :number, desc: N_('Organization identifier'), required: false
|
|
72
76
|
param_group :search_and_pagination, ::Api::V2::BaseController
|
|
77
|
+
add_scoped_search_description_for(::ForemanAnsibleDirector::ContentUnit)
|
|
73
78
|
# endregion
|
|
74
79
|
def index
|
|
75
|
-
|
|
76
|
-
@ansible_content_units = if @organization
|
|
77
|
-
scope.where(organization_id: @organization.id)
|
|
78
|
-
else
|
|
79
|
-
scope
|
|
80
|
-
end
|
|
80
|
+
@ansible_content_units = resource_scope_for_index
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
# region ApiDoc: GET /api/v2/ansible_director/ansible_content/:content_unit_id/versions/:content_unit_version_id
|
|
@@ -122,15 +122,32 @@ module ForemanAnsibleDirector
|
|
|
122
122
|
resolved = ::ForemanAnsibleDirector::AnsibleContent::AnsibleContentHelpers.resolve_destroy_payload(
|
|
123
123
|
destroy_params
|
|
124
124
|
)
|
|
125
|
-
@bulk_destroy_task =
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
@bulk_destroy_task = ::ForemanAnsibleDirector::ActionService.trigger(
|
|
126
|
+
::ForemanAnsibleDirector::Actions::AnsibleContentUnit::Bulk::Destroy,
|
|
127
|
+
task_args: {
|
|
128
|
+
resolved_content_units: resolved,
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# region ApiDoc: POST /api/v2/ansible_director/ansible_content/consistency_check
|
|
134
|
+
api :POST, '/v2/ansible_director/ansible_content/consistency_check',
|
|
135
|
+
N_('Run a consistency check to clean up the database after a failed content import.')
|
|
136
|
+
# endregion
|
|
137
|
+
def consistency_check
|
|
138
|
+
@consistency_check = ::ForemanAnsibleDirector::ActionService.trigger(
|
|
139
|
+
::ForemanAnsibleDirector::Actions::ConsistencyCheck::Perform
|
|
140
|
+
)
|
|
128
141
|
end
|
|
129
142
|
|
|
130
143
|
def model_of_controller
|
|
131
144
|
resource_class
|
|
132
145
|
end
|
|
133
146
|
|
|
147
|
+
def resource_scope
|
|
148
|
+
organization_scoped_resource_scope
|
|
149
|
+
end
|
|
150
|
+
|
|
134
151
|
private
|
|
135
152
|
|
|
136
153
|
def destroy_params
|
|
@@ -150,11 +167,6 @@ module ForemanAnsibleDirector
|
|
|
150
167
|
def resource_class
|
|
151
168
|
::ForemanAnsibleDirector::ContentUnit
|
|
152
169
|
end
|
|
153
|
-
|
|
154
|
-
def index_relation
|
|
155
|
-
units = AnsibleContentUnit
|
|
156
|
-
units.where organization_id: (params[:organization_id] || @organization.id)
|
|
157
|
-
end
|
|
158
170
|
end
|
|
159
171
|
end
|
|
160
172
|
end
|
|
@@ -5,10 +5,57 @@ module ForemanAnsibleDirector
|
|
|
5
5
|
module V2
|
|
6
6
|
class AnsibleDirectorApiController < ::Api::V2::BaseController
|
|
7
7
|
include ::Api::Version2
|
|
8
|
-
include ::
|
|
8
|
+
include ::ForemanAnsibleDirector::Concerns::FilteredAutoCompleteSearch
|
|
9
|
+
|
|
10
|
+
include ::ForemanAnsibleDirector::RequestCtx::RequestContextHelper
|
|
11
|
+
|
|
12
|
+
around_action :attach_request_ctx
|
|
13
|
+
|
|
14
|
+
rescue_from StandardError do |error|
|
|
15
|
+
@ctx.add_error(::ForemanAnsibleDirector::Issues::Errors::InternalError.new(
|
|
16
|
+
exception: error,
|
|
17
|
+
coincidence_id: @ctx.coincidence_id
|
|
18
|
+
))
|
|
19
|
+
render_default_response
|
|
20
|
+
# Re-raise the exception to get a traceback in the log
|
|
21
|
+
raise error
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
rescue_from ActiveRecord::RecordNotFound do |error|
|
|
25
|
+
@ctx.add_error(::ForemanAnsibleDirector::Issues::Errors::RecordNotFound.new(exception: error))
|
|
26
|
+
render_default_response
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
rescue_from ActionController::ParameterMissing do |error|
|
|
30
|
+
@ctx.add_error(::ForemanAnsibleDirector::Issues::Errors::ParameterMissingError.new(exception: error))
|
|
31
|
+
render_default_response
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
rescue_from Psych::SyntaxError do |error|
|
|
35
|
+
@ctx.add_error(::ForemanAnsibleDirector::Issues::Errors::InvalidYamlError.new(exception: error))
|
|
36
|
+
render_default_response
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
rescue_from ::ForemanAnsibleDirector::Issues::CriticalErrorException do |_|
|
|
40
|
+
render_default_response
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def attach_request_ctx
|
|
44
|
+
::ForemanAnsibleDirector::RequestCtx::RequestContext.with_context(
|
|
45
|
+
::ForemanAnsibleDirector::RequestCtx::RequestContext.new(request.request_id)
|
|
46
|
+
) do
|
|
47
|
+
@ctx = ctx
|
|
48
|
+
yield
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def render_default_response
|
|
53
|
+
return if performed?
|
|
54
|
+
render template: 'foreman_ansible_director/api/v2/common/response', status: @ctx.response_status_code
|
|
55
|
+
end
|
|
9
56
|
|
|
10
57
|
def find_organization
|
|
11
|
-
@organization = Organization.current
|
|
58
|
+
@organization = find_optional_organization || Organization.current
|
|
12
59
|
if @organization.nil?
|
|
13
60
|
render_error(
|
|
14
61
|
'custom_error',
|
|
@@ -21,6 +68,29 @@ module ForemanAnsibleDirector
|
|
|
21
68
|
@organization
|
|
22
69
|
end
|
|
23
70
|
|
|
71
|
+
def organization_scoped_resource_scope(scope = resource_class.all)
|
|
72
|
+
return scope.none if User.current.blank?
|
|
73
|
+
organization = @organization || Organization.current
|
|
74
|
+
if organization.nil?
|
|
75
|
+
if User.current.admin?
|
|
76
|
+
scope
|
|
77
|
+
else
|
|
78
|
+
scope.where(organization_id: User.current.my_organizations)
|
|
79
|
+
end
|
|
80
|
+
else
|
|
81
|
+
scope.where(organization_id: organization.id)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def action_permission
|
|
86
|
+
case params[:action]
|
|
87
|
+
when 'auto_complete_search'
|
|
88
|
+
:view
|
|
89
|
+
else
|
|
90
|
+
super
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
24
94
|
private
|
|
25
95
|
|
|
26
96
|
def organization_id_keys
|
|
@@ -37,7 +107,7 @@ module ForemanAnsibleDirector
|
|
|
37
107
|
|
|
38
108
|
@organization = get_organization(org_id)
|
|
39
109
|
if @organization.nil?
|
|
40
|
-
render_error('custom_error', status: :
|
|
110
|
+
render_error('custom_error', status: :not_found,
|
|
41
111
|
locals: { message: "Couldn't find organization #{org_id}" })
|
|
42
112
|
end
|
|
43
113
|
@organization
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ForemanAnsibleDirector
|
|
4
|
+
module Api
|
|
5
|
+
module V2
|
|
6
|
+
class AnsibleVariableBindingsController < AnsibleDirectorApiController
|
|
7
|
+
before_action :find_resource, only: %w[show destroy update_full update_partial]
|
|
8
|
+
before_action :find_variable, only: [:index_for_variable]
|
|
9
|
+
|
|
10
|
+
before_action :find_organization, only: %i[create]
|
|
11
|
+
# rubocop:disable Rails/LexicallyScopedActionFilter
|
|
12
|
+
before_action :find_optional_organization, only: %i[index_for_variable auto_complete_search]
|
|
13
|
+
# rubocop:enable Rails/LexicallyScopedActionFilter
|
|
14
|
+
resource_description { resource_id 'AD Ansible Variable Bindings' }
|
|
15
|
+
|
|
16
|
+
def index_for_variable
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# region ApiDoc: GET /api/v2/ansible_director/ansible_variables/bindings/:id
|
|
20
|
+
api :GET, '/v2/ansible_director/ansible_variables/bindings/:id', N_('Show details of a variable binding')
|
|
21
|
+
param :id, :number, desc: N_('Variable binding identifier'), required: true
|
|
22
|
+
# endregion
|
|
23
|
+
def show
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# region ApiDoc: POST /api/v2/ansible_director/ansible_variables/bindings
|
|
27
|
+
api :POST, '/api/v2/ansible_director/ansible_variables/bindings', N_('Create a variable binding')
|
|
28
|
+
param :organization_id, :number, desc: N_('Organization identifier'), required: true
|
|
29
|
+
param :ansible_variable_binding, Hash, desc: N_('Variable binding definition'), required: true do
|
|
30
|
+
param :variable_name,
|
|
31
|
+
String,
|
|
32
|
+
desc: N_('Name of the Ansible variable to bind.'),
|
|
33
|
+
example: 'ntp_server',
|
|
34
|
+
required: true
|
|
35
|
+
param :data_type,
|
|
36
|
+
%w[string integer boolean float array dictionary],
|
|
37
|
+
desc: N_('Data type of the variable.'),
|
|
38
|
+
example: 'string',
|
|
39
|
+
required: true
|
|
40
|
+
param :raw_value,
|
|
41
|
+
String,
|
|
42
|
+
desc: N_('Value of the variable (must be valid YAML for any type).'),
|
|
43
|
+
example: "---\ntime.example.com",
|
|
44
|
+
required: true
|
|
45
|
+
param :assignable_type,
|
|
46
|
+
%w[ForemanAnsibleDirector::AnsibleCollectionRole ForemanAnsibleDirector::AnsibleRole],
|
|
47
|
+
desc: N_('Type of the assignable ForemanAnsibleDirector::(AnsibleCollectionRole | AnsibleRole).'),
|
|
48
|
+
required: true
|
|
49
|
+
param :assignable_namespace,
|
|
50
|
+
String,
|
|
51
|
+
desc: N_('Namespace of the assignable.'),
|
|
52
|
+
example: 'my_namespace',
|
|
53
|
+
required: true
|
|
54
|
+
param :assignable_name,
|
|
55
|
+
String,
|
|
56
|
+
desc: N_('Name of the assignable.'),
|
|
57
|
+
example: 'my_collection',
|
|
58
|
+
required: true
|
|
59
|
+
param :assignable_role_name,
|
|
60
|
+
String,
|
|
61
|
+
desc: N_('Name of the role within the collection (required for AnsibleCollectionRole).'),
|
|
62
|
+
example: 'my_role',
|
|
63
|
+
required: false
|
|
64
|
+
param :target,
|
|
65
|
+
String,
|
|
66
|
+
desc: N_('Target type for the binding (host | hostgroup).'),
|
|
67
|
+
example: 'host',
|
|
68
|
+
required: true
|
|
69
|
+
param :target_id,
|
|
70
|
+
:number,
|
|
71
|
+
desc: N_('ID of the target entity.'),
|
|
72
|
+
example: 1,
|
|
73
|
+
required: true
|
|
74
|
+
end
|
|
75
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
76
|
+
example <<~EXAMPLE
|
|
77
|
+
{
|
|
78
|
+
"organization_id": 1,
|
|
79
|
+
"ansible_variable_binding": {
|
|
80
|
+
"variable_name": "ntp_server",
|
|
81
|
+
"data_type": "string",
|
|
82
|
+
"raw_value": "---\\ntime.example.com",
|
|
83
|
+
"assignable_type": "ForemanAnsibleDirector::AnsibleCollectionRole",
|
|
84
|
+
"assignable_namespace": "my_namespace",
|
|
85
|
+
"assignable_name": "my_collection",
|
|
86
|
+
"assignable_role_name": "my_role",
|
|
87
|
+
"target": "host",
|
|
88
|
+
"target_id": 1
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
EXAMPLE
|
|
92
|
+
# endregion
|
|
93
|
+
def create
|
|
94
|
+
binding_params = variable_binding_create_params
|
|
95
|
+
validate_yaml! variable_binding_create_params[:raw_value]
|
|
96
|
+
|
|
97
|
+
target = ::ForemanAnsibleDirector::AssignmentService.find_target(
|
|
98
|
+
target_type: binding_params[:target],
|
|
99
|
+
target_id: binding_params[:target_id]
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
@created_binding = ::ForemanAnsibleDirector::VariableBindingService.create_variable_binding(
|
|
103
|
+
variable_name: binding_params[:variable_name],
|
|
104
|
+
data_type: binding_params[:data_type],
|
|
105
|
+
raw_value: binding_params[:raw_value],
|
|
106
|
+
target: target,
|
|
107
|
+
assignable_type: binding_params[:assignable_type],
|
|
108
|
+
assignable_namespace: binding_params[:assignable_namespace],
|
|
109
|
+
assignable_name: binding_params[:assignable_name],
|
|
110
|
+
assignable_role_name: binding_params[:assignable_role_name],
|
|
111
|
+
organization_id: @organization.id
|
|
112
|
+
)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# region ApiDoc: PUT /api/v2/ansible_director/ansible_variables/bindings/:id
|
|
116
|
+
api :PUT, '/v2/ansible_director/ansible_variables/bindings/:id', N_('Update a variable binding')
|
|
117
|
+
description <<~DESC
|
|
118
|
+
Replace an entire variable binding. All binding attributes have to be provided. To update only a subset of+
|
|
119
|
+
arguments, consider using PATCH.
|
|
120
|
+
DESC
|
|
121
|
+
param :ansible_variable_binding, Hash, desc: N_('Variable binding updates'), required: true do
|
|
122
|
+
param :variable_name,
|
|
123
|
+
String,
|
|
124
|
+
desc: N_('Name of the Ansible variable to bind.'),
|
|
125
|
+
example: 'ntp_server',
|
|
126
|
+
required: true
|
|
127
|
+
param :data_type,
|
|
128
|
+
%w[string integer boolean float array dictionary],
|
|
129
|
+
desc: N_('Data type of the variable.'),
|
|
130
|
+
example: 'string',
|
|
131
|
+
required: true
|
|
132
|
+
param :raw_value,
|
|
133
|
+
String,
|
|
134
|
+
desc: N_('Value of the variable (must be valid YAML for any type).'),
|
|
135
|
+
example: '---\\ntime.example.com',
|
|
136
|
+
required: true
|
|
137
|
+
param :assignable_type,
|
|
138
|
+
%w[ForemanAnsibleDirector::AnsibleCollectionRole ForemanAnsibleDirector::AnsibleRole],
|
|
139
|
+
desc: N_('Type of the assignable ForemanAnsibleDirector::(AnsibleCollectionRole | AnsibleRole).'),
|
|
140
|
+
required: true
|
|
141
|
+
param :assignable_namespace,
|
|
142
|
+
String,
|
|
143
|
+
desc: N_('Namespace of the assignable.'),
|
|
144
|
+
example: 'my_namespace',
|
|
145
|
+
required: true
|
|
146
|
+
param :assignable_name,
|
|
147
|
+
String,
|
|
148
|
+
desc: N_('Name of the assignable.'),
|
|
149
|
+
example: 'my_collection',
|
|
150
|
+
required: true
|
|
151
|
+
param :assignable_role_name,
|
|
152
|
+
String,
|
|
153
|
+
desc: N_('Name of the role within the collection (required for AnsibleCollectionRole).'),
|
|
154
|
+
example: 'my_role',
|
|
155
|
+
required: false
|
|
156
|
+
param :target,
|
|
157
|
+
String,
|
|
158
|
+
desc: N_('Target type for the binding (host | hostgroup).'),
|
|
159
|
+
example: 'host',
|
|
160
|
+
required: true
|
|
161
|
+
param :target_id,
|
|
162
|
+
:number,
|
|
163
|
+
desc: N_('ID of the target entity.'),
|
|
164
|
+
example: 1,
|
|
165
|
+
required: true
|
|
166
|
+
end
|
|
167
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
168
|
+
example <<~EXAMPLE
|
|
169
|
+
{
|
|
170
|
+
"ansible_variable_binding": {
|
|
171
|
+
"data_type": "string",
|
|
172
|
+
"raw_value": "---\\ntime.example.com",
|
|
173
|
+
"variable_name": "ntp_server",
|
|
174
|
+
"assignable_type": "ForemanAnsibleDirector::AnsibleCollectionRole",
|
|
175
|
+
"assignable_namespace": "my_namespace",
|
|
176
|
+
"assignable_name": "my_collection",
|
|
177
|
+
"assignable_role_name": "my_role",
|
|
178
|
+
"target": "host",
|
|
179
|
+
"target_id": 1
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
EXAMPLE
|
|
183
|
+
# endregion
|
|
184
|
+
def update_full
|
|
185
|
+
variable_binding_params = variable_binding_full_params
|
|
186
|
+
validate_yaml! variable_binding_full_params[:raw_value]
|
|
187
|
+
|
|
188
|
+
::ForemanAnsibleDirector::VariableBindingService.edit_variable_binding(
|
|
189
|
+
variable_binding: @ansible_variable_binding,
|
|
190
|
+
**variable_binding_params
|
|
191
|
+
)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# region ApiDoc: PATCH /api/v2/ansible_director/ansible_variables/bindings/:id
|
|
195
|
+
api :PATCH, '/api/v2/ansible_director/ansible_variables/bindings/:id', N_('Partially update a variable binding')
|
|
196
|
+
description <<~DESC
|
|
197
|
+
Partially update an Ansible variable binding. To update every binding attribute, consider using PUT, which
|
|
198
|
+
informs you of missing attributes.
|
|
199
|
+
DESC
|
|
200
|
+
param :ansible_variable_binding, Hash, desc: N_('Variable binding updates'), required: true do
|
|
201
|
+
param :variable_name,
|
|
202
|
+
String,
|
|
203
|
+
desc: N_('Name of the Ansible variable to bind.'),
|
|
204
|
+
example: 'ntp_server',
|
|
205
|
+
required: false
|
|
206
|
+
param :data_type,
|
|
207
|
+
%w[string integer boolean float array dictionary],
|
|
208
|
+
desc: N_('Data type of the variable.'),
|
|
209
|
+
required: false
|
|
210
|
+
param :raw_value,
|
|
211
|
+
String,
|
|
212
|
+
desc: N_('Value of the variable (must be valid YAML for any type).'),
|
|
213
|
+
example: "---\ntime.example.com",
|
|
214
|
+
required: false
|
|
215
|
+
param :assignable_type,
|
|
216
|
+
%w[ForemanAnsibleDirector::AnsibleCollectionRole ForemanAnsibleDirector::AnsibleRole],
|
|
217
|
+
desc: N_('Type of the assignable ForemanAnsibleDirector::(AnsibleCollectionRole | AnsibleRole).'),
|
|
218
|
+
example: 'ForemanAnsibleDirector::AnsibleCollectionRole',
|
|
219
|
+
required: false
|
|
220
|
+
param :assignable_namespace,
|
|
221
|
+
String,
|
|
222
|
+
desc: N_('Namespace of the assignable.'),
|
|
223
|
+
example: 'my_namespace',
|
|
224
|
+
required: false
|
|
225
|
+
param :assignable_name,
|
|
226
|
+
String,
|
|
227
|
+
desc: N_('Name of the assignable.'),
|
|
228
|
+
example: 'my_collection',
|
|
229
|
+
required: false
|
|
230
|
+
param :assignable_role_name,
|
|
231
|
+
String,
|
|
232
|
+
desc: N_('Name of the role within the collection (required for AnsibleCollectionRole).'),
|
|
233
|
+
example: 'my_role',
|
|
234
|
+
required: false
|
|
235
|
+
param :target,
|
|
236
|
+
String,
|
|
237
|
+
desc: N_('Target type for the binding (host | hostgroup).'),
|
|
238
|
+
example: 'host',
|
|
239
|
+
required: false
|
|
240
|
+
param :target_id,
|
|
241
|
+
:number,
|
|
242
|
+
desc: N_('ID of the target entity.'),
|
|
243
|
+
example: 1,
|
|
244
|
+
required: false
|
|
245
|
+
end
|
|
246
|
+
# TRANSLATORS: ApiDoc, do not translate!
|
|
247
|
+
example <<~EXAMPLE
|
|
248
|
+
{
|
|
249
|
+
"ansible_variable_binding": {
|
|
250
|
+
"raw_value": "---\\nnew-time.example.com"
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
EXAMPLE
|
|
254
|
+
# endregion
|
|
255
|
+
def update_partial
|
|
256
|
+
variable_binding_params = variable_binding_partial_params
|
|
257
|
+
validate_yaml! variable_binding_partial_params[:raw_value]
|
|
258
|
+
|
|
259
|
+
::ForemanAnsibleDirector::VariableBindingService.edit_variable_binding(
|
|
260
|
+
variable_binding: @ansible_variable_binding,
|
|
261
|
+
**variable_binding_params
|
|
262
|
+
)
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
# region ApiDoc: DELETE /api/v2/ansible_director/ansible_variables/bindings/:id
|
|
266
|
+
api :DELETE, '/api/v2/ansible_director/ansible_variables/bindings/:id', N_('Delete a variable binding')
|
|
267
|
+
param :id, :number, desc: N_('Variable Binding identifier'), required: true
|
|
268
|
+
# endregion
|
|
269
|
+
def destroy
|
|
270
|
+
::ForemanAnsibleDirector::VariableBindingService.destroy_variable_binding(@ansible_variable_binding)
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
def resource_class
|
|
274
|
+
::ForemanAnsibleDirector::AnsibleVariableBinding
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def resource_scope
|
|
278
|
+
organization_scoped_resource_scope
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
private
|
|
282
|
+
|
|
283
|
+
def find_variable
|
|
284
|
+
@ansible_variable = ::ForemanAnsibleDirector::AnsibleVariable.find_by!(id: params[:id])
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def base_params
|
|
288
|
+
root_node = params.require(:ansible_variable_binding)
|
|
289
|
+
root_node.permit(
|
|
290
|
+
:data_type,
|
|
291
|
+
:raw_value,
|
|
292
|
+
:assignable_namespace,
|
|
293
|
+
:assignable_name,
|
|
294
|
+
:assignable_role_name,
|
|
295
|
+
:assignable_type,
|
|
296
|
+
:variable_name,
|
|
297
|
+
:target,
|
|
298
|
+
:target_id
|
|
299
|
+
)
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
def variable_binding_create_params
|
|
303
|
+
root_node = base_params
|
|
304
|
+
{
|
|
305
|
+
**variable_binding_full_params,
|
|
306
|
+
assignable_namespace: root_node.require(:assignable_namespace),
|
|
307
|
+
assignable_name: root_node.require(:assignable_name),
|
|
308
|
+
assignable_role_name: if params[:assignable_type] == 'ForemanAnsibleDirector::AnsibleCollectionRole'
|
|
309
|
+
root_node.require(:assignable_role_name)
|
|
310
|
+
else
|
|
311
|
+
root_node[:assignable_role_name]
|
|
312
|
+
end,
|
|
313
|
+
assignable_type: root_node.require(:assignable_type),
|
|
314
|
+
target: params[:target] || root_node.require(:target),
|
|
315
|
+
target_id: params[:target_id] || root_node.require(:target_id),
|
|
316
|
+
}
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
def variable_binding_full_params
|
|
320
|
+
root_node = base_params
|
|
321
|
+
{
|
|
322
|
+
data_type: root_node.require(:data_type),
|
|
323
|
+
raw_value: root_node.require(:raw_value),
|
|
324
|
+
variable_name: root_node.require(:variable_name),
|
|
325
|
+
}
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
def variable_binding_partial_params
|
|
329
|
+
root_node = base_params
|
|
330
|
+
{
|
|
331
|
+
data_type: root_node[:data_type],
|
|
332
|
+
raw_value: root_node[:raw_value],
|
|
333
|
+
variable_name: root_node[:variable_name],
|
|
334
|
+
}.compact
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
def validate_yaml!(string)
|
|
338
|
+
YAML.safe_load(string)
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
def controller_permission
|
|
342
|
+
'ansible_director_variable_overrides'
|
|
343
|
+
end
|
|
344
|
+
end
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
end
|