Today submitting an unbatched `ClusterStateUpdateTask` to the `MasterService` is deprecated, and devs are encouraged to write their own batching executor instead. In principle this makes it possible to combine updates without incurring the costs of building a whole new `ClusterState` on each iteration, but in practice most implementations don't work at a lower level and just iteratively update a `ClusterState`. Moreover creating new `ClusterState` instances is nothing like as expensive as once it was.

We should accept this and provide some friendlier utilities for writing batched cluster state updates, ideally leaving the developer to express the desired per-task update as a `ClusterState -> ClusterState` operator.
server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateService.java
public ClusterState execute(ClusterState currentState) throws Exception {
                    validateTemplate(request.settings, request.mappings, indicesService);
                    return innerPutTemplate(currentState, request, templateBuilder);
                }
            },
            ClusterStateTaskConfig.build(Priority.URGENT, request.masterTimeout),
            TEMPLATE_TASK_EXECUTOR
        );
    }
    
    static ClusterState innerPutTemplate(
        final ClusterState currentState,
        PutRequest request,
        IndexTemplateMetadata.Builder templateBuilder
    ) {
        
        
        boolean isUpdate = currentState.metadata().templates().containsKey(request.name);
        if (request.create && isUpdate) {
            throw new IllegalArgumentException("index_template [" + request.name + "] already exists");
        }
        boolean isUpdateAndPatternsAreUnchanged = isUpdate
            && currentState.metadata().templates().get(request.name).patterns().equals(request.indexPatterns);
        Map<String, List<String>> overlaps = findConflictingV2Templates(currentState, request.name, request.indexPatterns);
        if (overlaps.size() > 0) {
            
            if (isUpdateAndPatternsAreUnchanged || request.indexPatterns.stream().anyMatch(Regex::isMatchAllPattern)) {
                String warning = String.format(
                    Locale.ROOT,
                    "legacy template [%s] has index patterns %s matching patterns"